langroid 0.18.1__tar.gz → 0.18.2__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.18.1 → langroid-0.18.2}/PKG-INFO +1 -1
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/base.py +4 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/system.py +32 -8
- {langroid-0.18.1 → langroid-0.18.2}/pyproject.toml +1 -1
- {langroid-0.18.1 → langroid-0.18.2}/LICENSE +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/README.md +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/batch.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/callbacks/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/callbacks/chainlit.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/chat_agent.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/chat_document.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/helpers.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/junk +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/openai_assistant.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/doc_chat_agent.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/lance_rag/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/lance_tools.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/neo4j/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/neo4j/utils/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/neo4j/utils/system_message.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/relevance_extractor_agent.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/retriever_agent.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/sql/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/sql/utils/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/sql/utils/system_message.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/sql/utils/tools.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/special/table_chat_agent.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/structured_message.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/task.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/tool_message.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/tools/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/tools/file_tools.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/tools/google_search_tool.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/tools/metaphor_search_tool.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/tools/orchestration.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/tools/recipient_tool.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/tools/retrieval_tool.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/tools/rewind_tool.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/tools/segment_extract_tool.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/typed_task.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent/xml_tool_message.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/agent_config.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/cachedb/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/cachedb/base.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/cachedb/momento_cachedb.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/cachedb/redis_cachedb.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/embedding_models/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/embedding_models/base.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/embedding_models/clustering.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/embedding_models/models.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/embedding_models/protoc/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/embedding_models/protoc/embeddings.proto +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/embedding_models/remote_embeds.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/exceptions.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/language_models/.chainlit/config.toml +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/language_models/.chainlit/translations/en-US.json +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/language_models/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/language_models/azure_openai.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/language_models/base.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/language_models/config.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/language_models/mock_lm.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/language_models/openai_gpt.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/language_models/prompt_formatter/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/language_models/prompt_formatter/base.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/language_models/utils.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/mytypes.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/agent_chats.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/code-parsing.md +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/code_parser.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/config.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/document_parser.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/image_text.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/para_sentence_split.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/parse_json.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/parser.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/repo_loader.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/routing.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/search.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/spider.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/table_loader.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/url_loader.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/url_loader_cookies.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/urls.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/utils.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/parsing/web_search.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/prompts/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/prompts/dialog.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/prompts/prompts_config.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/prompts/templates.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/py.typed +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/pydantic_v1/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/pydantic_v1/main.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/.chainlit/config.toml +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/.chainlit/translations/en-US.json +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/algorithms/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/algorithms/graph.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/configuration.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/constants.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/docker.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/git_utils.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/globals.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/llms/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/llms/strings.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/logging.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/object_registry.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/output/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/output/citations.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/output/printing.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/output/status.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/pandas_utils.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/pydantic_utils.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/types.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/web/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/utils/web/login.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/vector_store/__init__.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/vector_store/base.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/vector_store/chromadb.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/vector_store/lancedb.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/vector_store/meilisearch.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/vector_store/momento.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/vector_store/qdrant_cloud.py +0 -0
- {langroid-0.18.1 → langroid-0.18.2}/langroid/vector_store/qdrantdb.py +0 -0
@@ -91,6 +91,8 @@ class AgentConfig(BaseSettings):
|
|
91
91
|
show_stats: bool = True # show token usage/cost stats?
|
92
92
|
add_to_registry: bool = True # register agent in ObjectRegistry?
|
93
93
|
respond_tools_only: bool = False # respond only to tool messages (not plain text)?
|
94
|
+
# allow multiple tool messages in a single response?
|
95
|
+
allow_multiple_tools: bool = True
|
94
96
|
|
95
97
|
@validator("name")
|
96
98
|
def check_name_alphanum(cls, v: str) -> str:
|
@@ -1120,6 +1122,8 @@ class Agent(ABC):
|
|
1120
1122
|
# as a response to the tool message even though the tool was not intended
|
1121
1123
|
# for this agent.
|
1122
1124
|
return None
|
1125
|
+
if len(tools) > 1 and not self.config.allow_multiple_tools:
|
1126
|
+
return self.to_ChatDocument("ERROR: Use ONE tool at a time!")
|
1123
1127
|
if len(tools) == 0:
|
1124
1128
|
fallback_result = self.handle_message_fallback(msg)
|
1125
1129
|
if fallback_result is None:
|
@@ -10,7 +10,7 @@ import socket
|
|
10
10
|
import traceback
|
11
11
|
import uuid
|
12
12
|
from pathlib import Path
|
13
|
-
from typing import Any
|
13
|
+
from typing import Any, Literal
|
14
14
|
|
15
15
|
logger = logging.getLogger(__name__)
|
16
16
|
|
@@ -186,24 +186,48 @@ def generate_unique_id() -> str:
|
|
186
186
|
return str(uuid.uuid4())
|
187
187
|
|
188
188
|
|
189
|
-
def create_file(
|
189
|
+
def create_file(
|
190
|
+
filepath: str | Path,
|
191
|
+
content: str = "",
|
192
|
+
if_exists: Literal["overwrite", "skip", "error", "append"] = "overwrite",
|
193
|
+
) -> None:
|
190
194
|
"""
|
191
|
-
Create a file with the given content
|
195
|
+
Create, overwrite or append to a file, with the given content
|
196
|
+
at the specified filepath.
|
192
197
|
If content is empty, it will simply touch to create an empty file.
|
193
198
|
|
194
199
|
Args:
|
195
200
|
filepath (str|Path): The relative path of the file to be created
|
196
201
|
content (str): The content to be written to the file
|
202
|
+
if_exists (Literal["overwrite", "skip", "error", "append"]):
|
203
|
+
Action to take if file exists
|
197
204
|
"""
|
198
|
-
Path(filepath)
|
199
|
-
|
200
|
-
|
205
|
+
filepath = Path(filepath)
|
206
|
+
filepath.parent.mkdir(parents=True, exist_ok=True)
|
207
|
+
|
208
|
+
if filepath.exists():
|
209
|
+
if if_exists == "skip":
|
210
|
+
logger.warning(f"File already exists, skipping: {filepath}")
|
211
|
+
return
|
212
|
+
elif if_exists == "error":
|
213
|
+
raise FileExistsError(f"File already exists: {filepath}")
|
214
|
+
elif if_exists == "append":
|
215
|
+
mode = "a"
|
216
|
+
else: # overwrite
|
217
|
+
mode = "w"
|
218
|
+
else:
|
219
|
+
mode = "w"
|
220
|
+
|
221
|
+
if content == "" and mode in ["a", "w"]:
|
222
|
+
filepath.touch()
|
223
|
+
logger.warning(f"Empty file created: {filepath}")
|
201
224
|
else:
|
202
225
|
# the newline = '\n` argument is used to ensure that
|
203
226
|
# newlines in the content are written as actual line breaks
|
204
|
-
with open(filepath,
|
227
|
+
with open(filepath, mode, newline="\n") as f:
|
205
228
|
f.write(content)
|
206
|
-
|
229
|
+
action = "appended to" if mode == "a" else "created/updated in"
|
230
|
+
logger.warning(f"Content {action}: {filepath}")
|
207
231
|
|
208
232
|
|
209
233
|
def read_file(path: str, line_numbers: bool = False) -> str:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
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.18.1 → langroid-0.18.2}/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
|
{langroid-0.18.1 → langroid-0.18.2}/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.18.1 → langroid-0.18.2}/langroid/language_models/prompt_formatter/hf_formatter.py
RENAMED
File without changes
|
{langroid-0.18.1 → langroid-0.18.2}/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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|