Skip to content

Commit

Permalink
[cli] support no config file (#84)
Browse files Browse the repository at this point in the history
* Fix typos for CLI

* temporary workaround to set up the openai key

* fix format
  • Loading branch information
qizheng7 authored May 24, 2023
1 parent 1d107eb commit 6dfaa8c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions skyagi/src/skyagi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ def run():
answers = inquirer.prompt(questions=questions)
settings.model = load_model_setting(answers["llm-model"])

openai_key = config.load_openai_token()
if os.getenv("OPENAI_API_KEY") is None:
os.environ["OPENAI_API_KEY"] = openai_key

# Model initialization verification
res = util.verify_model_initialization(settings)
if res != "OK":
Expand Down
2 changes: 1 addition & 1 deletion skyagi/src/skyagi/model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Type, List
from typing import Dict, List, Type

from langchain import chat_models, embeddings, llms
from langchain.embeddings.base import Embeddings
Expand Down
9 changes: 6 additions & 3 deletions skyagi/src/skyagi/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from typing import Any, Dict, Type, List
from typing import Any, Dict, List, Type

from pydantic import BaseModel, BaseSettings, Extra

Expand All @@ -9,9 +9,12 @@ def json_config_settings_source(settings: BaseSettings) -> Dict[str, Any]:

# Load settings from JSON config file
config_dir = Path(Path.home(), ".skyagi")
if not config_dir.exists():
return ""
config_file = Path(config_dir, "config.json")
if not config_dir.exists() or not config_file.exists():
print("[Error] Please config skyagi first by running `skyagi config --help`")
import sys

sys.exit(-1)
return load_json(config_file)


Expand Down

1 comment on commit 6dfaa8c

@vercel
Copy link

@vercel vercel bot commented on 6dfaa8c May 24, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

skyagi – ./

skyagi-git-main-sky-agi.vercel.app
skyagi-sky-agi.vercel.app
app.skyagi.ai
skyagi.vercel.app

Please sign in to comment.