naas-abi-core 1.4.2__tar.gz → 1.5.0__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.
- naas_abi_core-1.5.0/=0.9.13 +6 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/CHANGELOG.md +3 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/PKG-INFO +1 -1
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/apps/terminal_agent/main.py +3 -1
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/Agent.py +37 -33
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/IntentAgent.py +28 -9
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/pyproject.toml +1 -1
- naas_abi_core-1.4.2/=0.9.13 +0 -6
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/.gitignore +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/README.md +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/assets/favicon.ico +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/assets/logo.png +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/__init__.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/apps/api/api.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/apps/api/api_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/apps/api/openapi_doc.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/apps/mcp/Dockerfile.mcp +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/apps/mcp/mcp_server.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/apps/mcp/mcp_server_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/apps/terminal_agent/terminal_style.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/Engine.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/EngineProxy.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/Engine_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/IEngine.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/conftest.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_configuration/EngineConfiguration.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_configuration/EngineConfiguration_Deploy.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_configuration/EngineConfiguration_GenericLoader.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_configuration/EngineConfiguration_ObjectStorageService.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_configuration/EngineConfiguration_ObjectStorageService_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_configuration/EngineConfiguration_SecretService.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_configuration/EngineConfiguration_SecretService_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_configuration/EngineConfiguration_TripleStoreService.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_configuration/EngineConfiguration_TripleStoreService_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_configuration/EngineConfiguration_VectorStoreService.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_configuration/EngineConfiguration_VectorStoreService_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_configuration/EngineConfiguration_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_configuration/utils/PydanticModelValidator.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_loaders/EngineModuleLoader.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_loaders/EngineOntologyLoader.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/engine/engine_loaders/EngineServiceLoader.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/integration/__init__.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/integration/integration.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/models/Model.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/models/OpenRouter.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/models/OpenRouter_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/module/Module.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/module/ModuleAgentLoader.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/module/ModuleUtils.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/modules/templatablesparqlquery/README.md +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/modules/templatablesparqlquery/__init__.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/modules/templatablesparqlquery/ontologies/TemplatableSparqlQueryOntology.ttl +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/modules/templatablesparqlquery/workflows/GenericWorkflow.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/modules/templatablesparqlquery/workflows/TemplatableSparqlQueryLoader.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/pipeline/__init__.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/pipeline/pipeline.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/__init__.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/AgentMemory_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/Agent_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/IntentAgent_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/beta/Embeddings.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/beta/IntentMapper.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/beta/LocalModel.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/beta/VectorStore.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/test_agent_memory.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/test_postgres_integration.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/cache/CacheFactory.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/cache/CachePort.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/cache/CacheService.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/cache/CacheService_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/cache/adapters/secondary/CacheFSAdapter.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/object_storage/ObjectStorageFactory.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/object_storage/ObjectStoragePort.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/object_storage/ObjectStorageService.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/object_storage/adapters/secondary/ObjectStorageSecondaryAdapterFS.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/object_storage/adapters/secondary/ObjectStorageSecondaryAdapterNaas.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/object_storage/adapters/secondary/ObjectStorageSecondaryAdapterS3.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/ontology/OntologyPorts.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/ontology/OntologyService.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/ontology/adaptors/secondary/OntologyService_SecondaryAdaptor_NERPort.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/secret/Secret.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/secret/SecretPorts.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/secret/Secret_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/secret/adaptors/secondary/Base64Secret.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/secret/adaptors/secondary/Base64Secret_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/secret/adaptors/secondary/NaasSecret.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/secret/adaptors/secondary/NaasSecret_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/secret/adaptors/secondary/dotenv_secret_secondaryadaptor.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/triple_store/TripleStoreFactory.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/triple_store/TripleStorePorts.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/triple_store/TripleStoreService.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/triple_store/adaptors/secondary/AWSNeptune.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/triple_store/adaptors/secondary/AWSNeptune_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/triple_store/adaptors/secondary/Oxigraph.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/triple_store/adaptors/secondary/Oxigraph_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/triple_store/adaptors/secondary/TripleStoreService__SecondaryAdaptor__Filesystem.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/triple_store/adaptors/secondary/TripleStoreService__SecondaryAdaptor__ObjectStorage.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/triple_store/adaptors/secondary/base/TripleStoreService__SecondaryAdaptor__FileBase.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/vector_store/IVectorStorePort.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/vector_store/IVectorStorePort_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/vector_store/VectorStoreFactory.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/vector_store/VectorStoreService.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/vector_store/VectorStoreService_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/vector_store/__init__.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/vector_store/adapters/QdrantAdapter.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/vector_store/adapters/QdrantAdapter_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/tests/test_services_imports.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/Expose.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/Graph.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/JSON.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/LazyLoader.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/Logger.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/OntologyReasoner.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/OntologyYaml.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/SPARQL.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/Storage.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/StorageUtils.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/String.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/Workers.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/__init__.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/onto2py/README.md +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/onto2py/__init__.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/onto2py/__main__.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/onto2py/onto2py.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/onto2py/tests/ttl2py_test.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/workflow/__init__.py +0 -0
- {naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/workflow/workflow.py +0 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Collecting uv
|
|
2
|
+
Downloading uv-0.9.25-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (11 kB)
|
|
3
|
+
Downloading uv-0.9.25-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.3 MB)
|
|
4
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 22.3/22.3 MB 241.0 MB/s 0:00:00
|
|
5
|
+
Installing collected packages: uv
|
|
6
|
+
Successfully installed uv-0.9.25
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: naas-abi-core
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: Abi framework 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-core
|
|
@@ -182,7 +182,9 @@ def on_ai_message(message: Any, agent_name: str) -> None:
|
|
|
182
182
|
print("\r" + " " * 15 + "\r", end="", flush=True)
|
|
183
183
|
|
|
184
184
|
from rich.markdown import Markdown
|
|
185
|
-
|
|
185
|
+
if not isinstance(message.content, str):
|
|
186
|
+
message.content = str(message.content)
|
|
187
|
+
|
|
186
188
|
# Filter out think tags and their content
|
|
187
189
|
think_content = re.findall(r"<think>.*?</think>", message.content, flags=re.DOTALL)
|
|
188
190
|
|
|
@@ -182,6 +182,9 @@ class AgentSharedState:
|
|
|
182
182
|
def set_requesting_help(self, requesting_help: bool):
|
|
183
183
|
self._requesting_help = requesting_help
|
|
184
184
|
|
|
185
|
+
class ABIAgentState(MessagesState):
|
|
186
|
+
system_prompt: str = Field(default="")
|
|
187
|
+
|
|
185
188
|
|
|
186
189
|
@dataclass
|
|
187
190
|
class Event:
|
|
@@ -219,10 +222,13 @@ class AgentConfiguration:
|
|
|
219
222
|
on_ai_message: Callable[[AnyMessage, str], None] = field(
|
|
220
223
|
default_factory=lambda: lambda _, __: None
|
|
221
224
|
)
|
|
222
|
-
system_prompt: str = field(
|
|
225
|
+
system_prompt: str | Callable[[list[AnyMessage]], str] = field(
|
|
223
226
|
default="You are a helpful assistant. If a tool you used did not return the result you wanted, look for another tool that might be able to help you. If you don't find a suitable tool. Just output 'I DONT KNOW'"
|
|
224
227
|
)
|
|
225
228
|
|
|
229
|
+
def get_system_prompt(self, messages: list[AnyMessage]) -> str:
|
|
230
|
+
return self.system_prompt(messages) if callable(self.system_prompt) else self.system_prompt
|
|
231
|
+
|
|
226
232
|
|
|
227
233
|
class CompletionQuery(BaseModel):
|
|
228
234
|
prompt: str = Field(..., description="The prompt to send to the agent")
|
|
@@ -244,7 +250,6 @@ class Agent(Expose):
|
|
|
244
250
|
Attributes:
|
|
245
251
|
_name (str): Unique identifier for the agent
|
|
246
252
|
_description (str): Human-readable description of the agent's purpose
|
|
247
|
-
_system_prompt (str): System prompt that defines the agent's behavior
|
|
248
253
|
_chat_model (BaseChatModel): The underlying language model with tool binding
|
|
249
254
|
_chat_model_with_tools (Runnable): Language model configured with available tools
|
|
250
255
|
_tools (list[Union[Tool, Agent]]): Original list of provided tools and agents
|
|
@@ -262,7 +267,6 @@ class Agent(Expose):
|
|
|
262
267
|
|
|
263
268
|
_name: str
|
|
264
269
|
_description: str
|
|
265
|
-
_system_prompt: str
|
|
266
270
|
|
|
267
271
|
_chat_model: BaseChatModel
|
|
268
272
|
_chat_model_with_tools: Runnable[
|
|
@@ -338,7 +342,6 @@ class Agent(Expose):
|
|
|
338
342
|
logger.debug(f"Initializing agent: {name}")
|
|
339
343
|
self._name = name
|
|
340
344
|
self._description = description
|
|
341
|
-
self._system_prompt = configuration.system_prompt
|
|
342
345
|
self._state = state
|
|
343
346
|
self._original_tools = tools
|
|
344
347
|
self._original_agents = agents
|
|
@@ -613,13 +616,6 @@ class Agent(Expose):
|
|
|
613
616
|
tools.append(read_makefile)
|
|
614
617
|
return tools
|
|
615
618
|
|
|
616
|
-
@property
|
|
617
|
-
def system_prompt(self) -> str:
|
|
618
|
-
return self._system_prompt
|
|
619
|
-
|
|
620
|
-
def set_system_prompt(self, system_prompt: str):
|
|
621
|
-
self._system_prompt = system_prompt
|
|
622
|
-
|
|
623
619
|
@property
|
|
624
620
|
def structured_tools(self) -> list[Tool | BaseTool]:
|
|
625
621
|
return self._structured_tools
|
|
@@ -688,11 +684,18 @@ class Agent(Expose):
|
|
|
688
684
|
def as_tools(self, parent_graph: bool = False) -> list[BaseTool]:
|
|
689
685
|
return [make_handoff_tool(agent=self, parent_graph=parent_graph)]
|
|
690
686
|
|
|
687
|
+
def render_system_prompt(self, state: ABIAgentState) -> Command:
|
|
688
|
+
system_prompt = self._configuration.get_system_prompt(state["messages"])
|
|
689
|
+
return Command(update={"system_prompt": system_prompt})
|
|
690
|
+
|
|
691
691
|
def build_graph(self, patcher: Optional[Callable] = None):
|
|
692
|
-
graph = StateGraph(
|
|
692
|
+
graph = StateGraph(ABIAgentState)
|
|
693
|
+
|
|
694
|
+
graph.add_node(self.render_system_prompt)
|
|
695
|
+
graph.add_edge(START, "render_system_prompt")
|
|
693
696
|
|
|
694
697
|
graph.add_node(self.current_active_agent)
|
|
695
|
-
graph.add_edge(
|
|
698
|
+
graph.add_edge("render_system_prompt", "current_active_agent")
|
|
696
699
|
|
|
697
700
|
graph.add_node(self.continue_conversation)
|
|
698
701
|
|
|
@@ -710,11 +713,11 @@ class Agent(Expose):
|
|
|
710
713
|
|
|
711
714
|
self.graph = graph.compile(checkpointer=self._checkpointer)
|
|
712
715
|
|
|
713
|
-
def get_last_human_message(self, state:
|
|
716
|
+
def get_last_human_message(self, state: ABIAgentState) -> Any | None:
|
|
714
717
|
"""Get the appropriate human message based on AI message context.
|
|
715
718
|
|
|
716
719
|
Args:
|
|
717
|
-
state (
|
|
720
|
+
state (ABIAgentState): Current conversation state
|
|
718
721
|
|
|
719
722
|
Returns:
|
|
720
723
|
Any | None: The relevant human message
|
|
@@ -743,11 +746,11 @@ class Agent(Expose):
|
|
|
743
746
|
state["messages"][::-1], lambda m: isinstance(m, HumanMessage)
|
|
744
747
|
)
|
|
745
748
|
|
|
746
|
-
def current_active_agent(self, state:
|
|
749
|
+
def current_active_agent(self, state: ABIAgentState) -> Command:
|
|
747
750
|
"""Goto the current active agent.
|
|
748
751
|
|
|
749
752
|
Args:
|
|
750
|
-
state (
|
|
753
|
+
state (ABIAgentState): Current conversation state
|
|
751
754
|
|
|
752
755
|
Returns:
|
|
753
756
|
Command: Command to goto the current active agent
|
|
@@ -804,9 +807,10 @@ class Agent(Expose):
|
|
|
804
807
|
|
|
805
808
|
# self._state.set_current_active_agent(self.name)
|
|
806
809
|
logger.debug(f"💬 Starting chatting with agent '{self.name}'")
|
|
810
|
+
updated_system_prompt = state["system_prompt"]
|
|
807
811
|
if (
|
|
808
812
|
self.state.supervisor_agent != self.name
|
|
809
|
-
and "SUPERVISOR SYSTEM PROMPT" not in
|
|
813
|
+
and "SUPERVISOR SYSTEM PROMPT" not in state["system_prompt"]
|
|
810
814
|
):
|
|
811
815
|
# This agent is a subagent with a supervisor
|
|
812
816
|
subagent_prompt = f"""
|
|
@@ -836,14 +840,14 @@ Your supervisor will help ensure you operate effectively within your role while
|
|
|
836
840
|
|
|
837
841
|
SUBAGENT SYSTEM PROMPT:
|
|
838
842
|
|
|
839
|
-
{
|
|
843
|
+
{state["system_prompt"]}
|
|
840
844
|
"""
|
|
841
|
-
|
|
845
|
+
updated_system_prompt = subagent_prompt
|
|
842
846
|
|
|
843
847
|
if (
|
|
844
848
|
self.state.supervisor_agent == self.name
|
|
845
849
|
and os.getenv("ENV") == "dev"
|
|
846
|
-
and "DEVELOPPER SYSTEM PROMPT" not in
|
|
850
|
+
and "DEVELOPPER SYSTEM PROMPT" not in state["system_prompt"]
|
|
847
851
|
):
|
|
848
852
|
dev_prompt = f"""
|
|
849
853
|
DEVELOPPER SYSTEM PROMPT:
|
|
@@ -854,23 +858,23 @@ For any questions/commands related to the project, use tool: `read_makefile` to
|
|
|
854
858
|
|
|
855
859
|
AGENT SYSTEM PROMPT:
|
|
856
860
|
|
|
857
|
-
{
|
|
861
|
+
{state["system_prompt"]}
|
|
858
862
|
"""
|
|
859
863
|
|
|
860
|
-
|
|
864
|
+
updated_system_prompt = dev_prompt
|
|
861
865
|
|
|
862
|
-
if "CURRENT_DATE" not in
|
|
866
|
+
if "CURRENT_DATE" not in state["system_prompt"]:
|
|
863
867
|
from datetime import datetime
|
|
864
868
|
|
|
865
869
|
current_date_str = f"CURRENT_DATE: The current date is {datetime.now().strftime('%Y-%m-%d')}\n"
|
|
866
|
-
self._system_prompt = self._system_prompt + "\n" + current_date_str
|
|
867
|
-
|
|
868
|
-
return Command(goto="current_active_agent")
|
|
870
|
+
#self._system_prompt = self._system_prompt + "\n" + current_date_str
|
|
871
|
+
updated_system_prompt = updated_system_prompt + "\n" + current_date_str
|
|
872
|
+
return Command(goto="current_active_agent", update={"system_prompt": updated_system_prompt})
|
|
869
873
|
|
|
870
874
|
# logger.debug(f"💬 System prompt: {self._system_prompt}")
|
|
871
|
-
return Command(goto="continue_conversation")
|
|
875
|
+
return Command(goto="continue_conversation", update={"system_prompt": updated_system_prompt})
|
|
872
876
|
|
|
873
|
-
def continue_conversation(self, state:
|
|
877
|
+
def continue_conversation(self, state: ABIAgentState) -> Command:
|
|
874
878
|
return Command(goto="call_model")
|
|
875
879
|
|
|
876
880
|
def handle_openai_response_v1(self, response: BaseMessage) -> Command:
|
|
@@ -935,16 +939,16 @@ AGENT SYSTEM PROMPT:
|
|
|
935
939
|
|
|
936
940
|
def call_model(
|
|
937
941
|
self,
|
|
938
|
-
state:
|
|
942
|
+
state: ABIAgentState,
|
|
939
943
|
) -> Command[Literal["call_tools", "__end__"]]:
|
|
940
944
|
self._state.set_current_active_agent(self.name)
|
|
941
945
|
logger.debug(f"🧠 Calling model on current active agent: {self.name}")
|
|
942
946
|
|
|
943
947
|
# Inserting system prompt before messages.
|
|
944
948
|
messages = state["messages"]
|
|
945
|
-
if
|
|
949
|
+
if state["system_prompt"]:
|
|
946
950
|
messages = [
|
|
947
|
-
SystemMessage(content=
|
|
951
|
+
SystemMessage(content=state["system_prompt"]),
|
|
948
952
|
] + messages
|
|
949
953
|
logger.debug(f"Messages before calling model: {messages}")
|
|
950
954
|
|
|
@@ -975,7 +979,7 @@ AGENT SYSTEM PROMPT:
|
|
|
975
979
|
|
|
976
980
|
return Command(goto="__end__", update={"messages": [response]})
|
|
977
981
|
|
|
978
|
-
def call_tools(self, state:
|
|
982
|
+
def call_tools(self, state: ABIAgentState) -> list[Command]:
|
|
979
983
|
# Check if messages are present in the state.
|
|
980
984
|
if (
|
|
981
985
|
"messages" not in state
|
|
@@ -15,7 +15,7 @@ from naas_abi_core import logger
|
|
|
15
15
|
from naas_abi_core.models.Model import ChatModel
|
|
16
16
|
from spacy.cli import download as spacy_download
|
|
17
17
|
|
|
18
|
-
from .Agent import Agent, AgentConfiguration, AgentSharedState, create_checkpointer
|
|
18
|
+
from .Agent import Agent, AgentConfiguration, AgentSharedState, create_checkpointer, ABIAgentState
|
|
19
19
|
from .beta.IntentMapper import Intent, IntentMapper, IntentScope, IntentType
|
|
20
20
|
|
|
21
21
|
_nlp = None
|
|
@@ -394,7 +394,7 @@ DEV_INTENTS: list = [
|
|
|
394
394
|
]
|
|
395
395
|
|
|
396
396
|
|
|
397
|
-
class IntentState(
|
|
397
|
+
class IntentState(ABIAgentState):
|
|
398
398
|
"""State class for intent-based conversations.
|
|
399
399
|
|
|
400
400
|
Extends MessagesState to include intent mapping information that tracks
|
|
@@ -475,7 +475,24 @@ class IntentAgent(Agent):
|
|
|
475
475
|
threshold_neighbor (float, optional): Maximum score difference for similar intents.
|
|
476
476
|
Defaults to 0.05.
|
|
477
477
|
"""
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
@tool(return_direct=True)
|
|
481
|
+
def list_available_agents() -> str:
|
|
482
|
+
"""Displays a formatted list of all available agents."""
|
|
483
|
+
return "\n".join([agent.name for agent in self._agents])
|
|
484
|
+
|
|
485
|
+
tools.append(list_available_agents)
|
|
486
|
+
|
|
478
487
|
# Add default intents while avoiding duplicates
|
|
488
|
+
intents.append(
|
|
489
|
+
Intent(
|
|
490
|
+
intent_value="agents",
|
|
491
|
+
intent_type=IntentType.TOOL,
|
|
492
|
+
intent_target="list_available_agents",
|
|
493
|
+
)
|
|
494
|
+
)
|
|
495
|
+
|
|
479
496
|
intent_values = {
|
|
480
497
|
(intent.intent_value, intent.intent_type, intent.intent_target)
|
|
481
498
|
for intent in intents
|
|
@@ -539,8 +556,11 @@ class IntentAgent(Agent):
|
|
|
539
556
|
"""
|
|
540
557
|
graph = StateGraph(IntentState)
|
|
541
558
|
|
|
559
|
+
graph.add_node(self.render_system_prompt)
|
|
560
|
+
graph.add_edge(START, "render_system_prompt")
|
|
561
|
+
|
|
542
562
|
graph.add_node(self.current_active_agent)
|
|
543
|
-
graph.add_edge(
|
|
563
|
+
graph.add_edge("render_system_prompt", "current_active_agent")
|
|
544
564
|
|
|
545
565
|
graph.add_node(self.continue_conversation)
|
|
546
566
|
|
|
@@ -1107,8 +1127,8 @@ Last user message: "{last_human_message.content}"
|
|
|
1107
1127
|
for intent in intents:
|
|
1108
1128
|
intents_str += f"-Mapped intent: `{intent['intent'].intent_value}`, tool to call: `{intent['intent'].intent_target}`\n"
|
|
1109
1129
|
|
|
1110
|
-
if "<intents_rules>" not in
|
|
1111
|
-
updated_system_prompt = f"""{
|
|
1130
|
+
if "<intents_rules>" not in state["system_prompt"]:
|
|
1131
|
+
updated_system_prompt = f"""{state["system_prompt"]}
|
|
1112
1132
|
|
|
1113
1133
|
<intents_rules>
|
|
1114
1134
|
Everytime a user is sending a message, a system is trying to map the prompt/message to an intent or a list of intents using a vector search.
|
|
@@ -1131,12 +1151,11 @@ If you endup with a single intent which is of type TOOL, you must call this tool
|
|
|
1131
1151
|
return f"{match.group(1)}\n{intents_str}\n{match.group(3)}"
|
|
1132
1152
|
|
|
1133
1153
|
updated_system_prompt = re.sub(
|
|
1134
|
-
pattern, replace,
|
|
1154
|
+
pattern, replace, state["system_prompt"], flags=re.DOTALL
|
|
1135
1155
|
)
|
|
1136
1156
|
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
logger.debug(f"Injected in system prompt: {self._system_prompt}")
|
|
1157
|
+
logger.debug(f"Injected in system prompt: {updated_system_prompt}")
|
|
1158
|
+
return Command(update={"system_prompt": updated_system_prompt})
|
|
1140
1159
|
|
|
1141
1160
|
def duplicate(
|
|
1142
1161
|
self,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "naas-abi-core"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.5.0"
|
|
4
4
|
description = "Abi framework allowing you to build your AI system."
|
|
5
5
|
authors = [{ name = "Maxime Jublou", email = "maxime@naas.ai" },{ name = "Florent Ravenel", email = "florent@naas.ai" }, { name = "Jeremy Ravenel", email = "jeremy@naas.ai" }]
|
|
6
6
|
requires-python = ">=3.10,<4"
|
naas_abi_core-1.4.2/=0.9.13
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
Collecting uv
|
|
2
|
-
Downloading uv-0.9.22-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (11 kB)
|
|
3
|
-
Downloading uv-0.9.22-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.2 MB)
|
|
4
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 22.2/22.2 MB 161.1 MB/s 0:00:00
|
|
5
|
-
Installing collected packages: uv
|
|
6
|
-
Successfully installed uv-0.9.22
|
|
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
|
{naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/apps/terminal_agent/terminal_style.py
RENAMED
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/modules/templatablesparqlquery/README.md
RENAMED
|
File without changes
|
{naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/modules/templatablesparqlquery/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/AgentMemory_test.py
RENAMED
|
File without changes
|
|
File without changes
|
{naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/IntentAgent_test.py
RENAMED
|
File without changes
|
|
File without changes
|
{naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/beta/IntentMapper.py
RENAMED
|
File without changes
|
|
File without changes
|
{naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/beta/VectorStore.py
RENAMED
|
File without changes
|
{naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/agent/test_agent_memory.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/cache/CacheService_test.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/ontology/OntologyPorts.py
RENAMED
|
File without changes
|
{naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/ontology/OntologyService.py
RENAMED
|
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
|
{naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/triple_store/TripleStorePorts.py
RENAMED
|
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
|
{naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/services/vector_store/IVectorStorePort.py
RENAMED
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
{naas_abi_core-1.4.2 → naas_abi_core-1.5.0}/naas_abi_core/utils/onto2py/tests/ttl2py_test.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|