mirror of
https://github.com/katanemo/plano.git
synced 2026-06-26 15:39:40 +02:00
Address PR feedback: move uuid import to top, reuse parsed config in up()
This commit is contained in:
parent
bbe9946207
commit
00cafbb192
2 changed files with 8 additions and 9 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import uuid
|
||||||
from planoai.utils import convert_legacy_listeners
|
from planoai.utils import convert_legacy_listeners
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
import yaml
|
import yaml
|
||||||
|
|
@ -343,8 +344,6 @@ def validate_and_render_schema():
|
||||||
model_provider["base_url"] = CHATGPT_API_BASE
|
model_provider["base_url"] = CHATGPT_API_BASE
|
||||||
if not model_provider.get("access_key"):
|
if not model_provider.get("access_key"):
|
||||||
model_provider["access_key"] = "$CHATGPT_ACCESS_TOKEN"
|
model_provider["access_key"] = "$CHATGPT_ACCESS_TOKEN"
|
||||||
import uuid
|
|
||||||
|
|
||||||
headers = model_provider.get("headers", {})
|
headers = model_provider.get("headers", {})
|
||||||
headers.setdefault(
|
headers.setdefault(
|
||||||
"ChatGPT-Account-Id",
|
"ChatGPT-Account-Id",
|
||||||
|
|
|
||||||
|
|
@ -119,13 +119,8 @@ def _temporary_cli_log_level(level: str | None):
|
||||||
set_log_level(current_level)
|
set_log_level(current_level)
|
||||||
|
|
||||||
|
|
||||||
def _inject_chatgpt_tokens_if_needed(plano_config_file, env, console):
|
def _inject_chatgpt_tokens_if_needed(config, env, console):
|
||||||
"""If config uses chatgpt providers, resolve tokens from ~/.plano/chatgpt/auth.json."""
|
"""If config uses chatgpt providers, resolve tokens from ~/.plano/chatgpt/auth.json."""
|
||||||
import yaml
|
|
||||||
|
|
||||||
with open(plano_config_file, "r") as f:
|
|
||||||
config = yaml.safe_load(f)
|
|
||||||
|
|
||||||
providers = config.get("model_providers") or config.get("llm_providers") or []
|
providers = config.get("model_providers") or config.get("llm_providers") or []
|
||||||
has_chatgpt = any(str(p.get("model", "")).startswith("chatgpt/") for p in providers)
|
has_chatgpt = any(str(p.get("model", "")).startswith("chatgpt/") for p in providers)
|
||||||
if not has_chatgpt:
|
if not has_chatgpt:
|
||||||
|
|
@ -412,8 +407,13 @@ def up(file, path, foreground, with_tracing, tracing_port, docker, verbose):
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env.pop("PATH", None)
|
env.pop("PATH", None)
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
with open(plano_config_file, "r") as f:
|
||||||
|
plano_config = yaml.safe_load(f)
|
||||||
|
|
||||||
# Inject ChatGPT tokens from ~/.plano/chatgpt/auth.json if any provider needs them
|
# Inject ChatGPT tokens from ~/.plano/chatgpt/auth.json if any provider needs them
|
||||||
_inject_chatgpt_tokens_if_needed(plano_config_file, env, console)
|
_inject_chatgpt_tokens_if_needed(plano_config, env, console)
|
||||||
|
|
||||||
# Check access keys
|
# Check access keys
|
||||||
access_keys = get_llm_provider_access_keys(plano_config_file=plano_config_file)
|
access_keys = get_llm_provider_access_keys(plano_config_file=plano_config_file)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue