langroid 0.37.5__tar.gz → 0.37.7__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.37.5 → langroid-0.37.7}/PKG-INFO +1 -1
- {langroid-0.37.5 → langroid-0.37.7}/langroid/language_models/base.py +21 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/language_models/openai_gpt.py +10 -0
- {langroid-0.37.5 → langroid-0.37.7}/pyproject.toml +1 -1
- {langroid-0.37.5 → langroid-0.37.7}/.gitignore +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/LICENSE +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/README.md +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/base.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/batch.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/callbacks/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/callbacks/chainlit.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/chat_agent.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/chat_document.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/openai_assistant.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/arangodb/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/arangodb/arangodb_agent.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/arangodb/system_messages.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/arangodb/tools.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/arangodb/utils.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/doc_chat_agent.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/lance_rag/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/lance_tools.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/neo4j/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/neo4j/system_messages.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/neo4j/tools.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/relevance_extractor_agent.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/retriever_agent.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/sql/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/sql/utils/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/sql/utils/system_message.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/sql/utils/tools.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/special/table_chat_agent.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/task.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/tool_message.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/tools/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/tools/file_tools.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/tools/google_search_tool.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/tools/metaphor_search_tool.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/tools/orchestration.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/tools/recipient_tool.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/tools/retrieval_tool.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/tools/rewind_tool.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/tools/segment_extract_tool.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/agent/xml_tool_message.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/cachedb/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/cachedb/base.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/cachedb/momento_cachedb.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/cachedb/redis_cachedb.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/embedding_models/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/embedding_models/base.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/embedding_models/models.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/embedding_models/protoc/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/embedding_models/protoc/embeddings.proto +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/embedding_models/remote_embeds.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/exceptions.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/language_models/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/language_models/azure_openai.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/language_models/config.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/language_models/mock_lm.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/language_models/prompt_formatter/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/language_models/prompt_formatter/base.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/language_models/utils.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/mytypes.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/agent_chats.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/code_parser.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/document_parser.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/para_sentence_split.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/parse_json.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/parser.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/pdf_utils.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/repo_loader.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/routing.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/search.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/spider.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/table_loader.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/url_loader.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/urls.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/utils.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/parsing/web_search.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/prompts/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/prompts/dialog.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/prompts/prompts_config.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/prompts/templates.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/py.typed +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/pydantic_v1/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/pydantic_v1/main.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/algorithms/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/algorithms/graph.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/configuration.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/constants.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/git_utils.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/globals.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/logging.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/object_registry.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/output/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/output/citations.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/output/printing.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/output/status.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/pandas_utils.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/pydantic_utils.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/system.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/utils/types.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/vector_store/__init__.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/vector_store/base.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/vector_store/chromadb.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/vector_store/lancedb.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/vector_store/meilisearch.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/vector_store/momento.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/vector_store/qdrantdb.py +0 -0
- {langroid-0.37.5 → langroid-0.37.7}/langroid/vector_store/weaviatedb.py +0 -0
@@ -78,6 +78,7 @@ class LLMConfig(BaseSettings):
|
|
78
78
|
# TODO: we could have a `stream_reasoning` flag here to control whether to show
|
79
79
|
# reasoning output from reasoning models
|
80
80
|
cache_config: None | CacheDBConfig = RedisCacheConfig()
|
81
|
+
thought_delimiters: Tuple[str, str] = ("<think>", "</think>")
|
81
82
|
|
82
83
|
# Dict of model -> (input/prompt cost, output/completion cost)
|
83
84
|
chat_cost_per_1k_tokens: Tuple[float, float] = (0.0, 0.0)
|
@@ -646,6 +647,26 @@ class LanguageModel(ABC):
|
|
646
647
|
total_cost += counter.cost
|
647
648
|
return total_tokens, total_cost
|
648
649
|
|
650
|
+
def get_reasoning_final(self, message: str) -> Tuple[str, str]:
|
651
|
+
"""Extract "reasoning" and "final answer" from an LLM response, if the
|
652
|
+
reasoning is found within configured delimiters, like <think>, </think>.
|
653
|
+
E.g.,
|
654
|
+
'<think> Okay, let's see, the user wants... </think> 2 + 3 = 5'
|
655
|
+
|
656
|
+
Args:
|
657
|
+
message (str): message from LLM
|
658
|
+
|
659
|
+
Returns:
|
660
|
+
Tuple[str, str]: reasoning, final answer
|
661
|
+
"""
|
662
|
+
start, end = self.config.thought_delimiters
|
663
|
+
if start in message and end in message:
|
664
|
+
parts = message.split(start)
|
665
|
+
if len(parts) > 1:
|
666
|
+
reasoning, final = parts[1].split(end)
|
667
|
+
return reasoning, final
|
668
|
+
return "", message
|
669
|
+
|
649
670
|
def followup_to_standalone(
|
650
671
|
self, chat_history: List[Tuple[str, str]], question: str
|
651
672
|
) -> str:
|
@@ -1368,6 +1368,11 @@ class OpenAIGPT(LanguageModel):
|
|
1368
1368
|
choices=[msg],
|
1369
1369
|
usage=dict(total_tokens=0),
|
1370
1370
|
)
|
1371
|
+
if reasoning == "":
|
1372
|
+
# some LLM APIs may not return a separate reasoning field,
|
1373
|
+
# and the reasoning may be included in the message content
|
1374
|
+
# within delimiters like <think> ... </think>
|
1375
|
+
reasoning, completion = self.get_reasoning_final(completion)
|
1371
1376
|
return (
|
1372
1377
|
LLMResponse(
|
1373
1378
|
message=completion,
|
@@ -1905,6 +1910,11 @@ class OpenAIGPT(LanguageModel):
|
|
1905
1910
|
message = {}
|
1906
1911
|
msg = message.get("content", "")
|
1907
1912
|
reasoning = message.get("reasoning_content", "")
|
1913
|
+
if reasoning == "" and msg is not None:
|
1914
|
+
# some LLM APIs may not return a separate reasoning field,
|
1915
|
+
# and the reasoning may be included in the message content
|
1916
|
+
# within delimiters like <think> ... </think>
|
1917
|
+
reasoning, msg = self.get_reasoning_final(msg)
|
1908
1918
|
|
1909
1919
|
if message.get("function_call") is None:
|
1910
1920
|
fun_call = None
|
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.37.5 → langroid-0.37.7}/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
|
File without changes
|
File without changes
|
{langroid-0.37.5 → langroid-0.37.7}/langroid/language_models/prompt_formatter/hf_formatter.py
RENAMED
File without changes
|
{langroid-0.37.5 → langroid-0.37.7}/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
|