langroid 0.9.3__tar.gz → 0.9.5__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.
- {langroid-0.9.3 → langroid-0.9.5}/PKG-INFO +1 -1
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/base.py +25 -2
- {langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/prompt_formatter/hf_formatter.py +16 -19
- {langroid-0.9.3 → langroid-0.9.5}/pyproject.toml +1 -1
- {langroid-0.9.3 → langroid-0.9.5}/LICENSE +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/README.md +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/batch.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/callbacks/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/callbacks/chainlit.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/chat_agent.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/chat_document.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/helpers.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/junk +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/openai_assistant.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/doc_chat_agent.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/lance_rag/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/lance_tools.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/neo4j/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/neo4j/utils/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/neo4j/utils/system_message.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/relevance_extractor_agent.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/retriever_agent.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/sql/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/sql/utils/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/sql/utils/system_message.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/sql/utils/tools.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/table_chat_agent.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/task.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/tool_message.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/tools/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/tools/extract_tool.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/tools/generator_tool.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/tools/google_search_tool.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/tools/metaphor_search_tool.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/tools/note_tool.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/tools/orchestration.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/tools/recipient_tool.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/tools/retrieval_tool.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/tools/rewind_tool.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/tools/run_python_code.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/tools/segment_extract_tool.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent/typed_task.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/agent_config.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/cachedb/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/cachedb/base.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/cachedb/momento_cachedb.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/cachedb/redis_cachedb.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/embedding_models/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/embedding_models/base.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/embedding_models/clustering.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/embedding_models/models.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/embedding_models/protoc/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/embedding_models/protoc/embeddings.proto +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/embedding_models/remote_embeds.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/exceptions.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/.chainlit/config.toml +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/.chainlit/translations/en-US.json +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/azure_openai.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/base.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/config.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/mock_lm.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/openai_gpt.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/prompt_formatter/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/prompt_formatter/base.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/utils.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/mytypes.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/agent_chats.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/code-parsing.md +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/code_parser.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/config.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/document_parser.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/image_text.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/para_sentence_split.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/parse_json.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/parser.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/repo_loader.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/routing.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/search.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/spider.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/table_loader.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/url_loader.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/url_loader_cookies.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/urls.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/utils.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/parsing/web_search.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/prompts/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/prompts/dialog.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/prompts/prompts_config.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/prompts/templates.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/pydantic_v1/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/pydantic_v1/main.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/algorithms/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/algorithms/graph.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/configuration.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/constants.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/docker.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/globals.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/llms/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/llms/strings.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/logging.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/object_registry.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/output/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/output/citations.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/output/printing.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/output/status.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/pandas_utils.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/pydantic_utils.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/system.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/web/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/utils/web/login.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/vector_store/__init__.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/vector_store/base.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/vector_store/chromadb.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/vector_store/lancedb.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/vector_store/meilisearch.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/vector_store/momento.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/vector_store/qdrant_cloud.py +0 -0
- {langroid-0.9.3 → langroid-0.9.5}/langroid/vector_store/qdrantdb.py +0 -0
@@ -45,7 +45,13 @@ from langroid.mytypes import Entity
|
|
45
45
|
from langroid.parsing.parse_json import extract_top_level_json
|
46
46
|
from langroid.parsing.parser import Parser, ParsingConfig
|
47
47
|
from langroid.prompts.prompts_config import PromptsConfig
|
48
|
-
from langroid.pydantic_v1 import
|
48
|
+
from langroid.pydantic_v1 import (
|
49
|
+
BaseModel,
|
50
|
+
BaseSettings,
|
51
|
+
Field,
|
52
|
+
ValidationError,
|
53
|
+
validator,
|
54
|
+
)
|
49
55
|
from langroid.utils.configuration import settings
|
50
56
|
from langroid.utils.constants import DONE, NO_ANSWER, PASS, PASS_TO, SEND_TO
|
51
57
|
from langroid.utils.object_registry import ObjectRegistry
|
@@ -1300,8 +1306,25 @@ class Agent(ABC):
|
|
1300
1306
|
# else wrap it in an agent response and return it so
|
1301
1307
|
# orchestrator can find a respondent
|
1302
1308
|
result = self.create_agent_response(tool_messages=[maybe_result])
|
1303
|
-
|
1309
|
+
elif isinstance(maybe_result, (ChatDocument, str)):
|
1304
1310
|
result = maybe_result
|
1311
|
+
elif isinstance(maybe_result, BaseModel):
|
1312
|
+
result = maybe_result.json()
|
1313
|
+
else:
|
1314
|
+
# last resort: use json.dumps() or str() to make it a str
|
1315
|
+
try:
|
1316
|
+
result = json.dumps(maybe_result)
|
1317
|
+
except Exception:
|
1318
|
+
try:
|
1319
|
+
result = str(maybe_result)
|
1320
|
+
except Exception as e:
|
1321
|
+
logger.error(
|
1322
|
+
f"""
|
1323
|
+
Error converting result of {tool_name} to str: {e}",
|
1324
|
+
""",
|
1325
|
+
exc_info=True,
|
1326
|
+
)
|
1327
|
+
result = None
|
1305
1328
|
except Exception as e:
|
1306
1329
|
# raise the error here since we are sure it's
|
1307
1330
|
# not a pydantic validation error,
|
@@ -18,7 +18,7 @@ from langroid.language_models.prompt_formatter.base import PromptFormatter
|
|
18
18
|
logger = logging.getLogger(__name__)
|
19
19
|
|
20
20
|
|
21
|
-
def try_import_hf_modules() -> Tuple[Type[Any], Type[Any]
|
21
|
+
def try_import_hf_modules() -> Tuple[Type[Any], Type[Any]]:
|
22
22
|
"""
|
23
23
|
Attempts to import the AutoTokenizer class from the transformers package.
|
24
24
|
Returns:
|
@@ -27,17 +27,16 @@ def try_import_hf_modules() -> Tuple[Type[Any], Type[Any], Type[Any]]:
|
|
27
27
|
ImportError: If the transformers package is not installed.
|
28
28
|
"""
|
29
29
|
try:
|
30
|
-
from huggingface_hub import HfApi
|
30
|
+
from huggingface_hub import HfApi
|
31
31
|
from transformers import AutoTokenizer
|
32
32
|
|
33
|
-
return AutoTokenizer, HfApi
|
33
|
+
return AutoTokenizer, HfApi
|
34
34
|
except ImportError:
|
35
35
|
raise ImportError(
|
36
36
|
"""
|
37
37
|
You are trying to use some/all of:
|
38
38
|
HuggingFace transformers.AutoTokenizer,
|
39
|
-
huggingface_hub.HfApi,
|
40
|
-
huggingface_hub.ModelFilter,
|
39
|
+
huggingface_hub.HfApi,
|
41
40
|
but these are not not installed
|
42
41
|
by default with Langroid. Please install langroid using the
|
43
42
|
`transformers` extra, like so:
|
@@ -48,7 +47,7 @@ def try_import_hf_modules() -> Tuple[Type[Any], Type[Any], Type[Any]]:
|
|
48
47
|
|
49
48
|
|
50
49
|
def find_hf_formatter(model_name: str) -> str:
|
51
|
-
AutoTokenizer, HfApi
|
50
|
+
AutoTokenizer, HfApi = try_import_hf_modules()
|
52
51
|
hf_api = HfApi()
|
53
52
|
# try to find a matching model, with progressivly shorter prefixes of model_name
|
54
53
|
model_name = model_name.lower().split("/")[-1]
|
@@ -57,19 +56,19 @@ def find_hf_formatter(model_name: str) -> str:
|
|
57
56
|
for i in range(len(parts), 0, -1):
|
58
57
|
prefix = "-".join(parts[:i])
|
59
58
|
models = hf_api.list_models(
|
60
|
-
|
61
|
-
|
62
|
-
model_name=prefix,
|
63
|
-
)
|
59
|
+
task="text-generation",
|
60
|
+
model_name=prefix,
|
64
61
|
)
|
65
62
|
try:
|
66
63
|
mdl = next(models)
|
67
|
-
|
64
|
+
tokenizer = AutoTokenizer.from_pretrained(mdl.id)
|
65
|
+
if tokenizer.chat_template is not None:
|
66
|
+
return str(mdl.id)
|
67
|
+
else:
|
68
|
+
continue
|
69
|
+
except Exception:
|
68
70
|
continue
|
69
71
|
|
70
|
-
tokenizer = AutoTokenizer.from_pretrained(mdl.id)
|
71
|
-
if tokenizer.chat_template is not None:
|
72
|
-
return str(mdl.id)
|
73
72
|
return ""
|
74
73
|
|
75
74
|
|
@@ -78,14 +77,12 @@ class HFFormatter(PromptFormatter):
|
|
78
77
|
|
79
78
|
def __init__(self, config: HFPromptFormatterConfig):
|
80
79
|
super().__init__(config)
|
81
|
-
AutoTokenizer, HfApi
|
80
|
+
AutoTokenizer, HfApi = try_import_hf_modules()
|
82
81
|
self.config: HFPromptFormatterConfig = config
|
83
82
|
hf_api = HfApi()
|
84
83
|
models = hf_api.list_models(
|
85
|
-
|
86
|
-
|
87
|
-
model_name=config.model_name,
|
88
|
-
)
|
84
|
+
task="text-generation",
|
85
|
+
model_name=config.model_name,
|
89
86
|
)
|
90
87
|
try:
|
91
88
|
mdl = next(models)
|
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
|
{langroid-0.9.3 → langroid-0.9.5}/langroid/agent/special/sql/utils/description_extractors.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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/.chainlit/translations/en-US.json
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
|
{langroid-0.9.3 → langroid-0.9.5}/langroid/language_models/prompt_formatter/llama2_formatter.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
|
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
|