langroid 0.59.8__tar.gz → 0.59.10__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.59.8 → langroid-0.59.10}/PKG-INFO +1 -1
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/relevance_extractor_agent.py +19 -12
- {langroid-0.59.8 → langroid-0.59.10}/langroid/embedding_models/models.py +67 -2
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/parse_json.py +8 -2
- {langroid-0.59.8 → langroid-0.59.10}/pyproject.toml +1 -1
- {langroid-0.59.8 → langroid-0.59.10}/.gitignore +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/LICENSE +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/README.md +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/base.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/batch.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/callbacks/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/callbacks/chainlit.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/chat_agent.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/chat_document.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/done_sequence_parser.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/openai_assistant.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/arangodb/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/arangodb/arangodb_agent.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/arangodb/system_messages.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/arangodb/tools.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/arangodb/utils.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/doc_chat_agent.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/doc_chat_task.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/lance_rag/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/lance_tools.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/neo4j/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/neo4j/system_messages.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/neo4j/tools.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/retriever_agent.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/sql/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/sql/utils/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/sql/utils/system_message.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/sql/utils/tools.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/special/table_chat_agent.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/task.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tool_message.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/exa_search_tool.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/file_tools.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/google_search_tool.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/mcp/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/mcp/decorators.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/mcp/fastmcp_client.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/metaphor_search_tool.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/orchestration.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/recipient_tool.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/retrieval_tool.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/rewind_tool.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/segment_extract_tool.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/task_tool.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/tools/tavily_search_tool.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/agent/xml_tool_message.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/cachedb/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/cachedb/base.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/cachedb/redis_cachedb.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/embedding_models/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/embedding_models/base.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/embedding_models/protoc/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/embedding_models/protoc/embeddings.proto +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/embedding_models/remote_embeds.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/exceptions.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/azure_openai.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/base.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/client_cache.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/config.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/mock_lm.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/model_info.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/openai_gpt.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/prompt_formatter/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/prompt_formatter/base.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/provider_params.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/utils.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/mcp/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/mcp/server/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/mytypes.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/agent_chats.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/code_parser.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/document_parser.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/file_attachment.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/md_parser.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/para_sentence_split.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/parser.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/pdf_utils.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/repo_loader.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/routing.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/search.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/spider.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/table_loader.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/url_loader.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/urls.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/utils.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/parsing/web_search.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/prompts/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/prompts/dialog.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/prompts/prompts_config.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/prompts/templates.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/py.typed +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/pydantic_v1/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/pydantic_v1/main.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/algorithms/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/algorithms/graph.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/configuration.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/constants.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/git_utils.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/globals.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/html_logger.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/logging.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/object_registry.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/output/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/output/citations.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/output/printing.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/output/status.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/pandas_utils.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/pydantic_utils.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/system.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/utils/types.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/vector_store/__init__.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/vector_store/base.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/vector_store/chromadb.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/vector_store/lancedb.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/vector_store/meilisearch.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/vector_store/pineconedb.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/vector_store/postgres.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/vector_store/qdrantdb.py +0 -0
- {langroid-0.59.8 → langroid-0.59.10}/langroid/vector_store/weaviatedb.py +0 -0
@@ -14,7 +14,6 @@ from langroid.agent.chat_document import ChatDocument
|
|
14
14
|
from langroid.agent.tools.segment_extract_tool import SegmentExtractTool
|
15
15
|
from langroid.language_models.base import LLMConfig
|
16
16
|
from langroid.language_models.openai_gpt import OpenAIGPTConfig
|
17
|
-
from langroid.mytypes import Entity
|
18
17
|
from langroid.parsing.utils import extract_numbered_segments, number_segments
|
19
18
|
from langroid.utils.constants import DONE, NO_ANSWER
|
20
19
|
|
@@ -26,12 +25,19 @@ class RelevanceExtractorAgentConfig(ChatAgentConfig):
|
|
26
25
|
llm: LLMConfig | None = OpenAIGPTConfig()
|
27
26
|
segment_length: int = 1 # number of sentences per segment
|
28
27
|
query: str = "" # query for relevance extraction
|
28
|
+
handle_llm_no_tool: str = """
|
29
|
+
You FORGOT to use the `extract_segments` tool!
|
30
|
+
Remember that your response MUST be a JSON-formatted string
|
31
|
+
starting with `{"request": "extract_segments", ...}`
|
32
|
+
"""
|
29
33
|
system_message: str = """
|
30
34
|
The user will give you a PASSAGE containing segments numbered as
|
31
35
|
<#1#>, <#2#>, <#3#>, etc.,
|
32
36
|
followed by a QUERY. Extract ONLY the segment-numbers from
|
33
37
|
the PASSAGE that are RELEVANT to the QUERY.
|
34
38
|
Present the extracted segment-numbers using the `extract_segments` tool/function.
|
39
|
+
Note that your response MUST be a JSON-formatted string
|
40
|
+
starting with `{"request": "extract_segments", ...}`
|
35
41
|
"""
|
36
42
|
|
37
43
|
|
@@ -63,13 +69,22 @@ class RelevanceExtractorAgent(ChatAgent):
|
|
63
69
|
self.numbered_passage = number_segments(message_str, self.config.segment_length)
|
64
70
|
# compose prompt
|
65
71
|
prompt = f"""
|
72
|
+
<Instructions>
|
73
|
+
Given the PASSAGE below with NUMBERED segments, and the QUERY,
|
74
|
+
extract ONLY the segment-numbers that are RELEVANT to the QUERY,
|
75
|
+
and present them using the `extract_segments` tool/function,
|
76
|
+
i.e. your response MUST be a JSON-formatted string starting with
|
77
|
+
`{{"request": "extract_segments", ...}}`
|
78
|
+
</Instructions>
|
79
|
+
|
66
80
|
PASSAGE:
|
67
81
|
{self.numbered_passage}
|
68
82
|
|
69
83
|
QUERY: {self.config.query}
|
70
84
|
"""
|
71
85
|
# send to LLM
|
72
|
-
|
86
|
+
response = super().llm_response(prompt)
|
87
|
+
return response
|
73
88
|
|
74
89
|
@no_type_check
|
75
90
|
async def llm_response_async(
|
@@ -99,7 +114,8 @@ class RelevanceExtractorAgent(ChatAgent):
|
|
99
114
|
QUERY: {self.config.query}
|
100
115
|
"""
|
101
116
|
# send to LLM
|
102
|
-
|
117
|
+
response = await super().llm_response_async(prompt)
|
118
|
+
return response
|
103
119
|
|
104
120
|
def extract_segments(self, msg: SegmentExtractTool) -> str:
|
105
121
|
"""Method to handle a segmentExtractTool message from LLM"""
|
@@ -116,12 +132,3 @@ class RelevanceExtractorAgent(ChatAgent):
|
|
116
132
|
return DONE + " " + NO_ANSWER
|
117
133
|
# this response ends the task by saying DONE
|
118
134
|
return DONE + " " + extracts
|
119
|
-
|
120
|
-
def handle_message_fallback(
|
121
|
-
self, msg: str | ChatDocument
|
122
|
-
) -> str | ChatDocument | None:
|
123
|
-
"""Handle case where LLM forgets to use SegmentExtractTool"""
|
124
|
-
if isinstance(msg, ChatDocument) and msg.metadata.sender == Entity.LLM:
|
125
|
-
return DONE + " " + NO_ANSWER
|
126
|
-
else:
|
127
|
-
return None
|
@@ -463,12 +463,12 @@ class LlamaCppServerEmbeddings(EmbeddingModel):
|
|
463
463
|
response = requests.post(self.embedding_url, json=data)
|
464
464
|
|
465
465
|
if response.status_code == 200:
|
466
|
-
embeddings = response.json()
|
466
|
+
embeddings = self._extract_embedding(response.json())
|
467
467
|
if not (
|
468
468
|
isinstance(embeddings, list) and isinstance(embeddings[0], (int, float))
|
469
469
|
):
|
470
470
|
raise ValueError(
|
471
|
-
"""Embedding endpoint has not returned the correct format.
|
471
|
+
"""Embedding endpoint has not returned the correct format.
|
472
472
|
Is the URL correct?
|
473
473
|
"""
|
474
474
|
)
|
@@ -480,6 +480,71 @@ class LlamaCppServerEmbeddings(EmbeddingModel):
|
|
480
480
|
"Failed to connect to embedding provider",
|
481
481
|
)
|
482
482
|
|
483
|
+
def _extract_embedding(
|
484
|
+
self, response_json: dict[str, Any] | list[Any]
|
485
|
+
) -> List[int | float]:
|
486
|
+
"""
|
487
|
+
Extract embedding vector from llama.cpp response.
|
488
|
+
|
489
|
+
Handles multiple response formats:
|
490
|
+
1. Native /embedding: {"embedding": [floats]}
|
491
|
+
2. Array format: [{"embedding": [floats]}]
|
492
|
+
3. Double-nested: [{"embedding": [[floats]]}]
|
493
|
+
4. OpenAI /v1/embeddings: {"data": [{"embedding": [floats]}]}
|
494
|
+
5. Nested in dict: {"embedding": [[floats]]}
|
495
|
+
|
496
|
+
Args:
|
497
|
+
response_json: The JSON response from llama.cpp server
|
498
|
+
|
499
|
+
Returns:
|
500
|
+
List of floats representing the embedding vector
|
501
|
+
|
502
|
+
Raises:
|
503
|
+
ValueError: If response format is not recognized
|
504
|
+
"""
|
505
|
+
import json
|
506
|
+
|
507
|
+
# Try native format first: {"embedding": [floats]}
|
508
|
+
if isinstance(response_json, dict) and "embedding" in response_json:
|
509
|
+
embeddings = response_json["embedding"]
|
510
|
+
# Check if it's [floats]
|
511
|
+
if isinstance(embeddings, list) and len(embeddings) > 0:
|
512
|
+
if isinstance(embeddings[0], (int, float)):
|
513
|
+
return embeddings
|
514
|
+
# Might be nested: {"embedding": [[floats]]}
|
515
|
+
if isinstance(embeddings[0], list) and len(embeddings[0]) > 0:
|
516
|
+
if isinstance(embeddings[0][0], (int, float)):
|
517
|
+
return embeddings[0]
|
518
|
+
|
519
|
+
# Try OpenAI format: {"data": [{"embedding": [floats]}]}
|
520
|
+
if isinstance(response_json, dict) and "data" in response_json:
|
521
|
+
data = response_json["data"]
|
522
|
+
if isinstance(data, list) and len(data) > 0:
|
523
|
+
if isinstance(data[0], dict) and "embedding" in data[0]:
|
524
|
+
embeddings = data[0]["embedding"]
|
525
|
+
if isinstance(embeddings, list) and len(embeddings) > 0:
|
526
|
+
if isinstance(embeddings[0], (int, float)):
|
527
|
+
return embeddings
|
528
|
+
|
529
|
+
# Try array format: [{"embedding": [floats]}] or [{"embedding": [[floats]]}]
|
530
|
+
if isinstance(response_json, list) and len(response_json) > 0:
|
531
|
+
first_item = response_json[0]
|
532
|
+
if isinstance(first_item, dict) and "embedding" in first_item:
|
533
|
+
embeddings = first_item["embedding"]
|
534
|
+
# Check if it's [floats]
|
535
|
+
if isinstance(embeddings, list) and len(embeddings) > 0:
|
536
|
+
if isinstance(embeddings[0], (int, float)):
|
537
|
+
return embeddings
|
538
|
+
# Check if it's [[floats]]
|
539
|
+
if isinstance(embeddings[0], list) and len(embeddings[0]) > 0:
|
540
|
+
if isinstance(embeddings[0][0], (int, float)):
|
541
|
+
return embeddings[0]
|
542
|
+
|
543
|
+
raise ValueError(
|
544
|
+
f"Unsupported embedding response format from {self.embedding_url}. "
|
545
|
+
f"Response: {json.dumps(response_json)[:500]}"
|
546
|
+
)
|
547
|
+
|
483
548
|
def embedding_fn(self) -> Callable[[List[str]], Embeddings]:
|
484
549
|
return EmbeddingFunctionCallable(self, self.config.batch_size)
|
485
550
|
|
@@ -142,8 +142,14 @@ def top_level_json_field(s: str, f: str) -> Any:
|
|
142
142
|
return ""
|
143
143
|
for j in jsons:
|
144
144
|
json_data = json.loads(j)
|
145
|
-
if
|
146
|
-
|
145
|
+
if isinstance(json_data, dict):
|
146
|
+
if f in json_data:
|
147
|
+
return json_data[f]
|
148
|
+
elif isinstance(json_data, list):
|
149
|
+
# Some responses wrap candidate JSON objects in a list; scan them.
|
150
|
+
for item in json_data:
|
151
|
+
if isinstance(item, dict) and f in item:
|
152
|
+
return item[f]
|
147
153
|
|
148
154
|
return ""
|
149
155
|
|
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.59.8 → langroid-0.59.10}/langroid/agent/special/lance_rag/query_planner_agent.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
|
{langroid-0.59.8 → langroid-0.59.10}/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
|
{langroid-0.59.8 → langroid-0.59.10}/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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.59.8 → langroid-0.59.10}/langroid/language_models/prompt_formatter/hf_formatter.py
RENAMED
File without changes
|
{langroid-0.59.8 → langroid-0.59.10}/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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|