langroid 0.1.250__tar.gz → 0.1.252__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 (130) hide show
  1. {langroid-0.1.250 → langroid-0.1.252}/PKG-INFO +1 -1
  2. {langroid-0.1.250 → langroid-0.1.252}/langroid/__init__.py +6 -1
  3. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/base.py +53 -14
  4. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/chat_agent.py +9 -11
  5. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/lance_rag/critic_agent.py +7 -1
  6. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/lance_rag/query_planner_agent.py +1 -1
  7. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/task.py +204 -76
  8. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/tool_message.py +4 -1
  9. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/tools/recipient_tool.py +17 -9
  10. langroid-0.1.252/langroid/exceptions.py +3 -0
  11. {langroid-0.1.250 → langroid-0.1.252}/langroid/mytypes.py +12 -0
  12. langroid-0.1.252/langroid/parsing/routing.py +27 -0
  13. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/configuration.py +1 -0
  14. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/system.py +20 -0
  15. {langroid-0.1.250 → langroid-0.1.252}/pyproject.toml +1 -1
  16. {langroid-0.1.250 → langroid-0.1.252}/LICENSE +0 -0
  17. {langroid-0.1.250 → langroid-0.1.252}/README.md +0 -0
  18. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/__init__.py +0 -0
  19. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/batch.py +0 -0
  20. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/callbacks/__init__.py +0 -0
  21. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/callbacks/chainlit.py +0 -0
  22. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/chat_document.py +0 -0
  23. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/helpers.py +0 -0
  24. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/junk +0 -0
  25. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/openai_assistant.py +0 -0
  26. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/__init__.py +0 -0
  27. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/doc_chat_agent.py +0 -0
  28. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
  29. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/lance_rag/__init__.py +0 -0
  30. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
  31. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/lance_tools.py +0 -0
  32. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/neo4j/__init__.py +0 -0
  33. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
  34. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
  35. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/neo4j/utils/__init__.py +0 -0
  36. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/neo4j/utils/system_message.py +0 -0
  37. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/relevance_extractor_agent.py +0 -0
  38. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/retriever_agent.py +0 -0
  39. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/sql/__init__.py +0 -0
  40. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
  41. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/sql/utils/__init__.py +0 -0
  42. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
  43. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
  44. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/sql/utils/system_message.py +0 -0
  45. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/sql/utils/tools.py +0 -0
  46. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/special/table_chat_agent.py +0 -0
  47. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/tools/__init__.py +0 -0
  48. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
  49. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/tools/extract_tool.py +0 -0
  50. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/tools/generator_tool.py +0 -0
  51. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/tools/google_search_tool.py +0 -0
  52. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/tools/metaphor_search_tool.py +0 -0
  53. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/tools/retrieval_tool.py +0 -0
  54. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/tools/run_python_code.py +0 -0
  55. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent/tools/segment_extract_tool.py +0 -0
  56. {langroid-0.1.250 → langroid-0.1.252}/langroid/agent_config.py +0 -0
  57. {langroid-0.1.250 → langroid-0.1.252}/langroid/cachedb/__init__.py +0 -0
  58. {langroid-0.1.250 → langroid-0.1.252}/langroid/cachedb/base.py +0 -0
  59. {langroid-0.1.250 → langroid-0.1.252}/langroid/cachedb/momento_cachedb.py +0 -0
  60. {langroid-0.1.250 → langroid-0.1.252}/langroid/cachedb/redis_cachedb.py +0 -0
  61. {langroid-0.1.250 → langroid-0.1.252}/langroid/embedding_models/__init__.py +0 -0
  62. {langroid-0.1.250 → langroid-0.1.252}/langroid/embedding_models/base.py +0 -0
  63. {langroid-0.1.250 → langroid-0.1.252}/langroid/embedding_models/clustering.py +0 -0
  64. {langroid-0.1.250 → langroid-0.1.252}/langroid/embedding_models/models.py +0 -0
  65. {langroid-0.1.250 → langroid-0.1.252}/langroid/embedding_models/protoc/__init__.py +0 -0
  66. {langroid-0.1.250 → langroid-0.1.252}/langroid/embedding_models/protoc/embeddings.proto +0 -0
  67. {langroid-0.1.250 → langroid-0.1.252}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
  68. {langroid-0.1.250 → langroid-0.1.252}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
  69. {langroid-0.1.250 → langroid-0.1.252}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
  70. {langroid-0.1.250 → langroid-0.1.252}/langroid/embedding_models/remote_embeds.py +0 -0
  71. {langroid-0.1.250 → langroid-0.1.252}/langroid/language_models/__init__.py +0 -0
  72. {langroid-0.1.250 → langroid-0.1.252}/langroid/language_models/azure_openai.py +0 -0
  73. {langroid-0.1.250 → langroid-0.1.252}/langroid/language_models/base.py +0 -0
  74. {langroid-0.1.250 → langroid-0.1.252}/langroid/language_models/config.py +0 -0
  75. {langroid-0.1.250 → langroid-0.1.252}/langroid/language_models/openai_assistants.py +0 -0
  76. {langroid-0.1.250 → langroid-0.1.252}/langroid/language_models/openai_gpt.py +0 -0
  77. {langroid-0.1.250 → langroid-0.1.252}/langroid/language_models/prompt_formatter/__init__.py +0 -0
  78. {langroid-0.1.250 → langroid-0.1.252}/langroid/language_models/prompt_formatter/base.py +0 -0
  79. {langroid-0.1.250 → langroid-0.1.252}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
  80. {langroid-0.1.250 → langroid-0.1.252}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
  81. {langroid-0.1.250 → langroid-0.1.252}/langroid/language_models/utils.py +0 -0
  82. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/__init__.py +0 -0
  83. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/agent_chats.py +0 -0
  84. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/code-parsing.md +0 -0
  85. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/code_parser.py +0 -0
  86. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/config.py +0 -0
  87. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/document_parser.py +0 -0
  88. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/image_text.py +0 -0
  89. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/para_sentence_split.py +0 -0
  90. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/parse_json.py +0 -0
  91. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/parser.py +0 -0
  92. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/repo_loader.py +0 -0
  93. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/search.py +0 -0
  94. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/spider.py +0 -0
  95. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/table_loader.py +0 -0
  96. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/url_loader.py +0 -0
  97. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/url_loader_cookies.py +0 -0
  98. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/urls.py +0 -0
  99. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/utils.py +0 -0
  100. {langroid-0.1.250 → langroid-0.1.252}/langroid/parsing/web_search.py +0 -0
  101. {langroid-0.1.250 → langroid-0.1.252}/langroid/prompts/__init__.py +0 -0
  102. {langroid-0.1.250 → langroid-0.1.252}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
  103. {langroid-0.1.250 → langroid-0.1.252}/langroid/prompts/dialog.py +0 -0
  104. {langroid-0.1.250 → langroid-0.1.252}/langroid/prompts/prompts_config.py +0 -0
  105. {langroid-0.1.250 → langroid-0.1.252}/langroid/prompts/templates.py +0 -0
  106. {langroid-0.1.250 → langroid-0.1.252}/langroid/prompts/transforms.py +0 -0
  107. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/__init__.py +0 -0
  108. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/algorithms/__init__.py +0 -0
  109. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/algorithms/graph.py +0 -0
  110. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/constants.py +0 -0
  111. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/docker.py +0 -0
  112. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/globals.py +0 -0
  113. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/llms/__init__.py +0 -0
  114. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/llms/strings.py +0 -0
  115. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/logging.py +0 -0
  116. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/output/__init__.py +0 -0
  117. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/output/printing.py +0 -0
  118. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/output/status.py +0 -0
  119. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/pandas_utils.py +0 -0
  120. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/pydantic_utils.py +0 -0
  121. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/web/__init__.py +0 -0
  122. {langroid-0.1.250 → langroid-0.1.252}/langroid/utils/web/login.py +0 -0
  123. {langroid-0.1.250 → langroid-0.1.252}/langroid/vector_store/__init__.py +0 -0
  124. {langroid-0.1.250 → langroid-0.1.252}/langroid/vector_store/base.py +0 -0
  125. {langroid-0.1.250 → langroid-0.1.252}/langroid/vector_store/chromadb.py +0 -0
  126. {langroid-0.1.250 → langroid-0.1.252}/langroid/vector_store/lancedb.py +0 -0
  127. {langroid-0.1.250 → langroid-0.1.252}/langroid/vector_store/meilisearch.py +0 -0
  128. {langroid-0.1.250 → langroid-0.1.252}/langroid/vector_store/momento.py +0 -0
  129. {langroid-0.1.250 → langroid-0.1.252}/langroid/vector_store/qdrant_cloud.py +0 -0
  130. {langroid-0.1.250 → langroid-0.1.252}/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.250
