langroid 0.58.2__py3-none-any.whl → 0.59.0b1__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.
- langroid/agent/base.py +39 -17
- langroid/agent/base.py-e +2216 -0
- langroid/agent/callbacks/chainlit.py +2 -1
- langroid/agent/chat_agent.py +73 -55
- langroid/agent/chat_agent.py-e +2086 -0
- langroid/agent/chat_document.py +7 -7
- langroid/agent/chat_document.py-e +513 -0
- langroid/agent/openai_assistant.py +9 -9
- langroid/agent/openai_assistant.py-e +882 -0
- langroid/agent/special/arangodb/arangodb_agent.py +10 -18
- langroid/agent/special/arangodb/arangodb_agent.py-e +648 -0
- langroid/agent/special/arangodb/tools.py +3 -3
- langroid/agent/special/doc_chat_agent.py +16 -14
- langroid/agent/special/lance_rag/critic_agent.py +2 -2
- langroid/agent/special/lance_rag/query_planner_agent.py +4 -4
- langroid/agent/special/lance_tools.py +6 -5
- langroid/agent/special/lance_tools.py-e +61 -0
- langroid/agent/special/neo4j/neo4j_chat_agent.py +3 -7
- langroid/agent/special/neo4j/neo4j_chat_agent.py-e +430 -0
- langroid/agent/special/relevance_extractor_agent.py +1 -1
- langroid/agent/special/sql/sql_chat_agent.py +11 -3
- langroid/agent/task.py +9 -87
- langroid/agent/task.py-e +2418 -0
- langroid/agent/tool_message.py +33 -17
- langroid/agent/tool_message.py-e +400 -0
- langroid/agent/tools/file_tools.py +4 -2
- langroid/agent/tools/file_tools.py-e +234 -0
- langroid/agent/tools/mcp/fastmcp_client.py +19 -6
- langroid/agent/tools/mcp/fastmcp_client.py-e +584 -0
- langroid/agent/tools/orchestration.py +22 -17
- langroid/agent/tools/orchestration.py-e +301 -0
- langroid/agent/tools/recipient_tool.py +3 -3
- langroid/agent/tools/task_tool.py +22 -16
- langroid/agent/tools/task_tool.py-e +249 -0
- langroid/agent/xml_tool_message.py +90 -35
- langroid/agent/xml_tool_message.py-e +392 -0
- langroid/cachedb/base.py +1 -1
- langroid/embedding_models/base.py +2 -2
- langroid/embedding_models/models.py +3 -7
- langroid/embedding_models/models.py-e +563 -0
- langroid/exceptions.py +4 -1
- langroid/language_models/azure_openai.py +2 -2
- langroid/language_models/azure_openai.py-e +134 -0
- langroid/language_models/base.py +6 -4
- langroid/language_models/base.py-e +812 -0
- langroid/language_models/client_cache.py +64 -0
- langroid/language_models/config.py +2 -4
- langroid/language_models/config.py-e +18 -0
- langroid/language_models/model_info.py +9 -1
- langroid/language_models/model_info.py-e +483 -0
- langroid/language_models/openai_gpt.py +119 -20
- langroid/language_models/openai_gpt.py-e +2280 -0
- langroid/language_models/provider_params.py +3 -22
- langroid/language_models/provider_params.py-e +153 -0
- langroid/mytypes.py +11 -4
- langroid/mytypes.py-e +132 -0
- langroid/parsing/code_parser.py +1 -1
- langroid/parsing/file_attachment.py +1 -1
- langroid/parsing/file_attachment.py-e +246 -0
- langroid/parsing/md_parser.py +14 -4
- langroid/parsing/md_parser.py-e +574 -0
- langroid/parsing/parser.py +22 -7
- langroid/parsing/parser.py-e +410 -0
- langroid/parsing/repo_loader.py +3 -1
- langroid/parsing/repo_loader.py-e +812 -0
- langroid/parsing/search.py +1 -1
- langroid/parsing/url_loader.py +17 -51
- langroid/parsing/url_loader.py-e +683 -0
- langroid/parsing/urls.py +5 -4
- langroid/parsing/urls.py-e +279 -0
- langroid/prompts/prompts_config.py +1 -1
- langroid/pydantic_v1/__init__.py +45 -6
- langroid/pydantic_v1/__init__.py-e +36 -0
- langroid/pydantic_v1/main.py +11 -4
- langroid/pydantic_v1/main.py-e +11 -0
- langroid/utils/configuration.py +13 -11
- langroid/utils/configuration.py-e +141 -0
- langroid/utils/constants.py +1 -1
- langroid/utils/constants.py-e +32 -0
- langroid/utils/globals.py +21 -5
- langroid/utils/globals.py-e +49 -0
- langroid/utils/html_logger.py +2 -1
- langroid/utils/html_logger.py-e +825 -0
- langroid/utils/object_registry.py +1 -1
- langroid/utils/object_registry.py-e +66 -0
- langroid/utils/pydantic_utils.py +55 -28
- langroid/utils/pydantic_utils.py-e +602 -0
- langroid/utils/types.py +2 -2
- langroid/utils/types.py-e +113 -0
- langroid/vector_store/base.py +3 -3
- langroid/vector_store/lancedb.py +5 -5
- langroid/vector_store/lancedb.py-e +404 -0
- langroid/vector_store/meilisearch.py +2 -2
- langroid/vector_store/pineconedb.py +4 -4
- langroid/vector_store/pineconedb.py-e +427 -0
- langroid/vector_store/postgres.py +1 -1
- langroid/vector_store/qdrantdb.py +3 -3
- langroid/vector_store/weaviatedb.py +1 -1
- {langroid-0.58.2.dist-info → langroid-0.59.0b1.dist-info}/METADATA +3 -2
- langroid-0.59.0b1.dist-info/RECORD +181 -0
- langroid/agent/special/doc_chat_task.py +0 -0
- langroid/mcp/__init__.py +0 -1
- langroid/mcp/server/__init__.py +0 -1
- langroid-0.58.2.dist-info/RECORD +0 -145
- {langroid-0.58.2.dist-info → langroid-0.59.0b1.dist-info}/WHEEL +0 -0
- {langroid-0.58.2.dist-info → langroid-0.59.0b1.dist-info}/licenses/LICENSE +0 -0
langroid/utils/globals.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
from typing import Any, Dict, Optional, Type, TypeVar
|
1
|
+
from typing import Any, Dict, Optional, Type, TypeVar, cast
|
2
2
|
|
3
|
-
from
|
3
|
+
from pydantic import BaseModel
|
4
|
+
from pydantic.fields import ModelPrivateAttr
|
5
|
+
from pydantic_core import PydanticUndefined
|
4
6
|
|
5
7
|
T = TypeVar("T", bound="GlobalState")
|
6
8
|
|
@@ -18,9 +20,23 @@ class GlobalState(BaseModel):
|
|
18
20
|
Returns:
|
19
21
|
The global instance of the subclass.
|
20
22
|
"""
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
# Get the actual value from ModelPrivateAttr when accessing on class
|
24
|
+
instance_attr = getattr(cls, "_instance", None)
|
25
|
+
actual_instance: Optional["GlobalState"]
|
26
|
+
if isinstance(instance_attr, ModelPrivateAttr):
|
27
|
+
default_value = instance_attr.default
|
28
|
+
if default_value is PydanticUndefined:
|
29
|
+
actual_instance = None
|
30
|
+
else:
|
31
|
+
actual_instance = cast(Optional["GlobalState"], default_value)
|
32
|
+
else:
|
33
|
+
actual_instance = instance_attr
|
34
|
+
|
35
|
+
if actual_instance is None:
|
36
|
+
new_instance = cls()
|
37
|
+
cls._instance = new_instance
|
38
|
+
return new_instance
|
39
|
+
return actual_instance # type: ignore
|
24
40
|
|
25
41
|
@classmethod
|
26
42
|
def set_values(cls: Type[T], **kwargs: Dict[str, Any]) -> None:
|
@@ -0,0 +1,49 @@
|
|
1
|
+
from typing import Any, Dict, Optional, Type, TypeVar
|
2
|
+
|
3
|
+
from pydantic import BaseModel
|
4
|
+
|
5
|
+
T = TypeVar("T", bound="GlobalState")
|
6
|
+
|
7
|
+
|
8
|
+
class GlobalState(BaseModel):
|
9
|
+
"""A base Pydantic model for global states."""
|
10
|
+
|
11
|
+
_instance: Optional["GlobalState"] = None
|
12
|
+
|
13
|
+
@classmethod
|
14
|
+
def get_instance(cls: Type["GlobalState"]) -> "GlobalState":
|
15
|
+
"""
|
16
|
+
Get the global instance of the specific subclass.
|
17
|
+
|
18
|
+
Returns:
|
19
|
+
The global instance of the subclass.
|
20
|
+
"""
|
21
|
+
if cls._instance is None:
|
22
|
+
cls._instance = cls()
|
23
|
+
return cls._instance
|
24
|
+
|
25
|
+
@classmethod
|
26
|
+
def set_values(cls: Type[T], **kwargs: Dict[str, Any]) -> None:
|
27
|
+
"""
|
28
|
+
Set values on the global instance of the specific subclass.
|
29
|
+
|
30
|
+
Args:
|
31
|
+
**kwargs: The fields and their values to set.
|
32
|
+
"""
|
33
|
+
instance = cls.get_instance()
|
34
|
+
for key, value in kwargs.items():
|
35
|
+
setattr(instance, key, value)
|
36
|
+
|
37
|
+
@classmethod
|
38
|
+
def get_value(cls: Type[T], name: str) -> Any:
|
39
|
+
"""
|
40
|
+
Retrieve the value of a specific field from the global instance.
|
41
|
+
|
42
|
+
Args:
|
43
|
+
name (str): The name of the field to retrieve.
|
44
|
+
|
45
|
+
Returns:
|
46
|
+
str: The value of the specified field.
|
47
|
+
"""
|
48
|
+
instance = cls.get_instance()
|
49
|
+
return getattr(instance, name)
|
langroid/utils/html_logger.py
CHANGED