naas-abi-cli 1.4.4__py3-none-any.whl → 1.6.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/chat.py CHANGED
@@ -1,15 +1,18 @@
1
1
  import click
2
-
3
2
  from naas_abi_core import logger
4
3
 
5
4
 
6
5
  @click.command("chat")
7
- @click.argument("module-name", type=str, required=True, default="naas_abi")
8
- @click.argument("agent-name", type=str, required=True, default="AbiAgent")
9
- def chat(module_name: str, agent_name: str):
6
+ @click.argument("module-name", type=str, default=None)
7
+ @click.argument("agent-name", type=str, default=None)
8
+ def chat(module_name: str | None, agent_name: str | None):
10
9
  from naas_abi_core.engine.Engine import Engine
11
10
 
12
11
  engine = Engine()
12
+
13
+ if module_name is None and agent_name is None:
14
+ module_name, agent_name = engine.configuration.default_agent.split(" ")
15
+
13
16
  engine.load(module_names=[module_name])
14
17
 
15
18
  from naas_abi_core.apps.terminal_agent.main import run_agent
@@ -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,70 @@
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
+ # Comment default_agent to talk to naas_abi AbiAgent by default
42
+ default_agent: "{{ project_name_snake }} {{project_name_pascal}}Agent"
43
+
44
+ {% raw %}
45
+ services:
46
+ secret:
47
+ secret_adapters:
48
+ - adapter: "naas"
49
+ config:
50
+ naas_api_key: "{{ secret.NAAS_API_KEY }}"
51
+ naas_api_url: "https://api.naas.ai"
52
+ object_storage:
53
+ object_storage_adapter:
54
+ adapter: "naas"
55
+ config:
56
+ naas_api_key: "{{ secret.NAAS_API_KEY }}"
57
+ workspace_id: "{{ secret.NAAS_WORKSPACE_ID }}"
58
+ storage_name: "{{ secret.NAAS_STORAGE_NAME }}"
59
+ base_prefix: "datastore"
60
+ triple_store:
61
+ triple_store_adapter:
62
+ adapter: "fs"
63
+ config:
64
+ store_path: "storage/triplestore"
65
+ vector_store:
66
+ vector_store_adapter:
67
+ adapter: "qdrant"
68
+ config: {}
69
+
70
+ {% endraw %}
@@ -1,13 +1,13 @@
1
1
  deploy:
2
- workspace_id: "your_workspace_id"
3
- space_name: "your_project_name-abi-api"
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,14 @@ 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
38
+
39
+ # Comment default_agent to talk to naas_abi AbiAgent by default
40
+ default_agent: "{{ project_name_snake }} {{project_name_pascal}}Agent"
35
41
 
42
+ {% raw %}
36
43
  services:
37
44
  secret:
38
45
  secret_adapters:
@@ -52,3 +59,4 @@ services:
52
59
  vector_store_adapter:
53
60
  adapter: "qdrant"
54
61
  config: {}
62
+ {% endraw %}
@@ -6,3 +6,9 @@ readme = "README.md"
6
6
  requires-python = ">=3.12"
7
7
  dependencies = [
8
8
  ]
9
+
10
+
11
+ # [tool.uv.sources]
12
+ # naas-abi = { path = ".abi/libs/naas-abi", editable = true }
13
+ # naas-abi-core = { path = ".abi/libs/naas-abi-core", editable = true }
14
+ # naas-abi-marketplace = { path = ".abi/libs/naas-abi-marketplace", editable = true }
@@ -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
@@ -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 template_file_to_file(
18
- self, template_path: str, values: dict, destination_path: str
31
+ def _template_file_to_file(
32
+ self, template_path: str, values: ValueProvider, destination_path: str
19
33
  ) -> None:
20
- destination_path = self.template_string(destination_path, values)
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.template_file(template_path, values))
36
+ file.write(self._template_file(template_path, values))
23
37
 
24
- def template_file(self, template_path: str, values: dict) -> str:
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.template_string(file.read(), values)
40
+ return self._template_string(file.read(), values)
27
41
 
28
- def template_string(self, template_string: str, values: dict) -> str:
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.template_string(os.path.join(target_path, file), values),
68
+ self._template_string(os.path.join(target_path, file), vp),
52
69
  )