3
+ Version: 0.1.252
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  License: MIT
6
6
  Author: Prasad Chalasani
@@ -41,7 +41,7 @@ from .agent.chat_agent import (
41
41
  ChatAgentConfig,
42
42
  )
43
43
 
44
- from .agent.task import Task
44
+ from .agent.task import Task, TaskConfig
45
45
 
46
46
  try:
47
47
  from .agent.callbacks.chainlit import (
@@ -64,8 +64,11 @@ from .mytypes import (
64
64
  Entity,
65
65
  )
66
66
 
67
+ from .exceptions import InfiniteLoopException
68
+
67
69
  __all__ = [
68
70
  "mytypes",
71
+ "exceptions",
69
72
  "utils",
70
73
  "parsing",
71
74
  "prompts",
@@ -82,6 +85,7 @@ __all__ = [
82
85
  "ChatDocument",
83
86
  "ChatDocMetaData",
84
87
  "Task",
88
+ "TaskConfig",
85
89
  "DocMetaData",
86
90
  "Document",
87
91
  "Entity",
@@ -89,6 +93,7 @@ __all__ = [
89
93
  "run_batch_tasks",
90
94
  "llm_response_batch",
91
95
  "agent_response_batch",
96
+ "InfiniteLoopException",
92
97
  ]
93
98
  if chainlit_available:
94
99
  __all__.extend(
@@ -2,6 +2,7 @@ import asyncio
2
2
  import inspect
3
3
  import json
4
4
  import logging
5
+ import re
5
6
  from abc import ABC
6
7
  from contextlib import ExitStack
7
8
  from types import SimpleNamespace
@@ -19,7 +20,7 @@ from typing import (
19
20
  no_type_check,
20
21
  )
21
22
 
22
- from pydantic import BaseSettings, ValidationError
23
+ from pydantic import BaseSettings, ValidationError, validator
23
24
  from rich import print
24
25
  from rich.console import Console
25
26
  from rich.markup import escape
@@ -64,6 +65,15 @@ class AgentConfig(BaseSettings):
64
65
  prompts: Optional[PromptsConfig] = PromptsConfig()
65
66
  show_stats: bool = True # show token usage/cost stats?
66
67
 
68
+ @validator("name")
69
+ def check_name_alphanum(cls, v: str) -> str:
70
+ if not re.match(r"^[a-zA-Z0-9_-]+$", v):
71
+ raise ValueError(
72
+ "The name must only contain alphanumeric characters, "
73
+ "underscores, or hyphens, with no spaces"
74
+ )
75
+ return v
76
+
67
77
 
68
78
  def noop_fn(*args: List[Any], **kwargs: Dict[str, Any]) -> None:
69
79
  pass
@@ -87,6 +97,7 @@ class Agent(ABC):
87
97
  self.llm_tools_map: Dict[str, Type[ToolMessage]] = {}
88
98
  self.llm_tools_handled: Set[str] = set()
89
99
  self.llm_tools_usable: Set[str] = set()
100
+ self.interactive: bool | None = None
90
101
  self.total_llm_token_cost = 0.0
91
102
  self.total_llm_token_usage = 0
92
103
  self.token_stats_str = ""
@@ -223,8 +234,8 @@ class Agent(ABC):
223
234
  ):
224
235
  setattr(self, tool, lambda obj: obj.response(self))
225
236
 
226
- if hasattr(message_class, "handle_message_fallback") and inspect.isfunction(
227
- message_class.handle_message_fallback
237
+ if hasattr(message_class, "handle_message_fallback") and (
238
+ inspect.isfunction(message_class.handle_message_fallback)
228
239
  ):
229
240
  setattr(
230
241
  self,
@@ -279,9 +290,9 @@ class Agent(ABC):
279
290
  ]
280
291
  return "\n\n".join(sample_convo)
281
292
 
282
- def agent_response_template(self) -> ChatDocument:
293
+ def create_agent_response(self, content: str | None = None) -> ChatDocument:
283
294
  """Template for agent_response."""
284
- return self._response_template(Entity.AGENT)
295
+ return self._response_template(Entity.AGENT, content)
285
296
 
286
297
  async def agent_response_async(
287
298
  self,
@@ -342,19 +353,19 @@ class Agent(ABC):
342
353
  ),
343
354
  )
344
355
 
345
- def _response_template(self, e: Entity) -> ChatDocument:
356
+ def _response_template(self, e: Entity, content: str | None = None) -> ChatDocument:
346
357
  """Template for response from entity `e`."""
347
358
  return ChatDocument(
348
- content="",
359
+ content=content or "",
349
360
  tool_messages=[],
350
361
  metadata=ChatDocMetaData(
351
362
  source=e, sender=e, sender_name=self.config.name, tool_ids=[]
352
363
  ),
353
364
  )
354
365
 
355
- def user_response_template(self) -> ChatDocument:
366
+ def create_user_response(self, content: str | None = None) -> ChatDocument:
356
367
  """Template for user_response."""
357
- return self._response_template(Entity.USER)
368
+ return self._response_template(Entity.USER, content)
358
369
 
359
370
  async def user_response_async(
360
371
  self,
@@ -377,11 +388,21 @@ class Agent(ABC):
377
388
  (str) User response, packaged as a ChatDocument
378
389
 
379
390
  """
380
- if self.default_human_response is not None:
391
+
392
+ # When msg explicitly addressed to user, this means an actual human response
393
+ # is being sought.
394
+ need_human_response = (
395
+ isinstance(msg, ChatDocument) and msg.metadata.recipient == Entity.USER
396
+ )
397
+
398
+ interactive = (
399
+ self.interactive if self.interactive is not None else settings.interactive
400
+ )
401
+ if self.default_human_response is not None and not need_human_response:
381
402
  # useful for automated testing
382
403
  user_msg = self.default_human_response
383
- elif not settings.interactive:
384
- user_msg = ""
404
+ elif not interactive and not need_human_response:
405
+ return None
385
406
  else:
386
407
  if self.callbacks.get_user_response is not None:
387
408
  # ask user with empty prompt: no need for prompt
@@ -440,9 +461,9 @@ class Agent(ABC):
440
461
 
441
462
  return True
442
463
 
443
- def llm_response_template(self) -> ChatDocument:
464
+ def create_llm_response(self, content: str | None = None) -> ChatDocument:
444
465
  """Template for llm_response."""
445
- return self._response_template(Entity.LLM)
466
+ return self._response_template(Entity.LLM, content)
446
467
 
447
468
  @no_type_check
448
469
  async def llm_response_async(
@@ -736,6 +757,24 @@ class Agent(ABC):
736
757
 
737
758
  def _get_one_tool_message(self, json_str: str) -> Optional[ToolMessage]:
738
759
  json_data = json.loads(json_str)
760
+ # check if the json_data contains a "properties" field
761
+ # which further contains the actual tool-call
762
+ # (some weak LLMs do this). E.g. gpt-4o sometimes generates this:
763
+ # TOOL: {
764
+ # "type": "object",
765
+ # "properties": {
766
+ # "request": "square",
767
+ # "number": 9
768
+ # },
769
+ # "required": [
770
+ # "number",
771
+ # "request"
772
+ # ]
773
+ # }
774
+
775
+ properties = json_data.get("properties")
776
+ if properties is not None:
777
+ json_data = properties
739
778
  request = json_data.get("request")
740
779
  if (
741
780
  request is None
@@ -273,10 +273,11 @@ class ChatAgent(Agent):
273
273
  example = "" if self.config.use_tools else (msg_cls.usage_example())
274
274
  if example != "":
275
275
  example = "EXAMPLE: " + example
276
+ class_instructions = msg_cls.instructions()
276
277
  guidance = (
277
278
  ""
278
- if msg_cls.instructions() == ""
279
- else ("GUIDANCE: " + msg_cls.instructions())
279
+ if class_instructions == ""
280
+ else ("GUIDANCE: " + class_instructions)
280
281
  )
281
282
  if guidance == "" and example == "":
282
283
  continue
@@ -783,23 +784,20 @@ class ChatAgent(Agent):
783
784
  if self.llm is None:
784
785
  return
785
786
  if not citation_only and (not self.llm.get_stream() or is_cached):
786
- # We expect response to be LLMResponse in this context
787
- if not isinstance(response, LLMResponse):
788
- raise ValueError(
789
- "Expected response to be LLMResponse, but got "
790
- f"{type(response)} instead."
791
- )
792
787
  # We would have already displayed the msg "live" ONLY if
793
788
  # streaming was enabled, AND we did not find a cached response.
794
789
  # If we are here, it means the response has not yet been displayed.
795
790
  cached = f"[red]{self.indent}(cached)[/red]" if is_cached else ""
796
791
  if not settings.quiet:
792
+ chat_doc = (
793
+ response
794
+ if isinstance(response, ChatDocument)
795
+ else ChatDocument.from_LLMResponse(response, displayed=True)
796
+ )
797
797
  print(cached + "[green]" + escape(str(response)))
798
798
  self.callbacks.show_llm_response(
799
799
  content=str(response),
800
- is_tool=self.has_tool_message_attempt(
801
- ChatDocument.from_LLMResponse(response, displayed=True),
802
- ),
800
+ is_tool=self.has_tool_message_attempt(chat_doc),
803
801
  cached=is_cached,
804
802
  )
805
803
  if isinstance(response, LLMResponse):
@@ -70,13 +70,19 @@ class QueryPlanCriticConfig(LanceQueryPlanAgentConfig):
70
70
  plan execution FAILED, and your feedback should say INVALID along
71
71
  with the ERROR message, `suggested_fix` that aims to help the assistant
72
72
  fix the problem (or simply equals "address the the error shown in feedback")
73
+ - Ask yourself, is the ANSWER in the expected form, e.g.
74
+ if the question is asking for the name of an ENTITY with max SIZE,
75
+ then the answer should be the ENTITY name, NOT the SIZE!!
73
76
  - If the ANSWER is in the expected form, then the QUERY PLAN is likely VALID,
74
77
  and your feedback should say VALID, with empty `suggested_fix`.
78
+ ===> HOWEVER!!! Watch out for a spurious correct-looking answer, for EXAMPLE:
79
+ the query was to find the ENTITY with a maximum SIZE,
80
+ but the dataframe calculation is find the SIZE, NOT the ENTITY!!
75
81
  - If the ANSWER is {NO_ANSWER} or of the wrong form,
76
82
  then try to DIAGNOSE the problem IN THE FOLLOWING ORDER:
77
83
  - DATAFRAME CALCULATION -- is it doing the right thing?
78
84
  Is it finding the Index of a row instead of the value in a column?
79
- Or another example: mmaybe it is finding the maximum population
85
+ Or another example: maybe it is finding the maximum population
80
86
  rather than the CITY with the maximum population?
81
87
  If you notice a problem with the DATAFRAME CALCULATION, then
82
88
  ONLY SUBMIT FEEDBACK ON THE DATAFRAME CALCULATION, and DO NOT
@@ -195,7 +195,7 @@ class LanceQueryPlanAgent(ChatAgent):
195
195
  plan=self.curr_query_plan,
196
196
  answer=self.result,
197
197
  )
198
- response_tmpl = self.agent_response_template()
198
+ response_tmpl = self.create_agent_response()
199
199
  # ... add the QueryPlanAnswerTool to the response
200
200
  # (Notice how the Agent is directly sending a tool, not the LLM)
201
201
  response_tmpl.tool_messages = [query_plan_answer_tool]