naas-abi-cli 1.4.4__py3-none-any.whl → 1.5.0__py3-none-any.whl
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.
- naas_abi_cli/cli/new/project.py +1 -2
- naas_abi_cli/cli/new/templates/project/config.prod.yaml +67 -0
- naas_abi_cli/cli/new/templates/project/config.yaml +8 -3
- naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/__init__.py +31 -0
- naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/agents/Agent.py +52 -0
- naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/agents/README.md +0 -0
- naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/orchestrations/README.md +0 -0
- naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/pipelines/README.md +0 -0
- naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/workflows/README.md +0 -0
- naas_abi_cli/cli/utils/Copier.py +30 -12
- {naas_abi_cli-1.4.4.dist-info → naas_abi_cli-1.5.0.dist-info}/METADATA +1 -1
- {naas_abi_cli-1.4.4.dist-info → naas_abi_cli-1.5.0.dist-info}/RECORD +14 -8
- {naas_abi_cli-1.4.4.dist-info → naas_abi_cli-1.5.0.dist-info}/WHEEL +0 -0
- {naas_abi_cli-1.4.4.dist-info → naas_abi_cli-1.5.0.dist-info}/entry_points.txt +0 -0
naas_abi_cli/cli/new/project.py
CHANGED
|
@@ -2,7 +2,6 @@ import os
|
|
|
2
2
|
import subprocess
|
|
3
3
|
|
|
4
4
|
import click
|
|
5
|
-
|
|
6
5
|
import naas_abi_cli
|
|
7
6
|
from naas_abi_cli.cli.utils.Copier import Copier
|
|
8
7
|
|
|
@@ -24,7 +23,6 @@ def new_project(project_name: str | None, project_path: str | None):
|
|
|
24
23
|
# Ensure the last path component matches the project name, not just the suffix.
|
|
25
24
|
if os.path.basename(os.path.normpath(project_path)) != project_name:
|
|
26
25
|
project_path = os.path.join(project_path, project_name)
|
|
27
|
-
print(project_path)
|
|
28
26
|
|
|
29
27
|
if not os.path.exists(project_path):
|
|
30
28
|
os.makedirs(project_path, exist_ok=True)
|
|
@@ -42,6 +40,7 @@ def new_project(project_name: str | None, project_path: str | None):
|
|
|
42
40
|
values={
|
|
43
41
|
"project_name": project_name,
|
|
44
42
|
"project_name_snake": project_name.replace("-", "_"),
|
|
43
|
+
"project_name_pascal": project_name.replace("-", "").capitalize(),
|
|
45
44
|
}
|
|
46
45
|
)
|
|
47
46
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
deploy:
|
|
2
|
+
workspace_id: "{{ naas_workspace_id }}"
|
|
3
|
+
space_name: "{{ project_name_snake }}-abi-api"
|
|
4
|
+
{% raw %}
|
|
5
|
+
naas_api_key: "{{ secret.NAAS_API_KEY }}"
|
|
6
|
+
env:
|
|
7
|
+
ENV: "prod"
|
|
8
|
+
NAAS_API_KEY: "{{ secret.NAAS_API_KEY }}"
|
|
9
|
+
OPENAI_API_KEY: "{{ secret.OPENAI_API_KEY }}"
|
|
10
|
+
ABI_API_KEY: "{{ secret.ABI_API_KEY }}"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
auto_publish:
|
|
14
|
+
enabled: true # Enable automatic publishing of agents to workspace
|
|
15
|
+
exclude_agents: [] # Agents to exclude from auto-publishing (empty list means publish all enabled agents)
|
|
16
|
+
default_agent: "Abi" # Which agent to set as default in workspace
|
|
17
|
+
|
|
18
|
+
api:
|
|
19
|
+
title: "ABI API"
|
|
20
|
+
description: "API for ABI, your Artifical Business Intelligence"
|
|
21
|
+
logo_path: "assets/logo.png"
|
|
22
|
+
favicon_path: "assets/favicon.ico"
|
|
23
|
+
cors_origins:
|
|
24
|
+
- "http://localhost:9879"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
global_config:
|
|
28
|
+
ai_mode: "cloud"
|
|
29
|
+
|
|
30
|
+
modules:
|
|
31
|
+
- module: naas_abi
|
|
32
|
+
enabled: true
|
|
33
|
+
- module: naas_abi_marketplace.ai.chatgpt
|
|
34
|
+
enabled: true
|
|
35
|
+
config:
|
|
36
|
+
openai_api_key: "{{ secret.OPENAI_API_KEY }}"
|
|
37
|
+
{% endraw %}
|
|
38
|
+
- module: {{ project_name_snake }}
|
|
39
|
+
enabled: true
|
|
40
|
+
|
|
41
|
+
{% raw %}
|
|
42
|
+
services:
|
|
43
|
+
secret:
|
|
44
|
+
secret_adapters:
|
|
45
|
+
- adapter: "naas"
|
|
46
|
+
config:
|
|
47
|
+
naas_api_key: "{{ secret.NAAS_API_KEY }}"
|
|
48
|
+
naas_api_url: "https://api.naas.ai"
|
|
49
|
+
object_storage:
|
|
50
|
+
object_storage_adapter:
|
|
51
|
+
adapter: "naas"
|
|
52
|
+
config:
|
|
53
|
+
naas_api_key: "{{ secret.NAAS_API_KEY }}"
|
|
54
|
+
workspace_id: "{{ secret.NAAS_WORKSPACE_ID }}"
|
|
55
|
+
storage_name: "{{ secret.NAAS_STORAGE_NAME }}"
|
|
56
|
+
base_prefix: "datastore"
|
|
57
|
+
triple_store:
|
|
58
|
+
triple_store_adapter:
|
|
59
|
+
adapter: "fs"
|
|
60
|
+
config:
|
|
61
|
+
store_path: "storage/triplestore"
|
|
62
|
+
vector_store:
|
|
63
|
+
vector_store_adapter:
|
|
64
|
+
adapter: "qdrant"
|
|
65
|
+
config: {}
|
|
66
|
+
|
|
67
|
+
{% endraw %}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
deploy:
|
|
2
|
-
workspace_id: "
|
|
3
|
-
space_name: "
|
|
2
|
+
workspace_id: "{{ naas_workspace_id }}"
|
|
3
|
+
space_name: "{{ project_name_snake }}-abi-api"
|
|
4
|
+
{% raw %}
|
|
4
5
|
naas_api_key: "{{ secret.NAAS_API_KEY }}"
|
|
5
6
|
env:
|
|
6
7
|
NAAS_API_KEY: "{{ secret.NAAS_API_KEY }}"
|
|
7
8
|
OPENAI_API_KEY: "{{ secret.OPENAI_API_KEY }}"
|
|
8
9
|
ABI_API_KEY: "{{ secret.ABI_API_KEY }}"
|
|
9
10
|
|
|
10
|
-
|
|
11
11
|
auto_publish:
|
|
12
12
|
enabled: true # Enable automatic publishing of agents to workspace
|
|
13
13
|
exclude_agents: [] # Agents to exclude from auto-publishing (empty list means publish all enabled agents)
|
|
@@ -32,7 +32,11 @@ modules:
|
|
|
32
32
|
enabled: true
|
|
33
33
|
config:
|
|
34
34
|
openai_api_key: "{{ secret.OPENAI_API_KEY }}"
|
|
35
|
+
{% endraw %}
|
|
36
|
+
- module: {{ project_name_snake }}
|
|
37
|
+
enabled: true
|
|
35
38
|
|
|
39
|
+
{% raw %}
|
|
36
40
|
services:
|
|
37
41
|
secret:
|
|
38
42
|
secret_adapters:
|
|
@@ -52,3 +56,4 @@ services:
|
|
|
52
56
|
vector_store_adapter:
|
|
53
57
|
adapter: "qdrant"
|
|
54
58
|
config: {}
|
|
59
|
+
{% endraw %}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from naas_abi_core.module.Module import (
|
|
2
|
+
BaseModule,
|
|
3
|
+
ModuleConfiguration,
|
|
4
|
+
ModuleDependencies,
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
# from naas_abi_core.services.object_storage.ObjectStorageService import ObjectStorageService
|
|
8
|
+
# from naas_abi_core.services.secret.Secret import Secret
|
|
9
|
+
# from naas_abi_core.services.triple_store.TripleStoreService import TripleStoreService
|
|
10
|
+
# from naas_abi_core.services.vector_store.VectorStoreService import VectorStoreService
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ABIModule(BaseModule):
|
|
14
|
+
dependencies: ModuleDependencies = ModuleDependencies(
|
|
15
|
+
modules=[
|
|
16
|
+
"naas_abi_marketplace.ai.chatgpt",
|
|
17
|
+
],
|
|
18
|
+
services=[
|
|
19
|
+
# Secret,
|
|
20
|
+
# TripleStoreService,
|
|
21
|
+
# ObjectStorageService,
|
|
22
|
+
# VectorStoreService
|
|
23
|
+
],
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
class Configuration(ModuleConfiguration):
|
|
27
|
+
pass
|
|
28
|
+
# example: str
|
|
29
|
+
|
|
30
|
+
def on_initialized(self):
|
|
31
|
+
super().on_initialized()
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from naas_abi_core.services.agent.Agent import (
|
|
4
|
+
Agent,
|
|
5
|
+
AgentConfiguration,
|
|
6
|
+
AgentSharedState,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
NAME = "{{project_name_snake}} Agent"
|
|
10
|
+
DESCRIPTION = "An helpful agent that can help you with your tasks."
|
|
11
|
+
SYSTEM_PROMPT = """
|
|
12
|
+
You are {{project_name_snake}} Agent.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def create_agent(
|
|
17
|
+
agent_shared_state: Optional[AgentSharedState] = None,
|
|
18
|
+
agent_configuration: Optional[AgentConfiguration] = None,
|
|
19
|
+
) -> Optional[Agent]:
|
|
20
|
+
#from {{project_name_snake}} import ABIModule
|
|
21
|
+
|
|
22
|
+
# Set model
|
|
23
|
+
from naas_abi_marketplace.ai.chatgpt.models.gpt_5 import model as chatgpt_model
|
|
24
|
+
|
|
25
|
+
model = chatgpt_model.model
|
|
26
|
+
|
|
27
|
+
# Use provided configuration or create default one
|
|
28
|
+
if agent_configuration is None:
|
|
29
|
+
agent_configuration = AgentConfiguration(system_prompt=SYSTEM_PROMPT)
|
|
30
|
+
|
|
31
|
+
# Use provided shared state or create new one
|
|
32
|
+
if agent_shared_state is None:
|
|
33
|
+
agent_shared_state = AgentSharedState()
|
|
34
|
+
|
|
35
|
+
tools: list = []
|
|
36
|
+
|
|
37
|
+
agents: list = []
|
|
38
|
+
|
|
39
|
+
return {{project_name_pascal}}Agent(
|
|
40
|
+
name=NAME,
|
|
41
|
+
description=DESCRIPTION,
|
|
42
|
+
chat_model=model,
|
|
43
|
+
tools=tools,
|
|
44
|
+
agents=agents,
|
|
45
|
+
memory=None,
|
|
46
|
+
state=agent_shared_state,
|
|
47
|
+
configuration=agent_configuration,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class {{project_name_pascal}}Agent(Agent):
|
|
52
|
+
pass
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
naas_abi_cli/cli/utils/Copier.py
CHANGED
|
@@ -2,6 +2,20 @@ import os
|
|
|
2
2
|
import shutil
|
|
3
3
|
|
|
4
4
|
import jinja2
|
|
5
|
+
import rich
|
|
6
|
+
from jinja2 import Environment, meta
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ValueProvider(dict):
|
|
10
|
+
def collect_values(self, template_string: str) -> dict:
|
|
11
|
+
env = Environment() # add your filters/tests if you use them
|
|
12
|
+
ast = env.parse(template_string)
|
|
13
|
+
needed = meta.find_undeclared_variables(ast)
|
|
14
|
+
|
|
15
|
+
for name in sorted(needed):
|
|
16
|
+
if name in self:
|
|
17
|
+
continue
|
|
18
|
+
self[name] = rich.prompt.Prompt.ask(f"Enter value for '{name}'")
|
|
5
19
|
|
|
6
20
|
|
|
7
21
|
class Copier:
|
|
@@ -14,21 +28,24 @@ class Copier:
|
|
|
14
28
|
self.templates_path = os.path.abspath(templates_path)
|
|
15
29
|
self.destination_path = os.path.abspath(destination_path)
|
|
16
30
|
|
|
17
|
-
def
|
|
18
|
-
self, template_path: str, values:
|
|
31
|
+
def _template_file_to_file(
|
|
32
|
+
self, template_path: str, values: ValueProvider, destination_path: str
|
|
19
33
|
) -> None:
|
|
20
|
-
destination_path = self.
|
|
34
|
+
destination_path = self._template_string(destination_path, values)
|
|
21
35
|
with open(destination_path, "w", encoding="utf-8") as file:
|
|
22
|
-
file.write(self.
|
|
36
|
+
file.write(self._template_file(template_path, values))
|
|
23
37
|
|
|
24
|
-
def
|
|
38
|
+
def _template_file(self, template_path: str, values: ValueProvider) -> str:
|
|
25
39
|
with open(template_path, "r", encoding="utf-8") as file:
|
|
26
|
-
return self.
|
|
40
|
+
return self._template_string(file.read(), values)
|
|
27
41
|
|
|
28
|
-
def
|
|
42
|
+
def _template_string(self, template_string: str, values: ValueProvider) -> str:
|
|
43
|
+
values.collect_values(template_string)
|
|
29
44
|
return jinja2.Template(template_string).render(values)
|
|
30
45
|
|
|
31
46
|
def copy(self, values: dict, templates_path: str | None = None):
|
|
47
|
+
vp = ValueProvider(values)
|
|
48
|
+
|
|
32
49
|
if templates_path is None:
|
|
33
50
|
templates_path = self.templates_path
|
|
34
51
|
elif not os.path.isabs(templates_path):
|
|
@@ -45,22 +62,23 @@ class Copier:
|
|
|
45
62
|
|
|
46
63
|
for file in os.listdir(templates_path):
|
|
47
64
|
if os.path.isfile(os.path.join(templates_path, file)):
|
|
48
|
-
if "config" in file and file.endswith(".yaml"):
|
|
65
|
+
if False and "config" in file and file.endswith(".yaml"):
|
|
49
66
|
shutil.copy(
|
|
50
67
|
os.path.join(templates_path, file),
|
|
51
|
-
self.
|
|
68
|
+
self._template_string(os.path.join(target_path, file), vp),
|
|
52
69
|
)
|
|
53
70
|
else:
|
|
54
|
-
self.
|
|
71
|
+
self._template_file_to_file(
|
|
55
72
|
os.path.join(templates_path, file),
|
|
56
|
-
|
|
73
|
+
vp,
|
|
57
74
|
os.path.join(target_path, file),
|
|
58
75
|
)
|
|
59
76
|
elif os.path.isdir(os.path.join(templates_path, file)):
|
|
60
77
|
os.makedirs(
|
|
61
|
-
self.
|
|
78
|
+
self._template_string(os.path.join(target_path, file), vp),
|
|
62
79
|
exist_ok=True,
|
|
63
80
|
)
|
|
64
81
|
self.copy(values, os.path.join(templates_path, file))
|
|
65
82
|
else:
|
|
66
83
|
print(f"Skipping {file}")
|
|
84
|
+
print(f"Skipping {file}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: naas-abi-cli
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: Abi cli allowing you to build your AI system.
|
|
5
5
|
Project-URL: Homepage, https://github.com/jupyter-naas/abi
|
|
6
6
|
Project-URL: Repository, https://github.com/jupyter-naas/abi/tree/main/libs/naas-abi-cli
|
|
@@ -11,16 +11,22 @@ naas_abi_cli/cli/secret.py,sha256=u_yUZgVEcns-CM-qsIIZUHX8j8T6aioJYluqSQhnXFE,24
|
|
|
11
11
|
naas_abi_cli/cli/new/__init__.py,sha256=i-lOPJh8DL729CFhZyuXZibsaswsqPj5e7u_N68xXeM,156
|
|
12
12
|
naas_abi_cli/cli/new/module.py,sha256=e4gXnE7iQ4aCJpAU-0iMrHQ11T-PS11UDuifBLwyYFs,183
|
|
13
13
|
naas_abi_cli/cli/new/new.py,sha256=sfNmeoNZLGhjKRKSHuwEl1vtuxWR_SII0qOo9BVoEwY,55
|
|
14
|
-
naas_abi_cli/cli/new/project.py,sha256=
|
|
14
|
+
naas_abi_cli/cli/new/project.py,sha256=rqM7peahVhqdteo8HjWm-ZQW30LfVYYPfuZV2Y2tR2g,1966
|
|
15
15
|
naas_abi_cli/cli/new/templates/project/.gitignore,sha256=UGpJjKfZf8Gv1AD8aCgx0EDGsY_7j4viVinCdxDZMhQ,18
|
|
16
16
|
naas_abi_cli/cli/new/templates/project/Dockerfile,sha256=1qKIDdqwc_JYJE9ROHFqsq3RPyYpkfqjZHKACCMR4JE,147
|
|
17
17
|
naas_abi_cli/cli/new/templates/project/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
18
|
naas_abi_cli/cli/new/templates/project/pyproject.toml,sha256=LQfOYOCSYvI6BP5TGYoWV4dlfSAUVFBZJkXqf-em48o,165
|
|
19
19
|
naas_abi_cli/cli/new/templates/project/.github/workflows/release.yaml,sha256=7uV4SE20zvAfJKr1caKLbHIC3eyBmS-LOwjkKe6plhI,596
|
|
20
|
-
naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/__init__.py,sha256=
|
|
21
|
-
naas_abi_cli/cli/
|
|
22
|
-
naas_abi_cli/cli/new/templates/project/
|
|
23
|
-
naas_abi_cli
|
|
24
|
-
naas_abi_cli
|
|
25
|
-
naas_abi_cli
|
|
26
|
-
naas_abi_cli
|
|
20
|
+
naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/__init__.py,sha256=RrPtAs9r4Kf6ZUNkrA2P9BAmQftVZYnid5hZrT7A6wE,912
|
|
21
|
+
naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/agents/Agent.py,sha256=AAbYlAmmp8zC6Tp5WVelvHSMUYYgJCEko4zAhkGUaAg,1328
|
|
22
|
+
naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/agents/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
+
naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/orchestrations/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
+
naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/pipelines/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
+
naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/workflows/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
+
naas_abi_cli/cli/utils/Copier.py,sha256=cYo-5INC0jSrxcBgf2tvhahMr-92j2-BLpSmb6nQ1pc,3269
|
|
27
|
+
naas_abi_cli/cli/new/templates/project/config.prod.yaml,sha256=5aAfS2wSH7WnOm_z1Xxu4SarttPnPno39ES0T3bEVj0,1741
|
|
28
|
+
naas_abi_cli/cli/new/templates/project/config.yaml,sha256=NgjksaCwSJ6iHpGoMFMdcrtguiHUYx-FKPKIiQ8aODI,1474
|
|
29
|
+
naas_abi_cli-1.5.0.dist-info/METADATA,sha256=PBK11Mhqqnq42JkYqRcA4xYQLde_iALyNH5tDYKP4XI,7371
|
|
30
|
+
naas_abi_cli-1.5.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
31
|
+
naas_abi_cli-1.5.0.dist-info/entry_points.txt,sha256=ufNXhYVU3uo5dcZ8e1kdEJv1oh2Vons7LHJPg35cP4w,46
|
|
32
|
+
naas_abi_cli-1.5.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|