langroid 0.1.245__py3-none-any.whl → 0.1.246__py3-none-any.whl
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/agent/callbacks/chainlit.py +5 -4
- langroid/agent/chat_document.py +8 -3
- langroid/agent/special/lance_rag/critic_agent.py +8 -4
- langroid/agent/special/lance_rag/query_planner_agent.py +6 -1
- langroid/agent/special/table_chat_agent.py +7 -0
- {langroid-0.1.245.dist-info → langroid-0.1.246.dist-info}/METADATA +1 -1
- {langroid-0.1.245.dist-info → langroid-0.1.246.dist-info}/RECORD +9 -9
- {langroid-0.1.245.dist-info → langroid-0.1.246.dist-info}/LICENSE +0 -0
- {langroid-0.1.245.dist-info → langroid-0.1.246.dist-info}/WHEEL +0 -0
@@ -579,17 +579,18 @@ class ChainlitTaskCallbacks(ChainlitAgentCallbacks):
|
|
579
579
|
top-level agent"""
|
580
580
|
|
581
581
|
super().__init__(task.agent, msg, config)
|
582
|
-
|
582
|
+
self._inject_callbacks(task)
|
583
583
|
self.task = task
|
584
584
|
self.task.callbacks.show_subtask_response = self.show_subtask_response
|
585
585
|
|
586
|
-
@
|
586
|
+
@classmethod
|
587
587
|
def _inject_callbacks(
|
588
|
-
task: lr.Task, config: ChainlitCallbackConfig = ChainlitCallbackConfig()
|
588
|
+
cls, task: lr.Task, config: ChainlitCallbackConfig = ChainlitCallbackConfig()
|
589
589
|
) -> None:
|
590
590
|
# recursively apply ChainlitAgentCallbacks to agents of sub-tasks
|
591
591
|
for t in task.sub_tasks:
|
592
|
-
|
592
|
+
cls(t, config=config)
|
593
|
+
# ChainlitTaskCallbacks(t, config=config)
|
593
594
|
|
594
595
|
def show_subtask_response(
|
595
596
|
self, task: lr.Task, content: str, is_tool: bool = False
|
langroid/agent/chat_document.py
CHANGED
@@ -167,10 +167,15 @@ class ChatDocument(Document):
|
|
167
167
|
if message in ["''", '""']:
|
168
168
|
message = ""
|
169
169
|
if response.function_call is not None:
|
170
|
-
# Sometimes an OpenAI LLM may generate a function-call
|
171
|
-
#
|
172
|
-
#
|
170
|
+
# Sometimes an OpenAI LLM (esp gpt-4o) may generate a function-call
|
171
|
+
# with odditities:
|
172
|
+
# (a) the `name` is set, as well as `arugments.request` is set,
|
173
|
+
# and in langroid we use the `request` value as the `name`.
|
174
|
+
# In this case we override the `name` with the `request` value.
|
175
|
+
# (b) the `name` looks like "functions blah" or just "functions"
|
176
|
+
# In this case we strip the "functions" part.
|
173
177
|
fc = response.function_call
|
178
|
+
fc.name = fc.name.replace("functions", "").strip()
|
174
179
|
if fc.arguments is not None:
|
175
180
|
request = fc.arguments.get("request")
|
176
181
|
if request is not None and request != "":
|
@@ -50,10 +50,10 @@ class QueryPlanCriticConfig(LanceQueryPlanAgentConfig):
|
|
50
50
|
In general the REPHRASED QUERY should be relied upon to match the CONTENT
|
51
51
|
of the docs. Thus the REPHRASED QUERY itself acts like a
|
52
52
|
SEMANTIC/LEXICAL/FUZZY FILTER since the Assistant is able to use it to match
|
53
|
-
the CONTENT of the docs in various ways (semantic, lexical, fuzzy, etc.).
|
54
|
-
|
55
|
-
|
56
|
-
- ANSWER
|
53
|
+
the CONTENT of the docs in various ways (semantic, lexical, fuzzy, etc.).
|
54
|
+
- DATAFRAME CALCULATION, which must be a SINGLE LINE calculation (or empty),
|
55
|
+
[NOTE ==> This calculation is applied AFTER the FILTER and REPHRASED QUERY.],
|
56
|
+
- ANSWER received 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:
|
59
59
|
- CANNOT appear in a FILTER,
|
@@ -88,6 +88,10 @@ class QueryPlanCriticConfig(LanceQueryPlanAgentConfig):
|
|
88
88
|
- If the REPHRASED QUERY looks correct, then check if the FILTER makes sense.
|
89
89
|
REMEMBER: A filter should ONLY be used if EXPLICITLY REQUIRED BY THE QUERY.
|
90
90
|
|
91
|
+
|
92
|
+
IMPORTANT!! The DATAFRAME CALCULATION is done AFTER applying the
|
93
|
+
FILTER and REPHRASED QUERY! Keep this in mind when evaluating
|
94
|
+
the correctness of the DATAFRAME CALCULATION.
|
91
95
|
|
92
96
|
ALWAYS use `query_plan_feedback` tool/fn to present your feedback
|
93
97
|
in the `feedback` field, and if any fix is suggested,
|
@@ -67,6 +67,9 @@ class LanceQueryPlanAgentConfig(ChatAgentConfig):
|
|
67
67
|
or EMPTY string if no calc is needed.
|
68
68
|
The dataframe calc CAN refer to the `content` field.
|
69
69
|
If a DataFrame calculation is NOT needed, leave this field EMPTY.
|
70
|
+
|
71
|
+
IMPORTANT: The DataFrame `df` in this calculation is the result of
|
72
|
+
applying the FILTER AND REPHRASED QUERY to the documents.
|
70
73
|
|
71
74
|
|
72
75
|
EXAMPLE:
|
@@ -87,7 +90,9 @@ class LanceQueryPlanAgentConfig(ChatAgentConfig):
|
|
87
90
|
ASSISTANT does not know about them and only uses the query to
|
88
91
|
match the CONTENT of the docs.]
|
89
92
|
DATAFRAME CALCULATION: "df["num_deaths"].sum()"
|
90
|
-
|
93
|
+
NOTE!!! The DataFrame `df` in this calculation is the result of
|
94
|
+
applying the FILTER AND REPHRASED QUERY to the documents,
|
95
|
+
hence this computation will give the total deaths in shoplifting crimes.
|
91
96
|
------------- END OF EXAMPLE ----------------
|
92
97
|
|
93
98
|
The FILTER must be a SQL-like condition, e.g.
|
@@ -143,6 +143,13 @@ class PandasEvalTool(ToolMessage):
|
|
143
143
|
cls(expression="df[(df['gender'] == 'Male')]['income'].mean()"),
|
144
144
|
]
|
145
145
|
|
146
|
+
@classmethod
|
147
|
+
def instructions(cls) -> str:
|
148
|
+
return """
|
149
|
+
Use the `pandas_eval` tool/function to evaluate a pandas expression
|
150
|
+
involving the dataframe 'df' to answer the user's question.
|
151
|
+
"""
|
152
|
+
|
146
153
|
|
147
154
|
class TableChatAgent(ChatAgent):
|
148
155
|
"""
|
@@ -3,9 +3,9 @@ langroid/agent/__init__.py,sha256=_D8dxnfdr92ch1CIrUkKjrB5HVvsQdn62b1Fb2kBxV8,78
|
|
3
3
|
langroid/agent/base.py,sha256=H1Fk9kJKr-7I1GgbmaflumG7so6yGmwl7AVTgU7PyeM,35210
|
4
4
|
langroid/agent/batch.py,sha256=feRA_yRG768ElOQjrKEefcRv6Aefd_yY7qktuYUQDwc,10040
|
5
5
|
langroid/agent/callbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
langroid/agent/callbacks/chainlit.py,sha256=
|
6
|
+
langroid/agent/callbacks/chainlit.py,sha256=uIfdmoOKIfzBVeM2ce0V5SCfHjcvYyaz13dfjFXCEN4,21020
|
7
7
|
langroid/agent/chat_agent.py,sha256=X5uVMm9qdw3j-FRf4hbN8k8ByaSdtQCTuU8olKE0sbs,38750
|
8
|
-
langroid/agent/chat_document.py,sha256=
|
8
|
+
langroid/agent/chat_document.py,sha256=1ug58JXV3PEGjzRU9vQPjdZbRtza73ZFZksNwWBPziQ,9285
|
9
9
|
langroid/agent/helpers.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
10
|
langroid/agent/junk,sha256=LxfuuW7Cijsg0szAzT81OjWWv1PMNI-6w_-DspVIO2s,339
|
11
11
|
langroid/agent/openai_assistant.py,sha256=kIVDI4r-xGvplLU5s0nShPVHs6Jq-wOsfWE0kcMhAdQ,33056
|
@@ -13,9 +13,9 @@ langroid/agent/special/__init__.py,sha256=NG0JkB5y4K0bgnd9Q9UIvFExun3uTfVOWEVLVy
|
|
13
13
|
langroid/agent/special/doc_chat_agent.py,sha256=LwWNb_1s5n9rOk9OpOFPuuY1VnVX5DjzQmPwBanKRrM,53763
|
14
14
|
langroid/agent/special/lance_doc_chat_agent.py,sha256=USp0U3eTaJzwF_3bdqE7CedSLbaqAi2tm-VzygcyLaA,10175
|
15
15
|
langroid/agent/special/lance_rag/__init__.py,sha256=QTbs0IVE2ZgDg8JJy1zN97rUUg4uEPH7SLGctFNumk4,174
|
16
|
-
langroid/agent/special/lance_rag/critic_agent.py,sha256=
|
16
|
+
langroid/agent/special/lance_rag/critic_agent.py,sha256=OsOcpcU_AmU2MagpZ5X5yxFeXyteKN9QJMzJGqIITig,6871
|
17
17
|
langroid/agent/special/lance_rag/lance_rag_task.py,sha256=l_HQgrYY-CX2FwIsS961aEF3bYog3GDYo98fj0C0mSk,2889
|
18
|
-
langroid/agent/special/lance_rag/query_planner_agent.py,sha256=
|
18
|
+
langroid/agent/special/lance_rag/query_planner_agent.py,sha256=M2ry4PL_UkAzDNFvdl_Kqb6YtOnWqqA9Qz361AAb_b4,9584
|
19
19
|
langroid/agent/special/lance_tools.py,sha256=btMwKdcT8RdwAjmzbtN1xxm3s1H7ipO9GSpUamryYx8,1456
|
20
20
|
langroid/agent/special/neo4j/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
21
|
langroid/agent/special/neo4j/csv_kg_chat.py,sha256=koL3sKtHm3aRkLTiARs54ngrcU3lOR1WaLLc_i8rWOU,6374
|
@@ -31,7 +31,7 @@ langroid/agent/special/sql/utils/description_extractors.py,sha256=RZ2R3DmASxB1ij
|
|
31
31
|
langroid/agent/special/sql/utils/populate_metadata.py,sha256=x2OMKfmIBnJESBG3qKt6gvr3H3L4ZQcoxHfNdWfHjZs,2987
|
32
32
|
langroid/agent/special/sql/utils/system_message.py,sha256=qKLHkvQWRQodTtPLPxr1GSLUYUFASZU8x-ybV67cB68,1885
|
33
33
|
langroid/agent/special/sql/utils/tools.py,sha256=6uB2424SLtmapui9ggcEr0ZTiB6_dL1-JRGgN8RK9Js,1332
|
34
|
-
langroid/agent/special/table_chat_agent.py,sha256=
|
34
|
+
langroid/agent/special/table_chat_agent.py,sha256=v8gRYj5frhYgfCSzmwL1DMmvyC5Qb5z_Ira_fwld5vk,9024
|
35
35
|
langroid/agent/task.py,sha256=b_d46txohISETxXJoWpmIX0hinvt1wjHbK08LZRBEz8,54020
|
36
36
|
langroid/agent/tool_message.py,sha256=2kPsQUwi3ZzINTUNj10huKnZLjLp5SXmefacTHx8QDc,8304
|
37
37
|
langroid/agent/tools/__init__.py,sha256=q-maq3k2BXhPAU99G0H6-j_ozoRvx15I1RFpPVicQIU,304
|
@@ -121,7 +121,7 @@ langroid/vector_store/meilisearch.py,sha256=d2huA9P-NoYRuAQ9ZeXJmMKr7ry8u90RUSR2
|
|
121
121
|
langroid/vector_store/momento.py,sha256=9cui31TTrILid2KIzUpBkN2Ey3g_CZWOQVdaFsA4Ors,10045
|
122
122
|
langroid/vector_store/qdrant_cloud.py,sha256=3im4Mip0QXLkR6wiqVsjV1QvhSElfxdFSuDKddBDQ-4,188
|
123
123
|
langroid/vector_store/qdrantdb.py,sha256=sk5Qb2ZNbooi0rorsMuqIMokF7WADw6PJ0D6goM2XBw,16802
|
124
|
-
langroid-0.1.
|
125
|
-
langroid-0.1.
|
126
|
-
langroid-0.1.
|
127
|
-
langroid-0.1.
|
124
|
+
langroid-0.1.246.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
|
125
|
+
langroid-0.1.246.dist-info/METADATA,sha256=ZG2s9al3tSU4jkDPkjCySISHeNrThigZxy0jZ5vQlIs,49163
|
126
|
+
langroid-0.1.246.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
127
|
+
langroid-0.1.246.dist-info/RECORD,,
|
File without changes
|
File without changes
|