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

[1/n] Add load_json and load_yaml methods to AIConfigRuntime #1057

Merged
merged 1 commit into from
Jan 30, 2024
Merged

Conversation

saqadri
Copy link
Contributor

@saqadri saqadri commented Jan 29, 2024

[1/n] Add load_json and load_yaml methods to AIConfigRuntime

Allow loading an AIConfigRuntime from a string. There's already a loadJSON method in the TS SDK.

This is needed for VSCode extension (top of stack), which gets the state of the document from the editor (and which can contain unsaved changes that aren't present on the filesystem).

Test Plan:

Tested out getting started ipynb with:

load JSON:

config = AIConfigRuntime.load('travel.aiconfig.json')

load YAML:

config.save('travel.aiconfig.yaml', mode="yaml")
yaml_str = ""
with open('travel.aiconfig.yaml') as file:
    yaml_str = file.read()

config = AIConfigRuntime.load_yaml(yaml_str)

Made sure config runtime is valid and tried config.run


Stack created with Sapling. Best reviewed with ReviewStack.

Copy link
Contributor

@rholinshead rholinshead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Allow loading an AIConfigRuntime from a string. There's already a `loadJSON` method in the TS SDK.

This is needed for VSCode extension (top of stack), which gets the state of the document from the editor (and which can contain unsaved changes that aren't present on the filesystem).

Test Plan:

Tested out getting started ipynb with:

load JSON:

```
config = AIConfigRuntime.load('travel.aiconfig.json')
```

load YAML:
```
config.save('travel.aiconfig.yaml', mode="yaml")
yaml_str = ""
with open('travel.aiconfig.yaml') as file:
    yaml_str = file.read()

config = AIConfigRuntime.load_yaml(yaml_str)
```

Made sure config runtime is valid and tried `config.run`
saqadri added a commit that referenced this pull request Jan 30, 2024
[4/n] Add 'start' command to aiconfig server and CLI


The current aiconfig CLI has an 'edit' command which starts both the
frontend and backend servers, and also loads the aiconfig from disk.

In the same vein, this diff introduces a 'start' command that is used to
just start the aiconfig server. This is used by the vscode extension to
spawn a server when an aiconfig file is opened.

Unlike the 'edit' command, 'start':
* Doesn't load the aiconfig on server init. Instead, the
/api/load_content endpoint is called to initialize.
* Doesn't search for open ports. The vscode client is responsible for
finding an open port. This is because the client needs to be in control
of the server lifecycle.

A small change that was also added to this diff: using `dotenv` to load
an env file.

Test Plan:
* At the top of stack

---
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with
[ReviewStack](https://reviewstack.dev/lastmile-ai/aiconfig/pull/1060).
* #1076
* __->__ #1060
* #1059
* #1058
* #1057
@saqadri saqadri merged commit d42d594 into main Jan 30, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants