langroid 0.56.12__tar.gz → 0.56.13__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.56.12 → langroid-0.56.13}/PKG-INFO +1 -1
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/base.py +4 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/task.py +27 -11
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/task_tool.py +71 -13
- {langroid-0.56.12 → langroid-0.56.13}/pyproject.toml +1 -1
- {langroid-0.56.12 → langroid-0.56.13}/.gitignore +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/LICENSE +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/README.md +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/batch.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/callbacks/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/callbacks/chainlit.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/chat_agent.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/chat_document.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/done_sequence_parser.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/openai_assistant.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/arangodb/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/arangodb/arangodb_agent.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/arangodb/system_messages.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/arangodb/tools.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/arangodb/utils.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/doc_chat_agent.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/doc_chat_task.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/lance_rag/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/lance_tools.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/neo4j/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/neo4j/system_messages.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/neo4j/tools.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/relevance_extractor_agent.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/retriever_agent.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/sql/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/sql/utils/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/sql/utils/system_message.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/sql/utils/tools.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/special/table_chat_agent.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tool_message.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/exa_search_tool.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/file_tools.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/google_search_tool.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/mcp/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/mcp/decorators.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/mcp/fastmcp_client.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/metaphor_search_tool.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/orchestration.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/recipient_tool.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/retrieval_tool.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/rewind_tool.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/segment_extract_tool.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/tools/tavily_search_tool.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/agent/xml_tool_message.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/cachedb/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/cachedb/base.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/cachedb/redis_cachedb.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/embedding_models/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/embedding_models/base.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/embedding_models/models.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/embedding_models/protoc/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/embedding_models/protoc/embeddings.proto +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/embedding_models/remote_embeds.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/exceptions.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/azure_openai.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/base.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/client_cache.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/config.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/mock_lm.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/model_info.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/openai_gpt.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/prompt_formatter/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/prompt_formatter/base.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/provider_params.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/utils.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/mcp/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/mcp/server/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/mytypes.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/agent_chats.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/code_parser.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/document_parser.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/file_attachment.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/md_parser.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/para_sentence_split.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/parse_json.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/parser.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/pdf_utils.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/repo_loader.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/routing.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/search.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/spider.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/table_loader.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/url_loader.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/urls.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/utils.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/parsing/web_search.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/prompts/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/prompts/dialog.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/prompts/prompts_config.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/prompts/templates.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/py.typed +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/pydantic_v1/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/pydantic_v1/main.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/algorithms/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/algorithms/graph.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/configuration.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/constants.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/git_utils.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/globals.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/logging.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/object_registry.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/output/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/output/citations.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/output/printing.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/output/status.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/pandas_utils.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/pydantic_utils.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/system.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/utils/types.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/vector_store/__init__.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/vector_store/base.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/vector_store/chromadb.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/vector_store/lancedb.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/vector_store/meilisearch.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/vector_store/pineconedb.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/vector_store/postgres.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/vector_store/qdrantdb.py +0 -0
- {langroid-0.56.12 → langroid-0.56.13}/langroid/vector_store/weaviatedb.py +0 -0
@@ -137,6 +137,7 @@ class Agent(ABC):
|
|
137
137
|
|
138
138
|
def __init__(self, config: AgentConfig = AgentConfig()):
|
139
139
|
self.config = config
|
140
|
+
self.id = ObjectRegistry.new_id() # Initialize agent ID
|
140
141
|
self.lock = asyncio.Lock() # for async access to update self.llm.usage_cost
|
141
142
|
self.dialog: List[Tuple[str, str]] = [] # seq of LLM (prompt, response) tuples
|
142
143
|
self.llm_tools_map: Dict[str, Type[ToolMessage]] = {}
|
@@ -685,6 +686,7 @@ class Agent(ABC):
|
|
685
686
|
results.metadata.tool_ids = (
|
686
687
|
[] if msg is None or isinstance(msg, str) else msg.metadata.tool_ids
|
687
688
|
)
|
689
|
+
results.metadata.agent_id = self.id
|
688
690
|
return results
|
689
691
|
sender_name = self.config.name
|
690
692
|
if isinstance(msg, ChatDocument) and msg.function_call is not None:
|
@@ -703,6 +705,7 @@ class Agent(ABC):
|
|
703
705
|
metadata=ChatDocMetaData(
|
704
706
|
source=Entity.AGENT,
|
705
707
|
sender=Entity.AGENT,
|
708
|
+
agent_id=self.id,
|
706
709
|
sender_name=sender_name,
|
707
710
|
oai_tool_id=oai_tool_id,
|
708
711
|
# preserve trail of tool_ids for OpenAI Assistant fn-calls
|
@@ -967,6 +970,7 @@ class Agent(ABC):
|
|
967
970
|
return ChatDocument(
|
968
971
|
content=user_msg,
|
969
972
|
metadata=ChatDocMetaData(
|
973
|
+
agent_id=self.id,
|
970
974
|
source=source,
|
971
975
|
sender=sender,
|
972
976
|
# preserve trail of tool_ids for OpenAI Assistant fn-calls
|
@@ -615,7 +615,10 @@ class Task:
|
|
615
615
|
if isinstance(msg, ChatDocument):
|
616
616
|
# carefully deep-copy: fresh metadata.id, register
|
617
617
|
# as new obj in registry
|
618
|
+
original_parent_id = msg.metadata.parent_id
|
618
619
|
self.pending_message = ChatDocument.deepcopy(msg)
|
620
|
+
# Preserve the parent pointer from the original message
|
621
|
+
self.pending_message.metadata.parent_id = original_parent_id
|
619
622
|
if self.pending_message is not None and self.caller is not None:
|
620
623
|
# msg may have come from `caller`, so we pretend this is from
|
621
624
|
# the CURRENT task's USER entity
|
@@ -623,7 +626,11 @@ class Task:
|
|
623
626
|
# update parent, child, agent pointers
|
624
627
|
if msg is not None:
|
625
628
|
msg.metadata.child_id = self.pending_message.metadata.id
|
626
|
-
|
629
|
+
# Only override parent_id if it wasn't already set in the
|
630
|
+
# original message. This preserves parent chains from TaskTool
|
631
|
+
if not msg.metadata.parent_id:
|
632
|
+
self.pending_message.metadata.parent_id = msg.metadata.id
|
633
|
+
if self.pending_message is not None:
|
627
634
|
self.pending_message.metadata.agent_id = self.agent.id
|
628
635
|
|
629
636
|
self._show_pending_message_if_debug()
|
@@ -2250,24 +2257,33 @@ class Task:
|
|
2250
2257
|
def _get_message_chain(
|
2251
2258
|
self, msg: ChatDocument | None, max_depth: Optional[int] = None
|
2252
2259
|
) -> List[ChatDocument]:
|
2253
|
-
"""Get the chain of messages
|
2260
|
+
"""Get the chain of messages using agent's message history."""
|
2254
2261
|
if max_depth is None:
|
2255
2262
|
# Get max depth needed from all sequences
|
2256
2263
|
max_depth = 50 # default fallback
|
2257
2264
|
if self._parsed_done_sequences:
|
2258
2265
|
max_depth = max(len(seq.events) for seq in self._parsed_done_sequences)
|
2259
2266
|
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2267
|
+
# Get chat document IDs from message history
|
2268
|
+
doc_ids = [
|
2269
|
+
m.chat_document_id for m in self.agent.message_history if m.chat_document_id
|
2270
|
+
]
|
2271
|
+
|
2272
|
+
# Add current message ID if it exists and is not already the last one
|
2273
|
+
if msg:
|
2274
|
+
msg_id = msg.id()
|
2275
|
+
if not doc_ids or doc_ids[-1] != msg_id:
|
2276
|
+
doc_ids.append(msg_id)
|
2263
2277
|
|
2264
|
-
|
2265
|
-
|
2266
|
-
current = current.parent
|
2267
|
-
depth += 1
|
2278
|
+
# Take only the last max_depth elements
|
2279
|
+
relevant_ids = doc_ids[-max_depth:]
|
2268
2280
|
|
2269
|
-
#
|
2270
|
-
return
|
2281
|
+
# Convert IDs to ChatDocuments and filter out None values
|
2282
|
+
return [
|
2283
|
+
doc
|
2284
|
+
for doc_id in relevant_ids
|
2285
|
+
if (doc := ChatDocument.from_id(doc_id)) is not None
|
2286
|
+
]
|
2271
2287
|
|
2272
2288
|
def _matches_event(self, actual: AgentEvent, expected: AgentEvent) -> bool:
|
2273
2289
|
"""Check if an actual event matches an expected event pattern."""
|
@@ -38,10 +38,13 @@ class TaskTool(ToolMessage):
|
|
38
38
|
system_message: Optional[str] = Field(
|
39
39
|
...,
|
40
40
|
description="""
|
41
|
-
Optional system message to configure the sub-agent's general behavior
|
41
|
+
Optional system message to configure the sub-agent's general behavior and
|
42
|
+
to specify the task and its context.
|
42
43
|
A good system message will have these components:
|
43
44
|
- Inform the sub-agent of its role, e.g. "You are a financial analyst."
|
44
|
-
- Clear spec of the task
|
45
|
+
- Clear spec of the task, with sufficient context for the sub-agent to
|
46
|
+
understand what it needs to do, since the sub-agent does
|
47
|
+
NOT have access to your conversation history!
|
45
48
|
- Any additional general context needed for the task, such as a
|
46
49
|
(part of a) document, or data items, etc.
|
47
50
|
- Specify when to use certain tools, e.g.
|
@@ -73,9 +76,10 @@ class TaskTool(ToolMessage):
|
|
73
76
|
A list of tool names to enable for the sub-agent.
|
74
77
|
This must be a list of strings referring to the names of tools
|
75
78
|
that are known to you.
|
76
|
-
If you want to enable all tools, you
|
77
|
-
|
78
|
-
|
79
|
+
If you want to enable all tools, or you do not have any preference
|
80
|
+
on what tools are enabled for the sub-agent, you can set
|
81
|
+
this field to a singleton list ['ALL']
|
82
|
+
To disable all tools, set it to a singleton list ['NONE']
|
79
83
|
""",
|
80
84
|
)
|
81
85
|
# TODO: ensure valid model name
|
@@ -113,11 +117,20 @@ class TaskTool(ToolMessage):
|
|
113
117
|
# TODO: Maybe we just copy the parent agent's config and override chat_model?
|
114
118
|
# -- but what if parent agent has a MockLMConfig?
|
115
119
|
llm_config = lm.OpenAIGPTConfig(
|
116
|
-
chat_model=self.model or
|
120
|
+
chat_model=self.model or lm.OpenAIChatModel.GPT4_1_MINI,
|
117
121
|
)
|
118
122
|
config = ChatAgentConfig(
|
119
123
|
name=agent_name,
|
120
124
|
llm=llm_config,
|
125
|
+
handle_llm_no_tool=f"""
|
126
|
+
You forgot to use one of your TOOLs! Remember that you must either:
|
127
|
+
- use a tool, or a sequence of tools, to complete your task, OR
|
128
|
+
- if you are done with your task, use the `{DoneTool.name()}` tool
|
129
|
+
to return the result.
|
130
|
+
|
131
|
+
As a reminder, this was your task:
|
132
|
+
{self.prompt}
|
133
|
+
""",
|
121
134
|
system_message=f"""
|
122
135
|
{self.system_message}
|
123
136
|
|
@@ -138,7 +151,9 @@ class TaskTool(ToolMessage):
|
|
138
151
|
tool_classes = [
|
139
152
|
agent.llm_tools_map[t]
|
140
153
|
for t in agent.llm_tools_known
|
141
|
-
if t in agent.llm_tools_map
|
154
|
+
if t in agent.llm_tools_map
|
155
|
+
and t != self.request
|
156
|
+
and agent.llm_tools_map[t]._allow_llm_use
|
142
157
|
# Exclude the TaskTool itself!
|
143
158
|
]
|
144
159
|
elif self.tools == ["NONE"]:
|
@@ -150,6 +165,7 @@ class TaskTool(ToolMessage):
|
|
150
165
|
agent.llm_tools_map[tool_name]
|
151
166
|
for tool_name in self.tools
|
152
167
|
if tool_name in agent.llm_tools_map
|
168
|
+
and agent.llm_tools_map[tool_name]._allow_llm_use
|
153
169
|
]
|
154
170
|
|
155
171
|
# always enable the DoneTool to signal task completion
|
@@ -160,7 +176,9 @@ class TaskTool(ToolMessage):
|
|
160
176
|
|
161
177
|
return task
|
162
178
|
|
163
|
-
def handle(
|
179
|
+
def handle(
|
180
|
+
self, agent: ChatAgent, chat_doc: Optional[ChatDocument] = None
|
181
|
+
) -> Optional[ChatDocument]:
|
164
182
|
"""
|
165
183
|
|
166
184
|
Handle the TaskTool by creating a sub-agent with specified tools
|
@@ -168,24 +186,64 @@ class TaskTool(ToolMessage):
|
|
168
186
|
|
169
187
|
Args:
|
170
188
|
agent: The parent ChatAgent that is handling this tool
|
189
|
+
chat_doc: The ChatDocument containing this tool message
|
171
190
|
"""
|
172
191
|
|
173
192
|
task = self._set_up_task(agent)
|
174
|
-
|
175
|
-
|
193
|
+
|
194
|
+
# Create a ChatDocument for the prompt with parent pointer
|
195
|
+
prompt_doc = None
|
196
|
+
if chat_doc is not None:
|
197
|
+
from langroid.agent.chat_document import ChatDocMetaData
|
198
|
+
|
199
|
+
prompt_doc = ChatDocument(
|
200
|
+
content=self.prompt,
|
201
|
+
metadata=ChatDocMetaData(
|
202
|
+
parent_id=chat_doc.id(),
|
203
|
+
agent_id=agent.id,
|
204
|
+
sender=chat_doc.metadata.sender,
|
205
|
+
),
|
206
|
+
)
|
207
|
+
# Set bidirectional parent-child relationship
|
208
|
+
chat_doc.metadata.child_id = prompt_doc.id()
|
209
|
+
|
210
|
+
# Run the task with the ChatDocument or string prompt
|
211
|
+
result = task.run(prompt_doc or self.prompt, turns=self.max_iterations or 10)
|
176
212
|
return result
|
177
213
|
|
178
|
-
async def handle_async(
|
214
|
+
async def handle_async(
|
215
|
+
self, agent: ChatAgent, chat_doc: Optional[ChatDocument] = None
|
216
|
+
) -> Optional[ChatDocument]:
|
179
217
|
"""
|
180
218
|
Async method to handle the TaskTool by creating a sub-agent with specified tools
|
181
219
|
and running the task non-interactively.
|
182
220
|
|
183
221
|
Args:
|
184
222
|
agent: The parent ChatAgent that is handling this tool
|
223
|
+
chat_doc: The ChatDocument containing this tool message
|
185
224
|
"""
|
186
225
|
task = self._set_up_task(agent)
|
187
|
-
|
226
|
+
|
227
|
+
# Create a ChatDocument for the prompt with parent pointer
|
228
|
+
prompt_doc = None
|
229
|
+
if chat_doc is not None:
|
230
|
+
from langroid.agent.chat_document import ChatDocMetaData
|
231
|
+
|
232
|
+
prompt_doc = ChatDocument(
|
233
|
+
content=self.prompt,
|
234
|
+
metadata=ChatDocMetaData(
|
235
|
+
parent_id=chat_doc.id(),
|
236
|
+
agent_id=agent.id,
|
237
|
+
sender=chat_doc.metadata.sender,
|
238
|
+
),
|
239
|
+
)
|
240
|
+
# Set bidirectional parent-child relationship
|
241
|
+
chat_doc.metadata.child_id = prompt_doc.id()
|
242
|
+
|
243
|
+
# Run the task with the ChatDocument or string prompt
|
188
244
|
# TODO eventually allow the various task setup configs,
|
189
245
|
# including termination conditions
|
190
|
-
result = await task.run_async(
|
246
|
+
result = await task.run_async(
|
247
|
+
prompt_doc or self.prompt, turns=self.max_iterations or 10
|
248
|
+
)
|
191
249
|
return result
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
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.56.12 → langroid-0.56.13}/langroid/agent/special/lance_rag/query_planner_agent.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
|
{langroid-0.56.12 → langroid-0.56.13}/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
|
{langroid-0.56.12 → langroid-0.56.13}/langroid/embedding_models/protoc/embeddings_pb2_grpc.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
|
{langroid-0.56.12 → langroid-0.56.13}/langroid/language_models/prompt_formatter/hf_formatter.py
RENAMED
File without changes
|
{langroid-0.56.12 → langroid-0.56.13}/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
|