langroid 0.1.244__tar.gz → 0.1.246__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.
Files changed (127) hide show
  1. {langroid-0.1.244 → langroid-0.1.246}/PKG-INFO +1 -1
  2. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/callbacks/chainlit.py +5 -4
  3. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/chat_document.py +15 -0
  4. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/lance_rag/critic_agent.py +12 -4
  5. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/lance_rag/query_planner_agent.py +6 -1
  6. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/table_chat_agent.py +7 -0
  7. {langroid-0.1.244 → langroid-0.1.246}/pyproject.toml +1 -1
  8. {langroid-0.1.244 → langroid-0.1.246}/LICENSE +0 -0
  9. {langroid-0.1.244 → langroid-0.1.246}/README.md +0 -0
  10. {langroid-0.1.244 → langroid-0.1.246}/langroid/__init__.py +0 -0
  11. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/__init__.py +0 -0
  12. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/base.py +0 -0
  13. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/batch.py +0 -0
  14. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/callbacks/__init__.py +0 -0
  15. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/chat_agent.py +0 -0
  16. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/helpers.py +0 -0
  17. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/junk +0 -0
  18. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/openai_assistant.py +0 -0
  19. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/__init__.py +0 -0
  20. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/doc_chat_agent.py +0 -0
  21. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
  22. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/lance_rag/__init__.py +0 -0
  23. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
  24. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/lance_tools.py +0 -0
  25. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/neo4j/__init__.py +0 -0
  26. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
  27. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
  28. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/neo4j/utils/__init__.py +0 -0
  29. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/neo4j/utils/system_message.py +0 -0
  30. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/relevance_extractor_agent.py +0 -0
  31. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/retriever_agent.py +0 -0
  32. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/sql/__init__.py +0 -0
  33. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
  34. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/sql/utils/__init__.py +0 -0
  35. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
  36. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
  37. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/sql/utils/system_message.py +0 -0
  38. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/special/sql/utils/tools.py +0 -0
  39. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/task.py +0 -0
  40. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/tool_message.py +0 -0
  41. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/tools/__init__.py +0 -0
  42. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
  43. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/tools/extract_tool.py +0 -0
  44. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/tools/generator_tool.py +0 -0
  45. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/tools/google_search_tool.py +0 -0
  46. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/tools/metaphor_search_tool.py +0 -0
  47. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/tools/recipient_tool.py +0 -0
  48. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/tools/run_python_code.py +0 -0
  49. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent/tools/segment_extract_tool.py +0 -0
  50. {langroid-0.1.244 → langroid-0.1.246}/langroid/agent_config.py +0 -0
  51. {langroid-0.1.244 → langroid-0.1.246}/langroid/cachedb/__init__.py +0 -0
  52. {langroid-0.1.244 → langroid-0.1.246}/langroid/cachedb/base.py +0 -0
  53. {langroid-0.1.244 → langroid-0.1.246}/langroid/cachedb/momento_cachedb.py +0 -0
  54. {langroid-0.1.244 → langroid-0.1.246}/langroid/cachedb/redis_cachedb.py +0 -0
  55. {langroid-0.1.244 → langroid-0.1.246}/langroid/embedding_models/__init__.py +0 -0
  56. {langroid-0.1.244 → langroid-0.1.246}/langroid/embedding_models/base.py +0 -0
  57. {langroid-0.1.244 → langroid-0.1.246}/langroid/embedding_models/clustering.py +0 -0
  58. {langroid-0.1.244 → langroid-0.1.246}/langroid/embedding_models/models.py +0 -0
  59. {langroid-0.1.244 → langroid-0.1.246}/langroid/embedding_models/protoc/__init__.py +0 -0
  60. {langroid-0.1.244 → langroid-0.1.246}/langroid/embedding_models/protoc/embeddings.proto +0 -0
  61. {langroid-0.1.244 → langroid-0.1.246}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
  62. {langroid-0.1.244 → langroid-0.1.246}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
  63. {langroid-0.1.244 → langroid-0.1.246}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
  64. {langroid-0.1.244 → langroid-0.1.246}/langroid/embedding_models/remote_embeds.py +0 -0
  65. {langroid-0.1.244 → langroid-0.1.246}/langroid/language_models/__init__.py +0 -0
  66. {langroid-0.1.244 → langroid-0.1.246}/langroid/language_models/azure_openai.py +0 -0
  67. {langroid-0.1.244 → langroid-0.1.246}/langroid/language_models/base.py +0 -0
  68. {langroid-0.1.244 → langroid-0.1.246}/langroid/language_models/config.py +0 -0
  69. {langroid-0.1.244 → langroid-0.1.246}/langroid/language_models/openai_assistants.py +0 -0
  70. {langroid-0.1.244 → langroid-0.1.246}/langroid/language_models/openai_gpt.py +0 -0
  71. {langroid-0.1.244 → langroid-0.1.246}/langroid/language_models/prompt_formatter/__init__.py +0 -0
  72. {langroid-0.1.244 → langroid-0.1.246}/langroid/language_models/prompt_formatter/base.py +0 -0
  73. {langroid-0.1.244 → langroid-0.1.246}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
  74. {langroid-0.1.244 → langroid-0.1.246}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
  75. {langroid-0.1.244 → langroid-0.1.246}/langroid/language_models/utils.py +0 -0
  76. {langroid-0.1.244 → langroid-0.1.246}/langroid/mytypes.py +0 -0
  77. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/__init__.py +0 -0
  78. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/agent_chats.py +0 -0
  79. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/code-parsing.md +0 -0
  80. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/code_parser.py +0 -0
  81. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/config.py +0 -0
  82. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/document_parser.py +0 -0
  83. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/image_text.py +0 -0
  84. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/para_sentence_split.py +0 -0
  85. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/parse_json.py +0 -0
  86. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/parser.py +0 -0
  87. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/repo_loader.py +0 -0
  88. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/search.py +0 -0
  89. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/spider.py +0 -0
  90. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/table_loader.py +0 -0
  91. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/url_loader.py +0 -0
  92. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/url_loader_cookies.py +0 -0
  93. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/urls.py +0 -0
  94. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/utils.py +0 -0
  95. {langroid-0.1.244 → langroid-0.1.246}/langroid/parsing/web_search.py +0 -0
  96. {langroid-0.1.244 → langroid-0.1.246}/langroid/prompts/__init__.py +0 -0
  97. {langroid-0.1.244 → langroid-0.1.246}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
  98. {langroid-0.1.244 → langroid-0.1.246}/langroid/prompts/dialog.py +0 -0
  99. {langroid-0.1.244 → langroid-0.1.246}/langroid/prompts/prompts_config.py +0 -0
  100. {langroid-0.1.244 → langroid-0.1.246}/langroid/prompts/templates.py +0 -0
  101. {langroid-0.1.244 → langroid-0.1.246}/langroid/prompts/transforms.py +0 -0
  102. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/__init__.py +0 -0
  103. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/algorithms/__init__.py +0 -0
  104. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/algorithms/graph.py +0 -0
  105. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/configuration.py +0 -0
  106. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/constants.py +0 -0
  107. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/docker.py +0 -0
  108. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/globals.py +0 -0
  109. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/llms/__init__.py +0 -0
  110. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/llms/strings.py +0 -0
  111. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/logging.py +0 -0
  112. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/output/__init__.py +0 -0
  113. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/output/printing.py +0 -0
  114. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/output/status.py +0 -0
  115. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/pandas_utils.py +0 -0
  116. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/pydantic_utils.py +0 -0
  117. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/system.py +0 -0
  118. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/web/__init__.py +0 -0
  119. {langroid-0.1.244 → langroid-0.1.246}/langroid/utils/web/login.py +0 -0
  120. {langroid-0.1.244 → langroid-0.1.246}/langroid/vector_store/__init__.py +0 -0
  121. {langroid-0.1.244 → langroid-0.1.246}/langroid/vector_store/base.py +0 -0
  122. {langroid-0.1.244 → langroid-0.1.246}/langroid/vector_store/chromadb.py +0 -0
  123. {langroid-0.1.244 → langroid-0.1.246}/langroid/vector_store/lancedb.py +0 -0
  124. {langroid-0.1.244 → langroid-0.1.246}/langroid/vector_store/meilisearch.py +0 -0
  125. {langroid-0.1.244 → langroid-0.1.246}/langroid/vector_store/momento.py +0 -0
  126. {langroid-0.1.244 → langroid-0.1.246}/langroid/vector_store/qdrant_cloud.py +0 -0
  127. {langroid-0.1.244 → langroid-0.1.246}/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.244
