nao-core 0.0.8__tar.gz → 0.0.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nao_core-0.0.8 → nao_core-0.0.9}/PKG-INFO +1 -1
- {nao_core-0.0.8 → nao_core-0.0.9}/nao_core/__init__.py +1 -1
- {nao_core-0.0.8 → nao_core-0.0.9}/nao_core/commands/chat.py +15 -1
- {nao_core-0.0.8 → nao_core-0.0.9}/nao_core/commands/init.py +31 -3
- nao_core-0.0.9/nao_core/config.py +64 -0
- {nao_core-0.0.8 → nao_core-0.0.9}/pyproject.toml +1 -1
- nao_core-0.0.8/nao_core/config.py +0 -35
- {nao_core-0.0.8 → nao_core-0.0.9}/.gitignore +0 -0
- {nao_core-0.0.8 → nao_core-0.0.9}/LICENSE +0 -0
- {nao_core-0.0.8 → nao_core-0.0.9}/README.md +0 -0
- {nao_core-0.0.8 → nao_core-0.0.9}/nao_core/bin/db.sqlite +0 -0
- {nao_core-0.0.8 → nao_core-0.0.9}/nao_core/bin/nao-chat-server +0 -0
- {nao_core-0.0.8 → nao_core-0.0.9}/nao_core/bin/public/assets/index-BSxC58nD.js +0 -0
- {nao_core-0.0.8 → nao_core-0.0.9}/nao_core/bin/public/assets/index-Dh3br3Ia.js +0 -0
- {nao_core-0.0.8 → nao_core-0.0.9}/nao_core/bin/public/assets/index-heKLHGGE.css +0 -0
- {nao_core-0.0.8 → nao_core-0.0.9}/nao_core/bin/public/favicon.ico +0 -0
- {nao_core-0.0.8 → nao_core-0.0.9}/nao_core/bin/public/index.html +0 -0
- {nao_core-0.0.8 → nao_core-0.0.9}/nao_core/commands/__init__.py +0 -0
- {nao_core-0.0.8 → nao_core-0.0.9}/nao_core/main.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nao-core
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.9
|
|
4
4
|
Summary: nao Core is your analytics context builder with the best chat interface.
|
|
5
5
|
Project-URL: Homepage, https://github.com/naolabs/chat
|
|
6
6
|
Project-URL: Repository, https://github.com/naolabs/chat
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import os
|
|
2
|
-
import signal
|
|
3
2
|
import subprocess
|
|
4
3
|
import sys
|
|
5
4
|
import webbrowser
|
|
@@ -8,6 +7,8 @@ from time import sleep
|
|
|
8
7
|
|
|
9
8
|
from rich.console import Console
|
|
10
9
|
|
|
10
|
+
from nao_core.config import NaoConfig
|
|
11
|
+
|
|
11
12
|
console = Console()
|
|
12
13
|
|
|
13
14
|
# Default port for the nao chat server
|
|
@@ -63,6 +64,13 @@ def chat():
|
|
|
63
64
|
console.print(f"[dim]Server binary: {binary_path}[/dim]")
|
|
64
65
|
console.print(f"[dim]Working directory: {bin_dir}[/dim]")
|
|
65
66
|
|
|
67
|
+
# Try to load nao config from current directory
|
|
68
|
+
config = NaoConfig.try_load()
|
|
69
|
+
if config:
|
|
70
|
+
console.print(f"[bold green]✓[/bold green] Loaded config from {Path.cwd() / 'nao_config.yaml'}")
|
|
71
|
+
else:
|
|
72
|
+
console.print("[dim]No nao_config.yaml found in current directory[/dim]")
|
|
73
|
+
|
|
66
74
|
# Start the server process
|
|
67
75
|
process = None
|
|
68
76
|
try:
|
|
@@ -70,6 +78,12 @@ def chat():
|
|
|
70
78
|
# so the server can find the public folder
|
|
71
79
|
env = os.environ.copy()
|
|
72
80
|
|
|
81
|
+
# Set LLM API key from config if available
|
|
82
|
+
if config and config.llm:
|
|
83
|
+
env_var_name = f"{config.llm.model.upper()}_API_KEY"
|
|
84
|
+
env[env_var_name] = config.llm.api_key
|
|
85
|
+
console.print(f"[bold green]✓[/bold green] Set {env_var_name} from config")
|
|
86
|
+
|
|
73
87
|
process = subprocess.Popen(
|
|
74
88
|
[str(binary_path)],
|
|
75
89
|
cwd=str(bin_dir),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
|
|
3
3
|
from rich.console import Console
|
|
4
|
-
from rich.prompt import Prompt
|
|
4
|
+
from rich.prompt import Confirm, Prompt
|
|
5
5
|
|
|
6
|
-
from nao_core.config import NaoConfig
|
|
6
|
+
from nao_core.config import LLMConfig, LLMProvider, NaoConfig
|
|
7
7
|
|
|
8
8
|
console = Console()
|
|
9
9
|
|
|
@@ -29,9 +29,37 @@ def init():
|
|
|
29
29
|
)
|
|
30
30
|
return
|
|
31
31
|
|
|
32
|
+
# LLM Configuration
|
|
33
|
+
llm_config = None
|
|
34
|
+
setup_llm = Confirm.ask("\n[bold]Set up LLM configuration?[/bold]", default=True)
|
|
35
|
+
|
|
36
|
+
if setup_llm:
|
|
37
|
+
console.print("\n[bold cyan]LLM Configuration[/bold cyan]\n")
|
|
38
|
+
|
|
39
|
+
provider_choices = [p.value for p in LLMProvider]
|
|
40
|
+
llm_provider = Prompt.ask(
|
|
41
|
+
"[bold]Select LLM provider[/bold]",
|
|
42
|
+
choices=provider_choices,
|
|
43
|
+
default=provider_choices[0],
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
api_key = Prompt.ask(
|
|
47
|
+
f"[bold]Enter your {llm_provider.upper()} API key[/bold]",
|
|
48
|
+
password=True,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
if not api_key:
|
|
52
|
+
console.print("[bold red]✗[/bold red] API key cannot be empty.")
|
|
53
|
+
return
|
|
54
|
+
|
|
55
|
+
llm_config = LLMConfig(
|
|
56
|
+
model=LLMProvider(llm_provider),
|
|
57
|
+
api_key=api_key,
|
|
58
|
+
)
|
|
59
|
+
|
|
32
60
|
project_path.mkdir(parents=True)
|
|
33
61
|
|
|
34
|
-
config = NaoConfig(project_name=project_name)
|
|
62
|
+
config = NaoConfig(project_name=project_name, llm=llm_config)
|
|
35
63
|
config.save(project_path)
|
|
36
64
|
|
|
37
65
|
console.print()
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import yaml
|
|
5
|
+
from pydantic import BaseModel, Field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class LLMProvider(str, Enum):
|
|
9
|
+
"""Supported LLM providers."""
|
|
10
|
+
|
|
11
|
+
OPENAI = "openai"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class LLMConfig(BaseModel):
|
|
15
|
+
"""LLM configuration."""
|
|
16
|
+
|
|
17
|
+
model: LLMProvider = Field(description="The LLM provider to use")
|
|
18
|
+
api_key: str = Field(description="The API key to use")
|
|
19
|
+
|
|
20
|
+
class NaoConfig(BaseModel):
|
|
21
|
+
"""nao project configuration."""
|
|
22
|
+
|
|
23
|
+
project_name: str = Field(description="The name of the nao project")
|
|
24
|
+
llm: LLMConfig | None = Field(default=None, description="The LLM configuration")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def save(self, path: Path) -> None:
|
|
28
|
+
"""Save the configuration to a YAML file."""
|
|
29
|
+
config_file = path / "nao_config.yaml"
|
|
30
|
+
with config_file.open("w") as f:
|
|
31
|
+
yaml.dump(
|
|
32
|
+
self.model_dump(mode="json"),
|
|
33
|
+
f,
|
|
34
|
+
default_flow_style=False,
|
|
35
|
+
sort_keys=False,
|
|
36
|
+
allow_unicode=True,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
@classmethod
|
|
40
|
+
def load(cls, path: Path) -> "NaoConfig":
|
|
41
|
+
"""Load the configuration from a YAML file."""
|
|
42
|
+
config_file = path / "nao_config.yaml"
|
|
43
|
+
with config_file.open() as f:
|
|
44
|
+
data = yaml.safe_load(f)
|
|
45
|
+
return cls.model_validate(data)
|
|
46
|
+
|
|
47
|
+
@classmethod
|
|
48
|
+
def try_load(cls, path: Path | None = None) -> "NaoConfig | None":
|
|
49
|
+
"""Try to load config from path, returns None if not found or invalid.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
path: Directory containing nao_config.yaml. Defaults to current directory.
|
|
53
|
+
"""
|
|
54
|
+
if path is None:
|
|
55
|
+
path = Path.cwd()
|
|
56
|
+
try:
|
|
57
|
+
return cls.load(path)
|
|
58
|
+
except (FileNotFoundError, ValueError, yaml.YAMLError):
|
|
59
|
+
return None
|
|
60
|
+
|
|
61
|
+
@classmethod
|
|
62
|
+
def json_schema(cls) -> dict:
|
|
63
|
+
"""Generate JSON schema for the configuration."""
|
|
64
|
+
return cls.model_json_schema()
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
import yaml
|
|
4
|
-
from pydantic import BaseModel, Field
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class NaoConfig(BaseModel):
|
|
8
|
-
"""nao project configuration."""
|
|
9
|
-
|
|
10
|
-
project_name: str = Field(description="The name of the nao project")
|
|
11
|
-
|
|
12
|
-
def save(self, path: Path) -> None:
|
|
13
|
-
"""Save the configuration to a YAML file."""
|
|
14
|
-
config_file = path / "nao_config.yaml"
|
|
15
|
-
with config_file.open("w") as f:
|
|
16
|
-
yaml.dump(
|
|
17
|
-
self.model_dump(),
|
|
18
|
-
f,
|
|
19
|
-
default_flow_style=False,
|
|
20
|
-
sort_keys=False,
|
|
21
|
-
allow_unicode=True,
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
@classmethod
|
|
25
|
-
def load(cls, path: Path) -> "NaoConfig":
|
|
26
|
-
"""Load the configuration from a YAML file."""
|
|
27
|
-
config_file = path / "nao_config.yaml"
|
|
28
|
-
with config_file.open() as f:
|
|
29
|
-
data = yaml.safe_load(f)
|
|
30
|
-
return cls.model_validate(data)
|
|
31
|
-
|
|
32
|
-
@classmethod
|
|
33
|
-
def json_schema(cls) -> dict:
|
|
34
|
-
"""Generate JSON schema for the configuration."""
|
|
35
|
-
return cls.model_json_schema()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|