langroid 0.22.3__tar.gz → 0.22.4__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.22.3 → langroid-0.22.4}/PKG-INFO +1 -1
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/sql/sql_chat_agent.py +62 -68
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/tools/retrieval_tool.py +4 -1
- {langroid-0.22.3 → langroid-0.22.4}/pyproject.toml +1 -1
- {langroid-0.22.3 → langroid-0.22.4}/LICENSE +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/README.md +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/base.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/batch.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/callbacks/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/callbacks/chainlit.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/chat_agent.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/chat_document.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/helpers.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/junk +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/openai_assistant.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/arangodb/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/arangodb/arangodb_agent.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/arangodb/system_messages.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/arangodb/tools.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/arangodb/utils.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/doc_chat_agent.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/lance_rag/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/lance_tools.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/neo4j/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/neo4j/system_messages.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/neo4j/tools.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/relevance_extractor_agent.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/retriever_agent.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/sql/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/sql/utils/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/sql/utils/system_message.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/sql/utils/tools.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/special/table_chat_agent.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/structured_message.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/task.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/tool_message.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/tools/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/tools/file_tools.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/tools/google_search_tool.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/tools/metaphor_search_tool.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/tools/orchestration.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/tools/recipient_tool.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/tools/rewind_tool.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/tools/segment_extract_tool.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/typed_task.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent/xml_tool_message.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/agent_config.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/cachedb/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/cachedb/base.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/cachedb/momento_cachedb.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/cachedb/redis_cachedb.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/embedding_models/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/embedding_models/base.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/embedding_models/clustering.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/embedding_models/models.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/embedding_models/protoc/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/embedding_models/protoc/embeddings.proto +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/embedding_models/remote_embeds.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/exceptions.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/language_models/.chainlit/config.toml +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/language_models/.chainlit/translations/en-US.json +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/language_models/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/language_models/azure_openai.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/language_models/base.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/language_models/config.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/language_models/mock_lm.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/language_models/openai_gpt.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/language_models/prompt_formatter/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/language_models/prompt_formatter/base.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/language_models/utils.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/mytypes.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/agent_chats.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/code-parsing.md +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/code_parser.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/config.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/document_parser.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/image_text.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/para_sentence_split.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/parse_json.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/parser.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/repo_loader.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/routing.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/search.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/spider.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/table_loader.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/url_loader.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/url_loader_cookies.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/urls.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/utils.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/parsing/web_search.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/prompts/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/prompts/dialog.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/prompts/prompts_config.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/prompts/templates.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/py.typed +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/pydantic_v1/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/pydantic_v1/main.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/.chainlit/config.toml +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/.chainlit/translations/en-US.json +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/algorithms/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/algorithms/graph.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/configuration.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/constants.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/docker.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/git_utils.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/globals.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/llms/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/llms/strings.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/logging.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/object_registry.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/output/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/output/citations.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/output/printing.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/output/status.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/pandas_utils.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/pydantic_utils.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/system.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/types.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/web/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/utils/web/login.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/vector_store/__init__.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/vector_store/base.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/vector_store/chromadb.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/vector_store/lancedb.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/vector_store/meilisearch.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/vector_store/momento.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/vector_store/qdrant_cloud.py +0 -0
- {langroid-0.22.3 → langroid-0.22.4}/langroid/vector_store/qdrantdb.py +0 -0
@@ -10,11 +10,10 @@ Functionality includes:
|
|
10
10
|
import logging
|
11
11
|
from typing import Any, Dict, List, Optional, Sequence, Union
|
12
12
|
|
13
|
-
from rich import print
|
14
13
|
from rich.console import Console
|
15
14
|
|
16
15
|
from langroid.exceptions import LangroidImportError
|
17
|
-
from langroid.utils.constants import
|
16
|
+
from langroid.utils.constants import SEND_TO
|
18
17
|
|
19
18
|
try:
|
20
19
|
from sqlalchemy import MetaData, Row, create_engine, inspect, text
|
@@ -25,7 +24,7 @@ except ImportError as e:
|
|
25
24
|
raise LangroidImportError(extra="sql", error=str(e))
|
26
25
|
|
27
26
|
from langroid.agent.chat_agent import ChatAgent, ChatAgentConfig
|
28
|
-
from langroid.agent.chat_document import
|
27
|
+
from langroid.agent.chat_document import ChatDocument
|
29
28
|
from langroid.agent.special.sql.utils.description_extractors import (
|
30
29
|
extract_schema_descriptions,
|
31
30
|
)
|
@@ -43,15 +42,15 @@ from langroid.agent.special.sql.utils.tools import (
|
|
43
42
|
GetTableSchemaTool,
|
44
43
|
RunQueryTool,
|
45
44
|
)
|
46
|
-
from langroid.
|
45
|
+
from langroid.agent.tools.orchestration import DoneTool, ForwardTool
|
47
46
|
from langroid.vector_store.base import VectorStoreConfig
|
48
47
|
|
49
48
|
logger = logging.getLogger(__name__)
|
50
49
|
|
51
50
|
console = Console()
|
52
51
|
|
53
|
-
DEFAULT_SQL_CHAT_SYSTEM_MESSAGE =
|
54
|
-
{
|
52
|
+
DEFAULT_SQL_CHAT_SYSTEM_MESSAGE = """
|
53
|
+
{mode}
|
55
54
|
|
56
55
|
You do not need to attempt answering a question with just one query.
|
57
56
|
You could make a sequence of SQL queries to help you write the final query.
|
@@ -65,19 +64,24 @@ are "Male" and "Female".
|
|
65
64
|
|
66
65
|
Start by asking what I would like to know about the data.
|
67
66
|
|
68
|
-
When you have FINISHED the given query or database update task,
|
69
|
-
say {DONE} and show your answer.
|
70
|
-
|
71
67
|
"""
|
72
68
|
|
73
|
-
ADDRESSING_INSTRUCTION =
|
69
|
+
ADDRESSING_INSTRUCTION = """
|
74
70
|
IMPORTANT - Whenever you are NOT writing a SQL query, make sure you address the user
|
75
|
-
using {
|
71
|
+
using {prefix}User. You MUST use the EXACT syntax {prefix} !!!
|
76
72
|
|
77
73
|
In other words, you ALWAYS write EITHER:
|
78
74
|
- a SQL query using the `run_query` tool,
|
79
|
-
- OR address the user using {
|
80
|
-
|
75
|
+
- OR address the user using {prefix}User
|
76
|
+
"""
|
77
|
+
|
78
|
+
DONE_INSTRUCTION = f"""
|
79
|
+
When you are SURE you have the CORRECT answer to a user's query or request,
|
80
|
+
use the `{DoneTool.name()}` with `content` set to the answer or result.
|
81
|
+
If you DO NOT think you have the answer to the user's query or request,
|
82
|
+
you SHOULD NOT use the `{DoneTool.name()}` tool.
|
83
|
+
Instead, you must CONTINUE to improve your queries (tools) to get the correct answer,
|
84
|
+
and finally use the `{DoneTool.name()}` tool to send the correct answer to the user.
|
81
85
|
"""
|
82
86
|
|
83
87
|
|
@@ -96,7 +100,10 @@ class SQLChatAgentConfig(ChatAgentConfig):
|
|
96
100
|
context_descriptions: Dict[str, Dict[str, Union[str, Dict[str, str]]]] = {}
|
97
101
|
use_schema_tools: bool = False
|
98
102
|
multi_schema: bool = False
|
99
|
-
|
103
|
+
# whether the agent is used in a continuous chat with user,
|
104
|
+
# as opposed to returning a result from the task.run()
|
105
|
+
chat_mode: bool = False
|
106
|
+
addressing_prefix: str = ""
|
100
107
|
|
101
108
|
"""
|
102
109
|
Optional, but strongly recommended, context descriptions for tables, columns,
|
@@ -225,14 +232,21 @@ class SQLChatAgent(ChatAgent):
|
|
225
232
|
"""Initialize message tools used for chatting."""
|
226
233
|
message = self._format_message()
|
227
234
|
self.config.system_message = self.config.system_message.format(mode=message)
|
228
|
-
|
235
|
+
|
236
|
+
if self.config.chat_mode:
|
237
|
+
self.config.addressing_prefix = self.config.addressing_prefix or SEND_TO
|
229
238
|
self.config.system_message += ADDRESSING_INSTRUCTION.format(
|
230
239
|
prefix=self.config.addressing_prefix
|
231
240
|
)
|
241
|
+
else:
|
242
|
+
self.config.system_message += DONE_INSTRUCTION
|
243
|
+
|
232
244
|
super().__init__(self.config)
|
233
|
-
self.enable_message(RunQueryTool)
|
245
|
+
self.enable_message([RunQueryTool, ForwardTool])
|
234
246
|
if self.config.use_schema_tools:
|
235
247
|
self._enable_schema_tools()
|
248
|
+
if not self.config.chat_mode:
|
249
|
+
self.enable_message(DoneTool)
|
236
250
|
|
237
251
|
def _format_message(self) -> str:
|
238
252
|
if self.engine is None:
|
@@ -270,7 +284,7 @@ class SQLChatAgent(ChatAgent):
|
|
270
284
|
|
271
285
|
def handle_message_fallback(
|
272
286
|
self, msg: str | ChatDocument
|
273
|
-
) -> str |
|
287
|
+
) -> str | ForwardTool | None:
|
274
288
|
"""
|
275
289
|
Handle the scenario where current msg is not a tool.
|
276
290
|
Special handling is only needed if the message was from the LLM
|
@@ -278,60 +292,40 @@ class SQLChatAgent(ChatAgent):
|
|
278
292
|
"""
|
279
293
|
if not self.llm_responded:
|
280
294
|
return None
|
281
|
-
if self.
|
282
|
-
|
283
|
-
self.config.addressing_prefix + "User"
|
284
|
-
if self.config.addressing_prefix
|
285
|
-
else ""
|
286
|
-
)
|
287
|
-
return (
|
288
|
-
DONE + prefix + (msg.content if isinstance(msg, ChatDocument) else msg)
|
289
|
-
)
|
295
|
+
if self.interactive:
|
296
|
+
return ForwardTool(agent="User")
|
290
297
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
298
|
+
tools_instruction = f"""
|
299
|
+
For example you may want to use the TOOL
|
300
|
+
`{RunQueryTool.name()}` to further explore the database contents
|
301
|
+
"""
|
302
|
+
if self.config.use_schema_tools:
|
303
|
+
tools_instruction += """
|
304
|
+
OR you may want to use one of the schema tools to
|
305
|
+
explore the database schema
|
306
|
+
"""
|
307
|
+
if self.config.chat_mode:
|
308
|
+
return f"""
|
309
|
+
Since you did not explicitly address the User, it is not clear
|
310
|
+
whether:
|
311
|
+
- you intend this to be the final response to the
|
312
|
+
user's query/request, in which case you must use the
|
313
|
+
`{ForwardTool.name()}` to indicate this.
|
314
|
+
- OR, you FORGOT to use an Appropriate TOOL,
|
315
|
+
in which case you should use the available tools to
|
316
|
+
make progress on the user's query/request.
|
317
|
+
{tools_instruction}
|
295
318
|
"""
|
296
|
-
if self.config.addressing_prefix != "":
|
297
|
-
reminder += f"""
|
298
|
-
OR you may have forgotten to address the user using the prefix
|
299
|
-
{self.config.addressing_prefix}
|
300
|
-
"""
|
301
|
-
return reminder
|
302
|
-
|
303
|
-
def _agent_response(
|
304
|
-
self,
|
305
|
-
msg: Optional[str | ChatDocument] = None,
|
306
|
-
) -> Optional[ChatDocument]:
|
307
|
-
# Your override code here
|
308
|
-
if msg is None:
|
309
|
-
return None
|
310
|
-
|
311
|
-
results = self.handle_message(msg)
|
312
|
-
if results is None:
|
313
|
-
return None
|
314
319
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
content = results.content if isinstance(results, ChatDocument) else results
|
326
|
-
|
327
|
-
return ChatDocument(
|
328
|
-
content=content,
|
329
|
-
metadata=ChatDocMetaData(
|
330
|
-
source=Entity.AGENT,
|
331
|
-
sender=Entity.AGENT,
|
332
|
-
sender_name=sender_name,
|
333
|
-
),
|
334
|
-
)
|
320
|
+
return f"""
|
321
|
+
The intent of your response is not clear:
|
322
|
+
- if you intended this to be the FINAL answer to the user's query,
|
323
|
+
then use the `{DoneTool.name()}` to indicate so,
|
324
|
+
with the `content` set to the answer or result.
|
325
|
+
- otherwise, use one of the available tools to make progress
|
326
|
+
to arrive at the final answer.
|
327
|
+
{tools_instruction}
|
328
|
+
"""
|
335
329
|
|
336
330
|
def retry_query(self, e: Exception, query: str) -> str:
|
337
331
|
"""
|
@@ -4,7 +4,10 @@ from langroid.agent.tool_message import ToolMessage
|
|
4
4
|
|
5
5
|
|
6
6
|
class RetrievalTool(ToolMessage):
|
7
|
-
"""
|
7
|
+
"""
|
8
|
+
Retrieval tool, only to be used by a DocChatAgent.
|
9
|
+
The handler method is defined in DocChatAgent.retrieval_tool
|
10
|
+
"""
|
8
11
|
|
9
12
|
request: str = "retrieval_tool"
|
10
13
|
purpose: 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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.22.3 → langroid-0.22.4}/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
|
{langroid-0.22.3 → langroid-0.22.4}/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.22.3 → langroid-0.22.4}/langroid/language_models/prompt_formatter/hf_formatter.py
RENAMED
File without changes
|
{langroid-0.22.3 → langroid-0.22.4}/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
|
File without changes
|