langroid 0.1.241__tar.gz → 0.1.244__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.1.241 → langroid-0.1.244}/PKG-INFO +2 -2
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/base.py +4 -2
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/lance_rag/critic_agent.py +19 -14
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/lance_rag/query_planner_agent.py +34 -7
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/lance_tools.py +5 -1
- {langroid-0.1.241 → langroid-0.1.244}/langroid/language_models/openai_gpt.py +4 -0
- {langroid-0.1.241 → langroid-0.1.244}/pyproject.toml +2 -2
- {langroid-0.1.241 → langroid-0.1.244}/LICENSE +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/README.md +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/batch.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/callbacks/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/callbacks/chainlit.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/chat_agent.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/chat_document.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/helpers.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/junk +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/openai_assistant.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/doc_chat_agent.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/lance_rag/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/neo4j/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/neo4j/utils/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/neo4j/utils/system_message.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/relevance_extractor_agent.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/retriever_agent.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/sql/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/sql/utils/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/sql/utils/system_message.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/sql/utils/tools.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/table_chat_agent.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/task.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/tool_message.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/tools/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/tools/extract_tool.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/tools/generator_tool.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/tools/google_search_tool.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/tools/metaphor_search_tool.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/tools/recipient_tool.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/tools/run_python_code.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent/tools/segment_extract_tool.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/agent_config.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/cachedb/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/cachedb/base.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/cachedb/momento_cachedb.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/cachedb/redis_cachedb.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/embedding_models/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/embedding_models/base.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/embedding_models/clustering.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/embedding_models/models.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/embedding_models/protoc/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/embedding_models/protoc/embeddings.proto +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/embedding_models/remote_embeds.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/language_models/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/language_models/azure_openai.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/language_models/base.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/language_models/config.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/language_models/openai_assistants.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/language_models/prompt_formatter/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/language_models/prompt_formatter/base.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/language_models/utils.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/mytypes.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/agent_chats.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/code-parsing.md +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/code_parser.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/config.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/document_parser.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/image_text.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/para_sentence_split.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/parse_json.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/parser.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/repo_loader.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/search.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/spider.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/table_loader.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/url_loader.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/url_loader_cookies.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/urls.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/utils.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/parsing/web_search.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/prompts/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/prompts/dialog.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/prompts/prompts_config.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/prompts/templates.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/prompts/transforms.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/algorithms/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/algorithms/graph.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/configuration.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/constants.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/docker.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/globals.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/llms/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/llms/strings.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/logging.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/output/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/output/printing.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/output/status.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/pandas_utils.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/pydantic_utils.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/system.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/web/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/utils/web/login.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/vector_store/__init__.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/vector_store/base.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/vector_store/chromadb.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/vector_store/lancedb.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/vector_store/meilisearch.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/vector_store/momento.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/vector_store/qdrant_cloud.py +0 -0
- {langroid-0.1.241 → langroid-0.1.244}/langroid/vector_store/qdrantdb.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: langroid
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.244
|
4
4
|
Summary: Harness LLMs with Multi-Agent Programming
|
5
5
|
License: MIT
|
6
6
|
Author: Prasad Chalasani
|
@@ -30,7 +30,7 @@ Requires-Dist: chainlit (>=1.0.400,<2.0.0) ; extra == "chainlit"
|
|
30
30
|
Requires-Dist: chromadb (>=0.4.21,<=0.4.23) ; extra == "chromadb"
|
31
31
|
Requires-Dist: colorlog (>=6.7.0,<7.0.0)
|
32
32
|
Requires-Dist: docstring-parser (>=0.15,<0.16)
|
33
|
-
Requires-Dist: duckduckgo-search (>=
|
33
|
+
Requires-Dist: duckduckgo-search (>=6.0.0,<7.0.0)
|
34
34
|
Requires-Dist: faker (>=18.9.0,<19.0.0)
|
35
35
|
Requires-Dist: fakeredis (>=2.12.1,<3.0.0)
|
36
36
|
Requires-Dist: fire (>=0.5.0,<0.6.0)
|
@@ -812,12 +812,14 @@ class Agent(ABC):
|
|
812
812
|
llm_model = (
|
813
813
|
"no-LLM" if self.config.llm is None else self.llm.config.chat_model
|
814
814
|
)
|
815
|
-
|
815
|
+
# tot cost across all LLMs, agents
|
816
|
+
all_cost = format(self.llm.tot_tokens_cost()[1], ".4f")
|
816
817
|
return (
|
817
818
|
f"[bold]Stats:[/bold] [magenta]N_MSG={chat_length}, "
|
818
819
|
f"TOKENS: in={in_tokens}, out={out_tokens}, "
|
819
820
|
f"max={max_out}, ctx={context_length}, "
|
820
|
-
f"COST: now=${llm_response_cost}, cumul=${cumul_cost} "
|
821
|
+
f"COST: now=${llm_response_cost}, cumul=${cumul_cost}, "
|
822
|
+
f"tot=${all_cost} "
|
821
823
|
f"[bold]({llm_model})[/bold][/magenta]"
|
822
824
|
)
|
823
825
|
return ""
|
@@ -52,7 +52,7 @@ class QueryPlanCriticConfig(LanceQueryPlanAgentConfig):
|
|
52
52
|
SEMANTIC/LEXICAL/FUZZY FILTER since the Assistant is able to use it to match
|
53
53
|
the CONTENT of the docs in various ways (semantic, lexical, fuzzy, etc.).
|
54
54
|
|
55
|
-
- DATAFRAME CALCULATION, and
|
55
|
+
- DATAFRAME CALCULATION, which must be a SINGLE LINE calculation, and
|
56
56
|
- ANSWER recieved from an assistant that used this QUERY PLAN.
|
57
57
|
|
58
58
|
In addition to the above SCHEMA fields there is a `content` field which:
|
@@ -64,8 +64,10 @@ class QueryPlanCriticConfig(LanceQueryPlanAgentConfig):
|
|
64
64
|
ONLY using the `query_plan_feedback` tool, and DO NOT SAY ANYTHING ELSE.
|
65
65
|
|
66
66
|
Here is how you must examine the QUERY PLAN + ANSWER:
|
67
|
+
- ALL filtering conditions in the original query must be EXPLICITLY
|
68
|
+
mentioned in the FILTER, and the QUERY field should not be used for filtering.
|
67
69
|
- If the ANSWER is in the expected form, then the QUERY PLAN is likely VALID,
|
68
|
-
and your feedback should
|
70
|
+
and your feedback should say VALID, with empty `suggested_fix`.
|
69
71
|
- If the ANSWER is {NO_ANSWER} or of the wrong form,
|
70
72
|
then try to DIAGNOSE the problem IN THE FOLLOWING ORDER:
|
71
73
|
- DATAFRAME CALCULATION -- is it doing the right thing?
|
@@ -83,11 +85,13 @@ class QueryPlanCriticConfig(LanceQueryPlanAgentConfig):
|
|
83
85
|
REMEMBER: A filter should ONLY be used if EXPLICITLY REQUIRED BY THE QUERY.
|
84
86
|
|
85
87
|
|
86
|
-
ALWAYS use `query_plan_feedback` tool/fn to present your feedback
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
ALWAYS use `query_plan_feedback` tool/fn to present your feedback
|
89
|
+
in the `feedback` field, and if any fix is suggested,
|
90
|
+
present it in the `suggested_fix` field.
|
91
|
+
DO NOT SAY ANYTHING ELSE OUTSIDE THE TOOL/FN.
|
92
|
+
IF NO REVISION NEEDED, simply leave the `suggested_fix` field EMPTY,
|
93
|
+
and SAY NOTHING ELSE
|
94
|
+
and DO NOT EXPLAIN YOURSELF.
|
91
95
|
"""
|
92
96
|
|
93
97
|
|
@@ -95,7 +99,7 @@ def plain_text_query_plan(msg: QueryPlanAnswerTool) -> str:
|
|
95
99
|
plan = f"""
|
96
100
|
OriginalQuery: {msg.plan.original_query}
|
97
101
|
Filter: {msg.plan.filter}
|
98
|
-
Query: {msg.plan.query}
|
102
|
+
Rephrased Query: {msg.plan.query}
|
99
103
|
DataframeCalc: {msg.plan.dataframe_calc}
|
100
104
|
Answer: {msg.answer}
|
101
105
|
"""
|
@@ -126,11 +130,12 @@ class QueryPlanCritic(ChatAgent):
|
|
126
130
|
def handle_message_fallback(
|
127
131
|
self, msg: str | ChatDocument
|
128
132
|
) -> str | ChatDocument | None:
|
129
|
-
"""
|
133
|
+
"""Remind the LLM to use QueryPlanFeedbackTool since it forgot"""
|
130
134
|
if isinstance(msg, ChatDocument) and msg.metadata.sender == Entity.LLM:
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
135
|
+
return """
|
136
|
+
You forgot to use the `query_plan_feedback` tool/function.
|
137
|
+
Re-try your response using the `query_plan_feedback` tool/function,
|
138
|
+
remember to provide feedback in the `feedback` field,
|
139
|
+
and if any fix is suggested, provide it in the `suggested_fix` field.
|
140
|
+
"""
|
136
141
|
return None
|
{langroid-0.1.241 → langroid-0.1.244}/langroid/agent/special/lance_rag/query_planner_agent.py
RENAMED
@@ -16,6 +16,7 @@ This agent has access to two tools:
|
|
16
16
|
|
17
17
|
import logging
|
18
18
|
|
19
|
+
import langroid as lr
|
19
20
|
from langroid.agent.chat_agent import ChatAgent, ChatAgentConfig
|
20
21
|
from langroid.agent.chat_document import ChatDocument
|
21
22
|
from langroid.agent.special.lance_tools import (
|
@@ -35,6 +36,7 @@ class LanceQueryPlanAgentConfig(ChatAgentConfig):
|
|
35
36
|
doc_agent_name: str = "LanceRAG"
|
36
37
|
doc_schema: str = ""
|
37
38
|
use_tools = False
|
39
|
+
max_retries: int = 5 # max number of retries for query plan
|
38
40
|
use_functions_api = True
|
39
41
|
|
40
42
|
system_message = f"""
|
@@ -58,10 +60,13 @@ class LanceQueryPlanAgentConfig(ChatAgentConfig):
|
|
58
60
|
so the REPHRASED QUERY should NOT mention ANY FILTER fields.
|
59
61
|
The answer will answer based on documents whose CONTENTS match the QUERY,
|
60
62
|
possibly REPHRASED.
|
61
|
-
-
|
62
|
-
the answer to the original query,
|
63
|
-
|
64
|
-
|
63
|
+
- an OPTIONAL SINGLE-LINE Pandas-dataframe calculation/aggregation string
|
64
|
+
that can be used to calculate the answer to the original query,
|
65
|
+
e.g. "df["rating"].mean()",
|
66
|
+
or "df.groupby("director").mean()["rating"]",
|
67
|
+
or EMPTY string if no calc is needed.
|
68
|
+
The dataframe calc CAN refer to the `content` field.
|
69
|
+
If a DataFrame calculation is NOT needed, leave this field EMPTY.
|
65
70
|
|
66
71
|
|
67
72
|
EXAMPLE:
|
@@ -116,6 +121,8 @@ class LanceQueryPlanAgent(ChatAgent):
|
|
116
121
|
super().__init__(config)
|
117
122
|
self.config: LanceQueryPlanAgentConfig = config
|
118
123
|
self.curr_query_plan: QueryPlan | None = None
|
124
|
+
# how many times re-trying query plan in response to feedback:
|
125
|
+
self.n_retries: int = 0
|
119
126
|
self.result: str = "" # answer received from LanceRAG
|
120
127
|
# This agent should generate the QueryPlanTool
|
121
128
|
# as well as handle it for validation
|
@@ -125,6 +132,8 @@ class LanceQueryPlanAgent(ChatAgent):
|
|
125
132
|
def query_plan(self, msg: QueryPlanTool) -> str:
|
126
133
|
"""Valid, forward to RAG Agent"""
|
127
134
|
# save, to be used to assemble QueryPlanResultTool
|
135
|
+
if len(msg.plan.dataframe_calc.split("\n")) > 1:
|
136
|
+
return "DATAFRAME CALCULATION must be a SINGLE LINE; Retry the `query_plan`"
|
128
137
|
self.curr_query_plan = msg.plan
|
129
138
|
return PASS_TO + self.config.doc_agent_name
|
130
139
|
|
@@ -132,7 +141,8 @@ class LanceQueryPlanAgent(ChatAgent):
|
|
132
141
|
"""Process Critic feedback on QueryPlan + Answer from RAG Agent"""
|
133
142
|
# We should have saved answer in self.result by this time,
|
134
143
|
# since this Agent seeks feedback only after receiving RAG answer.
|
135
|
-
if msg.
|
144
|
+
if msg.suggested_fix == "":
|
145
|
+
self.n_retries = 0
|
136
146
|
# This means the Query Plan or Result is good, as judged by Critic
|
137
147
|
if self.result == "":
|
138
148
|
# This was feedback for query with no result
|
@@ -141,9 +151,16 @@ class LanceQueryPlanAgent(ChatAgent):
|
|
141
151
|
return NO_ANSWER
|
142
152
|
else: # non-empty and non-null answer
|
143
153
|
return DONE + " " + self.result
|
154
|
+
self.n_retries += 1
|
155
|
+
if self.n_retries >= self.config.max_retries:
|
156
|
+
# bail out to avoid infinite loop
|
157
|
+
self.n_retries = 0
|
158
|
+
return DONE + " " + NO_ANSWER
|
144
159
|
return f"""
|
145
|
-
here is FEEDBACK about your QUERY PLAN
|
146
|
-
|
160
|
+
here is FEEDBACK about your QUERY PLAN, and a SUGGESTED FIX.
|
161
|
+
Modify the QUERY PLAN if needed:
|
162
|
+
FEEDBACK: {msg.feedback}
|
163
|
+
SUGGESTED FIX: {msg.suggested_fix}
|
147
164
|
"""
|
148
165
|
|
149
166
|
def handle_message_fallback(
|
@@ -177,4 +194,14 @@ class LanceQueryPlanAgent(ChatAgent):
|
|
177
194
|
response_tmpl.metadata.recipient = self.config.critic_name
|
178
195
|
self.curr_query_plan = None # reset
|
179
196
|
return response_tmpl
|
197
|
+
if (
|
198
|
+
isinstance(msg, ChatDocument)
|
199
|
+
and not self.has_tool_message_attempt(msg)
|
200
|
+
and msg.metadata.sender == lr.Entity.LLM
|
201
|
+
):
|
202
|
+
# remind LLM to use the QueryPlanFeedbackTool
|
203
|
+
return """
|
204
|
+
You forgot to use the `query_plan` tool/function.
|
205
|
+
Re-try your response using the `query_plan` tool/function.
|
206
|
+
"""
|
180
207
|
return None
|
@@ -40,5 +40,9 @@ class QueryPlanAnswerTool(ToolMessage):
|
|
40
40
|
|
41
41
|
class QueryPlanFeedbackTool(ToolMessage):
|
42
42
|
request = "query_plan_feedback"
|
43
|
-
purpose = "
|
43
|
+
purpose = """
|
44
|
+
To give <feedback> regarding the query plan,
|
45
|
+
along with a <suggested_fix> if any (empty string if no fix is suggested).
|
46
|
+
"""
|
44
47
|
feedback: str
|
48
|
+
suggested_fix: str
|
@@ -71,6 +71,7 @@ class OpenAIChatModel(str, Enum):
|
|
71
71
|
GPT4 = "gpt-4"
|
72
72
|
GPT4_32K = "gpt-4-32k"
|
73
73
|
GPT4_TURBO = "gpt-4-turbo"
|
74
|
+
GPT4o = "gpt-4o"
|
74
75
|
|
75
76
|
|
76
77
|
class OpenAICompletionModel(str, Enum):
|
@@ -86,6 +87,7 @@ _context_length: Dict[str, int] = {
|
|
86
87
|
OpenAIChatModel.GPT4: 8192,
|
87
88
|
OpenAIChatModel.GPT4_32K: 32_768,
|
88
89
|
OpenAIChatModel.GPT4_TURBO: 128_000,
|
90
|
+
OpenAIChatModel.GPT4o: 128_000,
|
89
91
|
OpenAICompletionModel.TEXT_DA_VINCI_003: 4096,
|
90
92
|
}
|
91
93
|
|
@@ -95,10 +97,12 @@ _cost_per_1k_tokens: Dict[str, Tuple[float, float]] = {
|
|
95
97
|
OpenAIChatModel.GPT3_5_TURBO: (0.001, 0.002),
|
96
98
|
OpenAIChatModel.GPT4: (0.03, 0.06), # 8K context
|
97
99
|
OpenAIChatModel.GPT4_TURBO: (0.01, 0.03), # 128K context
|
100
|
+
OpenAIChatModel.GPT4o: (0.005, 0.015), # 128K context
|
98
101
|
}
|
99
102
|
|
100
103
|
|
101
104
|
openAIChatModelPreferenceList = [
|
105
|
+
OpenAIChatModel.GPT4o,
|
102
106
|
OpenAIChatModel.GPT4_TURBO,
|
103
107
|
OpenAIChatModel.GPT4,
|
104
108
|
OpenAIChatModel.GPT3_5_TURBO,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "langroid"
|
3
|
-
version = "0.1.
|
3
|
+
version = "0.1.244"
|
4
4
|
description = "Harness LLMs with Multi-Agent Programming"
|
5
5
|
authors = ["Prasad Chalasani <pchalasani@gmail.com>"]
|
6
6
|
readme = "README.md"
|
@@ -90,7 +90,7 @@ grpcio = "^1.62.1"
|
|
90
90
|
metaphor-python = {version = "^0.1.23", optional = true}
|
91
91
|
chainlit = {version = "^1.0.400", optional = true}
|
92
92
|
python-socketio = {version="^5.11.0", optional=true}
|
93
|
-
duckduckgo-search = "^
|
93
|
+
duckduckgo-search = "^6.0.0"
|
94
94
|
huggingface-hub = {version="^0.21.2", optional=true}
|
95
95
|
pdf2image = "^1.17.0"
|
96
96
|
pytesseract = "^0.3.10"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
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.1.241 → langroid-0.1.244}/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
|
{langroid-0.1.241 → langroid-0.1.244}/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
|
{langroid-0.1.241 → langroid-0.1.244}/langroid/language_models/prompt_formatter/hf_formatter.py
RENAMED
File without changes
|
{langroid-0.1.241 → langroid-0.1.244}/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
|