Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Up dev 'watch' for aiconfig-editor declarations HMR #955

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"**/*.code-search": true,
"**/.next": true,
"**/.sl": true,
"yarn.lock": true
"yarn.lock": true,
"**/dist": true
},
"editor.formatOnSave": true,
"[javascript]": {
Expand Down
1 change: 1 addition & 0 deletions python/src/aiconfig/editor/client/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@types/",
"build/",
"node_modules/",
"config-overrides.js",
"public/",
"postbuild.js"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
]
},
"ignorePatterns": ["dist/", "node_modules/"]
}
27 changes: 27 additions & 0 deletions python/src/aiconfig/editor/client/aiconfig-editor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# AIConfigEditor

This component library provides an AIConfigEditor React component for renderering a customizable AIConfig file editor in React.

## Usage

To render the editor component, simply render an AIConfigEditor within your JSX, passing in an AIConfig object:

```
<AIConfigEditor aiconfig={aiconfig} />
```

## Customization

The editor component can be customized to suit different needs. The following customizations are supported:

### Readonly Editor

// TODO

### Custom Callbacks

// TODO

### Custom Styles

// TODO
64 changes: 64 additions & 0 deletions python/src/aiconfig/editor/client/aiconfig-editor/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "@lastmileai/aiconfig-editor",
"version": "0.1.13",
"description": "React component for editing aiconfig files",
"author": "LastMile AI",
"license": "UNLICENSED",
"keywords": [
"aiconfig",
"editor",
"react"
],
"type": "module",
"main": "dist/index.cjs.js",
"module": "dist/index.es.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && vite build",
"dev": "yarn clean && vite build --config vite.config.dev.ts",
"clean": "rm -rf dist",
"lint": "eslint . --max-warnings=0"
},
"dependencies": {
"@emotion/react": "^11.11.1",
"@mantine/carousel": "^6.0.7",
"@mantine/core": "^6.0.7",
"@mantine/dates": "^6.0.16",
"@mantine/dropzone": "^6.0.7",
"@mantine/form": "^6.0.7",
"@mantine/hooks": "^6.0.7",
"@mantine/modals": "^6.0.7",
"@mantine/notifications": "^6.0.7",
"@mantine/prism": "^6.0.7",
"@monaco-editor/react": "^4.6.0",
"@tabler/icons-react": "^2.44.0",
"aiconfig": "^1.1.6",
"lodash": "^4.17.21",
"node-fetch": "^3.3.2",
"react-error-boundary": "^4.0.12",
"react-markdown": "^8.0.6",
"remark-gfm": "^3.0.1",
"uuid": "^9.0.1"
},
"peerDependencies": {
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@types/lodash": "^4.14.202",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/uuid": "^9.0.7",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"eslint": "^8",
"eslint-config-next": "14.0.2",
"eslint-plugin-react-hooks": "^4.6.0",
"typescript": "^5",
"vite": "^5.0.11",
"vite-plugin-dts": "^3.7.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { createContext } from "react";
import { ClientAIConfig } from "../shared/types";

/**
* Context for overall editor config state. This context should
* be memoized to prevent unnecessary re-renders
*/
const AIConfigContext = createContext<{
getState: () => ClientAIConfig;
}>({
getState: () => ({ prompts: [], _ui: { isDirty: false } }),
});

export default AIConfigContext;
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export type AIConfigCallbacks = {

type RequestCallbackError = { message?: string };

export default function AIConfigEditor({
export function AIConfigEditor({
aiconfig: initialAIConfig,
callbacks,
mode,
Expand Down
Loading
Loading