53
70
  else:
54
- self.template_file_to_file(
71
+ self._template_file_to_file(
55
72
  os.path.join(templates_path, file),
56
- values,
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.template_string(os.path.join(target_path, file), values),
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.4.4
3
+ Version: 1.6.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
@@ -0,0 +1,32 @@
1
+ naas_abi_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ naas_abi_cli/cli/__init__.py,sha256=JJbXMmjdp4TUYkgpVhuTOH5acecBeYT-26xl8jX_Nv0,1340
3
+ naas_abi_cli/cli/agent.py,sha256=fMdbC7HsrOfZSf5zVRHWSmyrejI5mUdRlAT5v5YHXzk,658
4
+ naas_abi_cli/cli/chat.py,sha256=2m8Ezf5mfXf3d8NMBBRQKrJ1w5sS7dfNccKUh6yCnyY,960
5
+ naas_abi_cli/cli/config.py,sha256=CcdDX6HKCP32NjRhbVsCOwLUC9LmaqTm2sv8W5rOt00,1484
6
+ naas_abi_cli/cli/deploy.py,sha256=F4ZO-_ZVfBj93m7WQw5C7qAo3s7D3APl3-ePTpdFTYI,6670
7
+ naas_abi_cli/cli/init.py,sha256=Pcy2-hy-FvpXf3UOKMP6agWyFrCl9z-KP5ktEWltPy0,220
8
+ naas_abi_cli/cli/module.py,sha256=TBl-SpeGUcy1Rrp40Irbt34yQS00xJcNje-OijNE4Hk,717
9
+ naas_abi_cli/cli/run.py,sha256=OLrAs0mtnI0jvyW5Bb_Jd3Sp-bWDMdulCcsPixEq-6s,308
10
+ naas_abi_cli/cli/secret.py,sha256=u_yUZgVEcns-CM-qsIIZUHX8j8T6aioJYluqSQhnXFE,2491
11
+ naas_abi_cli/cli/new/__init__.py,sha256=i-lOPJh8DL729CFhZyuXZibsaswsqPj5e7u_N68xXeM,156
12
+ naas_abi_cli/cli/new/module.py,sha256=e4gXnE7iQ4aCJpAU-0iMrHQ11T-PS11UDuifBLwyYFs,183
13
+ naas_abi_cli/cli/new/new.py,sha256=sfNmeoNZLGhjKRKSHuwEl1vtuxWR_SII0qOo9BVoEwY,55
14
+ naas_abi_cli/cli/new/project.py,sha256=rqM7peahVhqdteo8HjWm-ZQW30LfVYYPfuZV2Y2tR2g,1966
15
+ naas_abi_cli/cli/new/templates/project/.gitignore,sha256=UGpJjKfZf8Gv1AD8aCgx0EDGsY_7j4viVinCdxDZMhQ,18
16
+ naas_abi_cli/cli/new/templates/project/Dockerfile,sha256=1qKIDdqwc_JYJE9ROHFqsq3RPyYpkfqjZHKACCMR4JE,147
17
+ naas_abi_cli/cli/new/templates/project/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ naas_abi_cli/cli/new/templates/project/pyproject.toml,sha256=fvQumyCVeMfVWssZrK6movGnVE4q1Wnh2su3URRl8k8,409
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=RrPtAs9r4Kf6ZUNkrA2P9BAmQftVZYnid5hZrT7A6wE,912
21
+ naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/agents/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ naas_abi_cli/cli/new/templates/project/{{project_name_snake}}/agents/{{project_name_pascal}}Agent.py,sha256=AAbYlAmmp8zC6Tp5WVelvHSMUYYgJCEko4zAhkGUaAg,1328
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=Y57Qzz_yt8tfHbtDqGCSQxOkwnLgF4eoGOWOq66xSA8,1877
28
+ naas_abi_cli/cli/new/templates/project/config.yaml,sha256=iQAAO6N3xO7iszG33vbSAljO11Pcf4KOvW3N-avJrsQ,1610
29
+ naas_abi_cli-1.6.0.dist-info/METADATA,sha256=xZnpMmt1NfX0MZHPAkGpmPWp0bIQm1l2EKUcaGCtmmc,7371
30
+ naas_abi_cli-1.6.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
31
+ naas_abi_cli-1.6.0.dist-info/entry_points.txt,sha256=ufNXhYVU3uo5dcZ8e1kdEJv1oh2Vons7LHJPg35cP4w,46
32
+ naas_abi_cli-1.6.0.dist-info/RECORD,,
@@ -1,26 +0,0 @@
1
- naas_abi_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- naas_abi_cli/cli/__init__.py,sha256=JJbXMmjdp4TUYkgpVhuTOH5acecBeYT-26xl8jX_Nv0,1340
3
- naas_abi_cli/cli/agent.py,sha256=fMdbC7HsrOfZSf5zVRHWSmyrejI5mUdRlAT5v5YHXzk,658
4
- naas_abi_cli/cli/chat.py,sha256=3t_TJ7vqCNs0MIIXOtlSke3nzy4rMSEJtB3P6pKItMo,856
5
- naas_abi_cli/cli/config.py,sha256=CcdDX6HKCP32NjRhbVsCOwLUC9LmaqTm2sv8W5rOt00,1484
6
- naas_abi_cli/cli/deploy.py,sha256=F4ZO-_ZVfBj93m7WQw5C7qAo3s7D3APl3-ePTpdFTYI,6670
7
- naas_abi_cli/cli/init.py,sha256=Pcy2-hy-FvpXf3UOKMP6agWyFrCl9z-KP5ktEWltPy0,220
8
- naas_abi_cli/cli/module.py,sha256=TBl-SpeGUcy1Rrp40Irbt34yQS00xJcNje-OijNE4Hk,717
9
- naas_abi_cli/cli/run.py,sha256=OLrAs0mtnI0jvyW5Bb_Jd3Sp-bWDMdulCcsPixEq-6s,308
10
- naas_abi_cli/cli/secret.py,sha256=u_yUZgVEcns-CM-qsIIZUHX8j8T6aioJYluqSQhnXFE,2491
11
- naas_abi_cli/cli/new/__init__.py,sha256=i-lOPJh8DL729CFhZyuXZibsaswsqPj5e7u_N68xXeM,156
12
- naas_abi_cli/cli/new/module.py,sha256=e4gXnE7iQ4aCJpAU-0iMrHQ11T-PS11UDuifBLwyYFs,183
13
- naas_abi_cli/cli/new/new.py,sha256=sfNmeoNZLGhjKRKSHuwEl1vtuxWR_SII0qOo9BVoEwY,55
14
- naas_abi_cli/cli/new/project.py,sha256=ptYIh9_M-bOr-LEj6hzfKIYVLCaQtKhJXhP5OGKH0TQ,1912
15
- naas_abi_cli/cli/new/templates/project/.gitignore,sha256=UGpJjKfZf8Gv1AD8aCgx0EDGsY_7j4viVinCdxDZMhQ,18
16
- naas_abi_cli/cli/new/templates/project/Dockerfile,sha256=1qKIDdqwc_JYJE9ROHFqsq3RPyYpkfqjZHKACCMR4JE,147
17
- naas_abi_cli/cli/new/templates/project/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- naas_abi_cli/cli/new/templates/project/pyproject.toml,sha256=LQfOYOCSYvI6BP5TGYoWV4dlfSAUVFBZJkXqf-em48o,165
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=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- naas_abi_cli/cli/utils/Copier.py,sha256=YDYY9rxbL0TFB8IHKZc1ZR0w9tMUlX29jhVw4To8OQs,2640
22
- naas_abi_cli/cli/new/templates/project/config.yaml,sha256=XbH96_X2EFowSsM5yl3NjE9NzcwkLgsznx29bNlx0io,1362
23
- naas_abi_cli-1.4.4.dist-info/METADATA,sha256=ttwSxszM9SNQQVXf1t6-9uAoEyHrUfWPZUTO8Vn-Mh8,7371
24
- naas_abi_cli-1.4.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
25
- naas_abi_cli-1.4.4.dist-info/entry_points.txt,sha256=ufNXhYVU3uo5dcZ8e1kdEJv1oh2Vons7LHJPg35cP4w,46
26
- naas_abi_cli-1.4.4.dist-info/RECORD,,