3
+ Version: 0.1.246
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  License: MIT
6
6
  Author: Prasad Chalasani
@@ -579,17 +579,18 @@ class ChainlitTaskCallbacks(ChainlitAgentCallbacks):
579
579
  top-level agent"""
580
580
 
581
581
  super().__init__(task.agent, msg, config)
582
- ChainlitTaskCallbacks._inject_callbacks(task)
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
- @staticmethod
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
- ChainlitTaskCallbacks(t, config=config)
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
@@ -166,6 +166,21 @@ class ChatDocument(Document):
166
166
  message = message.strip()
167
167
  if message in ["''", '""']:
168
168
  message = ""
169
+ if response.function_call is not None:
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.
177
+ fc = response.function_call
178
+ fc.name = fc.name.replace("functions", "").strip()
179
+ if fc.arguments is not None:
180
+ request = fc.arguments.get("request")
181
+ if request is not None and request != "":
182
+ fc.name = request
183
+ fc.arguments.pop("request")
169
184
  return ChatDocument(
170
185
  content=message,
171
186
  function_call=response.function_call,
@@ -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
- - DATAFRAME CALCULATION, which must be a SINGLE LINE calculation, and
56
- - ANSWER recieved from an assistant that used this QUERY PLAN.
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,
@@ -66,6 +66,10 @@ class QueryPlanCriticConfig(LanceQueryPlanAgentConfig):
66
66
  Here is how you must examine the QUERY PLAN + ANSWER:
67
67
  - ALL filtering conditions in the original query must be EXPLICITLY
68
68
  mentioned in the FILTER, and the QUERY field should not be used for filtering.
69
+ - If the ANSWER contains an ERROR message, then this means that the query
70
+ plan execution FAILED, and your feedback should say INVALID along
71
+ with the ERROR message, `suggested_fix` that aims to help the assistant
72
+ fix the problem (or simply equals "address the the error shown in feedback")
69
73
  - If the ANSWER is in the expected form, then the QUERY PLAN is likely VALID,
70
74
  and your feedback should say VALID, with empty `suggested_fix`.
71
75
  - If the ANSWER is {NO_ANSWER} or of the wrong form,
@@ -84,6 +88,10 @@ class QueryPlanCriticConfig(LanceQueryPlanAgentConfig):
84
88
  - If the REPHRASED QUERY looks correct, then check if the FILTER makes sense.
85
89
  REMEMBER: A filter should ONLY be used if EXPLICITLY REQUIRED BY THE QUERY.
86
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.
87
95
 
88
96
  ALWAYS use `query_plan_feedback` tool/fn to present your feedback
89
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
  """
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "langroid"
3
- version = "0.1.244"
3
+ version = "0.1.246"
4
4
  description = "Harness LLMs with Multi-Agent Programming"
5
5
  authors = ["Prasad Chalasani <pchalasani@gmail.com>"]
6
6
  readme = "README.md"
File without changes
File without changes