versionhq 1.2.1.17__tar.gz → 1.2.1.19__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.
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/PKG-INFO +1 -1
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/pyproject.toml +1 -1
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/__init__.py +1 -1
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/_utils/process_config.py +1 -1
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/agent/model.py +92 -89
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/agent_network/formation.py +7 -4
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/knowledge/model.py +1 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/storage/rag_storage.py +7 -7
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq.egg-info/PKG-INFO +1 -1
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/agent/agent_test.py +4 -2
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/task/task_test.py +0 -8
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/uv.lock +1 -1
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/.env.sample +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/.github/workflows/deploy_docs.yml +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/.github/workflows/publish.yml +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/.github/workflows/publish_testpypi.yml +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/.github/workflows/run_tests.yml +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/.github/workflows/security_check.yml +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/.gitignore +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/.pre-commit-config.yaml +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/.python-version +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/LICENSE +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/README.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/SECURITY.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/db/preprocess.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/CNAME +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/_logos/favicon.ico +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/_logos/logo192.png +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/core/agent/config.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/core/agent/index.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/core/agent/ref.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/core/agent/task-handling.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/core/agent-network/index.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/core/llm/index.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/core/task/evaluation.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/core/task/index.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/core/task/response-field.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/core/task/task-output.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/core/task-graph/index.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/core/tool.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/index.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/quickstart.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/stylesheets/main.css +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/docs/tags.md +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/mkdocs.yml +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/requirements-dev.txt +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/requirements.txt +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/runtime.txt +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/setup.cfg +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/_utils/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/_utils/i18n.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/_utils/logger.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/_utils/usage_metrics.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/_utils/vars.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/agent/TEMPLATES/Backstory.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/agent/TEMPLATES/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/agent/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/agent/inhouse_agents.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/agent/parser.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/agent/rpm_controller.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/agent_network/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/agent_network/model.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/cli/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/clients/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/clients/customer/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/clients/customer/model.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/clients/product/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/clients/product/model.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/clients/workflow/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/clients/workflow/model.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/knowledge/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/knowledge/_utils.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/knowledge/embedding.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/knowledge/source.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/knowledge/source_docling.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/knowledge/storage.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/llm/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/llm/llm_vars.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/llm/model.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/memory/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/memory/contextual_memory.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/memory/model.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/storage/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/storage/base.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/storage/ltm_sqlite_storage.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/storage/mem0_storage.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/storage/task_output_storage.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/storage/utils.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/task/TEMPLATES/Description.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/task/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/task/evaluate.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/task/formatter.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/task/log_handler.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/task/model.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/task/structured_response.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/task_graph/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/task_graph/colors.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/task_graph/draft.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/task_graph/model.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/tool/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/tool/cache_handler.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/tool/composio_tool.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/tool/composio_tool_vars.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/tool/decorator.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/tool/model.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq/tool/tool_handler.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq.egg-info/SOURCES.txt +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq.egg-info/dependency_links.txt +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq.egg-info/requires.txt +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/src/versionhq.egg-info/top_level.txt +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/agent/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/agent/doc_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/agent_network/Prompts/Demo_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/agent_network/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/agent_network/agent_network_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/cli/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/clients/customer_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/clients/product_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/clients/workflow_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/conftest.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/doc_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/formation_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/knowledge/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/knowledge/knowledge_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/knowledge/mock_report_compressed.pdf +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/llm/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/llm/llm_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/memory/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/memory/memory_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/task/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/task/doc_taskoutput_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/task/doc_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/task/llm_connection_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/task_graph/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/task_graph/doc_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/task_graph/task_graph_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/tool/__init__.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/tool/composio_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/tool/doc_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/tool/tool_test.py +0 -0
- {versionhq-1.2.1.17 → versionhq-1.2.1.19}/tests/usecase_test.py +0 -0
@@ -15,7 +15,7 @@ exclude = ["test*", "__pycache__", "*.egg-info"]
|
|
15
15
|
|
16
16
|
[project]
|
17
17
|
name = "versionhq"
|
18
|
-
version = "1.2.1.
|
18
|
+
version = "1.2.1.19"
|
19
19
|
authors = [{ name = "Kuriko Iwai", email = "kuriko@versi0n.io" }]
|
20
20
|
description = "An agentic orchestration framework for building agent networks that handle task automation."
|
21
21
|
readme = "README.md"
|
@@ -8,7 +8,7 @@ def process_config(values_to_update: Dict[str, Any], model_class: Type[BaseModel
|
|
8
8
|
Refer to the Pydantic model class for field validation.
|
9
9
|
"""
|
10
10
|
|
11
|
-
config = values_to_update.pop("config"
|
11
|
+
config = values_to_update.pop("config") if "config" in values_to_update else {}
|
12
12
|
|
13
13
|
if config:
|
14
14
|
for k, v in config.items():
|
@@ -149,94 +149,6 @@ class Agent(BaseModel):
|
|
149
149
|
return self
|
150
150
|
|
151
151
|
|
152
|
-
def _convert_to_llm_object(self, llm: Any = None) -> LLM:
|
153
|
-
"""
|
154
|
-
Convert the given value to LLM object.
|
155
|
-
When `llm` is dict or self.llm_config is not None, add these values to the LLM object after validating them.
|
156
|
-
"""
|
157
|
-
llm = llm if llm else self.llm if self.llm else DEFAULT_MODEL_NAME
|
158
|
-
|
159
|
-
if not llm:
|
160
|
-
pass
|
161
|
-
|
162
|
-
match llm:
|
163
|
-
case LLM():
|
164
|
-
return self._set_llm_params(llm=llm, config=self.llm_config)
|
165
|
-
|
166
|
-
case str():
|
167
|
-
llm_obj = LLM(model=llm)
|
168
|
-
return self._set_llm_params(llm=llm_obj, config=self.llm_config)
|
169
|
-
|
170
|
-
case dict():
|
171
|
-
model_name = llm.pop("model_name", llm.pop("deployment_name", str(llm)))
|
172
|
-
llm_obj = LLM(model=model_name if model_name else DEFAULT_MODEL_NAME)
|
173
|
-
config = llm.update(self.llm_config) if self.llm_config else llm
|
174
|
-
return self._set_llm_params(llm_obj, config=config)
|
175
|
-
|
176
|
-
case _:
|
177
|
-
model_name = (getattr(self.llm, "model_name") or getattr(self.llm, "deployment_name") or str(self.llm))
|
178
|
-
llm_obj = LLM(model=model_name if model_name else DEFAULT_MODEL_NAME)
|
179
|
-
llm_params = {
|
180
|
-
"max_tokens": (getattr(llm, "max_tokens") or 3000),
|
181
|
-
"timeout": getattr(llm, "timeout", self.max_execution_time),
|
182
|
-
"callbacks": getattr(llm, "callbacks", None),
|
183
|
-
"temperature": getattr(llm, "temperature", None),
|
184
|
-
"logprobs": getattr(llm, "logprobs", None),
|
185
|
-
"api_key": getattr(llm, "api_key", os.environ.get("LITELLM_API_KEY", None)),
|
186
|
-
"base_url": getattr(llm, "base_url", None),
|
187
|
-
}
|
188
|
-
config = llm_params.update(self.llm_config) if self.llm_config else llm_params
|
189
|
-
return self._set_llm_params(llm=llm_obj, config=config)
|
190
|
-
|
191
|
-
|
192
|
-
def _set_llm_params(self, llm: LLM, config: Dict[str, Any] = None) -> LLM:
|
193
|
-
"""
|
194
|
-
Add valid params to the LLM object.
|
195
|
-
"""
|
196
|
-
|
197
|
-
import litellm
|
198
|
-
from versionhq.llm.llm_vars import PARAMS
|
199
|
-
|
200
|
-
valid_config = {k: v for k, v in config.items() if v} if config else {}
|
201
|
-
|
202
|
-
if valid_config:
|
203
|
-
valid_keys = list()
|
204
|
-
try:
|
205
|
-
valid_keys = litellm.get_supported_openai_params(model=llm.model, custom_llm_provider=self.endpoint_provider, request_type="chat_completion")
|
206
|
-
if not valid_keys:
|
207
|
-
valid_keys = PARAMS.get("common")
|
208
|
-
except:
|
209
|
-
valid_keys = PARAMS.get("common")
|
210
|
-
|
211
|
-
valid_keys += PARAMS.get("litellm")
|
212
|
-
|
213
|
-
for key in valid_keys:
|
214
|
-
if key in valid_config and valid_config[key]:
|
215
|
-
val = valid_config[key]
|
216
|
-
if [key == k for k, v in LLM.model_fields.items()]:
|
217
|
-
setattr(llm, key, val)
|
218
|
-
else:
|
219
|
-
llm.other_valid_config.update({ key: val})
|
220
|
-
|
221
|
-
|
222
|
-
llm.timeout = self.max_execution_time if llm.timeout is None else llm.timeout
|
223
|
-
# llm.max_tokens = self.max_tokens if self.max_tokens else llm.max_tokens
|
224
|
-
|
225
|
-
if llm.provider is None:
|
226
|
-
provider_name = llm.model.split("/")[0]
|
227
|
-
valid_provider = provider_name if provider_name in PROVIDERS else None
|
228
|
-
llm.provider = valid_provider
|
229
|
-
|
230
|
-
if self.callbacks:
|
231
|
-
llm.callbacks = self.callbacks
|
232
|
-
llm._set_callbacks(llm.callbacks)
|
233
|
-
|
234
|
-
if self.respect_context_window == False:
|
235
|
-
llm.context_window_size = DEFAULT_CONTEXT_WINDOW_SIZE
|
236
|
-
|
237
|
-
return llm
|
238
|
-
|
239
|
-
|
240
152
|
@model_validator(mode="after")
|
241
153
|
def set_up_tools(self) -> Self:
|
242
154
|
"""
|
@@ -310,7 +222,7 @@ class Agent(BaseModel):
|
|
310
222
|
|
311
223
|
if self.knowledge_sources:
|
312
224
|
try:
|
313
|
-
collection_name = f"{self.role.replace(' ', '_')}"
|
225
|
+
collection_name = f"{self.role.replace(' ', '_')}-{str(self.id)}"
|
314
226
|
knowledge_sources = []
|
315
227
|
docling_fp, txt_fp, json_fp, excel_fp, csv_fp, pdf_fp = [], [], [], [], [], []
|
316
228
|
str_cont = ""
|
@@ -369,6 +281,94 @@ class Agent(BaseModel):
|
|
369
281
|
return self
|
370
282
|
|
371
283
|
|
284
|
+
def _convert_to_llm_object(self, llm: Any = None) -> LLM:
|
285
|
+
"""
|
286
|
+
Convert the given value to LLM object.
|
287
|
+
When `llm` is dict or self.llm_config is not None, add these values to the LLM object after validating them.
|
288
|
+
"""
|
289
|
+
llm = llm if llm else self.llm if self.llm else DEFAULT_MODEL_NAME
|
290
|
+
|
291
|
+
if not llm:
|
292
|
+
pass
|
293
|
+
|
294
|
+
match llm:
|
295
|
+
case LLM():
|
296
|
+
return self._set_llm_params(llm=llm, config=self.llm_config)
|
297
|
+
|
298
|
+
case str():
|
299
|
+
llm_obj = LLM(model=llm)
|
300
|
+
return self._set_llm_params(llm=llm_obj, config=self.llm_config)
|
301
|
+
|
302
|
+
case dict():
|
303
|
+
model_name = llm.pop("model_name", llm.pop("deployment_name", str(llm)))
|
304
|
+
llm_obj = LLM(model=model_name if model_name else DEFAULT_MODEL_NAME)
|
305
|
+
config = llm.update(self.llm_config) if self.llm_config else llm
|
306
|
+
return self._set_llm_params(llm_obj, config=config)
|
307
|
+
|
308
|
+
case _:
|
309
|
+
model_name = (getattr(self.llm, "model_name") or getattr(self.llm, "deployment_name") or str(self.llm))
|
310
|
+
llm_obj = LLM(model=model_name if model_name else DEFAULT_MODEL_NAME)
|
311
|
+
llm_params = {
|
312
|
+
"max_tokens": (getattr(llm, "max_tokens") or 3000),
|
313
|
+
"timeout": getattr(llm, "timeout", self.max_execution_time),
|
314
|
+
"callbacks": getattr(llm, "callbacks", None),
|
315
|
+
"temperature": getattr(llm, "temperature", None),
|
316
|
+
"logprobs": getattr(llm, "logprobs", None),
|
317
|
+
"api_key": getattr(llm, "api_key", os.environ.get("LITELLM_API_KEY", None)),
|
318
|
+
"base_url": getattr(llm, "base_url", None),
|
319
|
+
}
|
320
|
+
config = llm_params.update(self.llm_config) if self.llm_config else llm_params
|
321
|
+
return self._set_llm_params(llm=llm_obj, config=config)
|
322
|
+
|
323
|
+
|
324
|
+
def _set_llm_params(self, llm: LLM, config: Dict[str, Any] = None) -> LLM:
|
325
|
+
"""
|
326
|
+
Add valid params to the LLM object.
|
327
|
+
"""
|
328
|
+
|
329
|
+
import litellm
|
330
|
+
from versionhq.llm.llm_vars import PARAMS
|
331
|
+
|
332
|
+
valid_config = {k: v for k, v in config.items() if v} if config else {}
|
333
|
+
|
334
|
+
if valid_config:
|
335
|
+
valid_keys = list()
|
336
|
+
try:
|
337
|
+
valid_keys = litellm.get_supported_openai_params(model=llm.model, custom_llm_provider=self.endpoint_provider, request_type="chat_completion")
|
338
|
+
if not valid_keys:
|
339
|
+
valid_keys = PARAMS.get("common")
|
340
|
+
except:
|
341
|
+
valid_keys = PARAMS.get("common")
|
342
|
+
|
343
|
+
valid_keys += PARAMS.get("litellm")
|
344
|
+
|
345
|
+
for key in valid_keys:
|
346
|
+
if key in valid_config and valid_config[key]:
|
347
|
+
val = valid_config[key]
|
348
|
+
if [key == k for k, v in LLM.model_fields.items()]:
|
349
|
+
setattr(llm, key, val)
|
350
|
+
else:
|
351
|
+
llm.other_valid_config.update({ key: val})
|
352
|
+
|
353
|
+
|
354
|
+
llm.timeout = self.max_execution_time if llm.timeout is None else llm.timeout
|
355
|
+
# llm.max_tokens = self.max_tokens if self.max_tokens else llm.max_tokens
|
356
|
+
|
357
|
+
if llm.provider is None:
|
358
|
+
provider_name = llm.model.split("/")[0]
|
359
|
+
valid_provider = provider_name if provider_name in PROVIDERS else None
|
360
|
+
llm.provider = valid_provider
|
361
|
+
|
362
|
+
if self.callbacks:
|
363
|
+
llm.callbacks = self.callbacks
|
364
|
+
llm._set_callbacks(llm.callbacks)
|
365
|
+
|
366
|
+
if self.respect_context_window == False:
|
367
|
+
llm.context_window_size = DEFAULT_CONTEXT_WINDOW_SIZE
|
368
|
+
|
369
|
+
return llm
|
370
|
+
|
371
|
+
|
372
372
|
def _update_llm(self, llm: Any = None, llm_config: Optional[Dict[str, Any]] = None) -> Self:
|
373
373
|
"""
|
374
374
|
Update llm and llm_config of the exsiting agent. (Other conditions will remain the same.)
|
@@ -599,3 +599,6 @@ class Agent(BaseModel):
|
|
599
599
|
|
600
600
|
def __repr__(self):
|
601
601
|
return f"Agent(role={self.role}, goal={self.goal}"
|
602
|
+
|
603
|
+
def __str__(self):
|
604
|
+
return super().__str__()
|
@@ -9,6 +9,9 @@ from versionhq.agent_network.model import AgentNetwork, Member, Formation
|
|
9
9
|
from versionhq.agent.inhouse_agents import vhq_formation_planner
|
10
10
|
from versionhq._utils import Logger
|
11
11
|
|
12
|
+
import chromadb
|
13
|
+
chromadb.api.client.SharedSystemClient.clear_system_cache()
|
14
|
+
|
12
15
|
|
13
16
|
def form_agent_network(
|
14
17
|
task: str,
|
@@ -85,7 +88,7 @@ def form_agent_network(
|
|
85
88
|
members = []
|
86
89
|
leader = str(res.pydantic.leader_agent) if res.pydantic else str(res.json_dict["leader_agent"])
|
87
90
|
|
88
|
-
created_agents = [Agent(role=item, goal=item) for item in res.pydantic.agent_roles]
|
91
|
+
created_agents = [Agent(role=str(item), goal=str(item)) for item in res.pydantic.agent_roles]
|
89
92
|
created_tasks = []
|
90
93
|
|
91
94
|
if res.pydantic:
|
@@ -94,7 +97,7 @@ def form_agent_network(
|
|
94
97
|
fields = {}
|
95
98
|
for ob in item:
|
96
99
|
try:
|
97
|
-
field_name = str(ob).lower().
|
100
|
+
field_name = str(ob).lower().split(":")[0].replace(" ", "_")[0: 16]
|
98
101
|
fields[field_name] = (str, Field(default=None))
|
99
102
|
except:
|
100
103
|
pass
|
@@ -108,7 +111,7 @@ def form_agent_network(
|
|
108
111
|
fields = {}
|
109
112
|
for ob in item:
|
110
113
|
try:
|
111
|
-
field_name = str(ob).lower().
|
114
|
+
field_name = str(ob).lower().split(":")[0].replace(" ", "_")[0: 16]
|
112
115
|
fields[field_name] = (str, Field(default=None))
|
113
116
|
except:
|
114
117
|
pass
|
@@ -137,7 +140,7 @@ def form_agent_network(
|
|
137
140
|
member = Member(agent=created_agents[i], is_manager=is_manager, tasks=[created_tasks[i]])
|
138
141
|
members.append(member)
|
139
142
|
|
140
|
-
network_tasks.
|
143
|
+
network_tasks.extend(created_tasks[len(created_agents):len(created_tasks)])
|
141
144
|
|
142
145
|
|
143
146
|
if _formation == Formation.SUPERVISING and not [member for member in members if member.is_manager]:
|
@@ -9,6 +9,7 @@ class Knowledge(BaseModel):
|
|
9
9
|
"""
|
10
10
|
Knowlede class for collection of sources and setup for the vector store to query relevant context.
|
11
11
|
"""
|
12
|
+
|
12
13
|
collection_name: Optional[str] = None
|
13
14
|
sources: List[BaseKnowledgeSource] = Field(default_factory=list)
|
14
15
|
storage: KnowledgeStorage = Field(default_factory=KnowledgeStorage)
|
@@ -129,16 +129,16 @@ class RAGStorage(BaseRAGStorage):
|
|
129
129
|
from chromadb.config import Settings
|
130
130
|
|
131
131
|
self._set_embedder_config()
|
132
|
-
chroma_client = chromadb.PersistentClient(
|
133
|
-
path=self.path if self.path else self.storage_file_name,
|
134
|
-
settings=Settings(allow_reset=self.allow_reset),
|
135
|
-
)
|
136
|
-
self.app = chroma_client
|
137
|
-
|
138
132
|
try:
|
133
|
+
chroma_client = chromadb.PersistentClient(
|
134
|
+
path=self.path if self.path else self.storage_file_name,
|
135
|
+
settings=Settings(allow_reset=self.allow_reset),
|
136
|
+
)
|
137
|
+
self.app = chroma_client
|
139
138
|
self.collection = self.app.get_collection(name=self.type, embedding_function=self.embedder_config)
|
140
139
|
except Exception:
|
141
|
-
|
140
|
+
if self.app:
|
141
|
+
self.collection = self.app.create_collection(name=self.type, embedding_function=self.embedder_config)
|
142
142
|
|
143
143
|
|
144
144
|
def _sanitize_role(self, role: str) -> str:
|
@@ -244,10 +244,12 @@ def test_agent_with_knowledge_sources():
|
|
244
244
|
|
245
245
|
agent = Agent(role="Information Agent", goal="Provide information based on knowledge sources", knowledge_sources=knowledge_sources)
|
246
246
|
|
247
|
-
assert
|
247
|
+
assert f"{agent.role.replace(' ', '_')}" in agent._knowledge.collection_name
|
248
248
|
assert [isinstance(item, StringKnowledgeSource | DoclingSource) for item in agent.knowledge_sources]
|
249
249
|
assert agent._knowledge.embedder_config == agent.embedder_config
|
250
|
-
assert agent._knowledge.storage and agent._knowledge.storage.embedding_function
|
250
|
+
assert agent._knowledge.storage and agent._knowledge.storage.embedding_function
|
251
|
+
assert agent._knowledge.storage.app is not None
|
252
|
+
assert agent._knowledge.storage.collection_name is not None
|
251
253
|
|
252
254
|
task = Task(description="Answer the following question: What is Kuriko's favorite color?")
|
253
255
|
|
@@ -1,19 +1,11 @@
|
|
1
|
-
import sys
|
2
|
-
import threading
|
3
1
|
from unittest.mock import patch
|
4
2
|
from typing import Callable
|
5
3
|
|
6
|
-
from pydantic import BaseModel, Field
|
7
|
-
|
8
4
|
from versionhq.agent.model import Agent, LLM
|
9
5
|
from versionhq.task.model import Task, ResponseField, TaskOutput, TaskExecutionType
|
10
6
|
from versionhq.tool.model import Tool, ToolSet
|
11
7
|
from versionhq.tool.decorator import tool
|
12
8
|
|
13
|
-
sys.setrecursionlimit(2097152)
|
14
|
-
threading.stack_size(134217728)
|
15
|
-
|
16
|
-
|
17
9
|
|
18
10
|
# def test_async_execute_task():
|
19
11
|
# task = Task(description="Return string: 'test'", type=TaskExecutionType.ASYNC)
|
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
|
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
|
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
|
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
|
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
|