langroid 0.1.207__tar.gz → 0.1.209__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.1.207 → langroid-0.1.209}/PKG-INFO +1 -1
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/doc_chat_agent.py +25 -12
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/search.py +8 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/utils.py +2 -1
- {langroid-0.1.207 → langroid-0.1.209}/langroid/vector_store/base.py +0 -4
- {langroid-0.1.207 → langroid-0.1.209}/langroid/vector_store/lancedb.py +2 -3
- {langroid-0.1.207 → langroid-0.1.209}/pyproject.toml +1 -1
- {langroid-0.1.207 → langroid-0.1.209}/LICENSE +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/README.md +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/base.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/batch.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/callbacks/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/callbacks/chainlit.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/chat_agent.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/chat_document.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/helpers.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/junk +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/openai_assistant.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/lance_rag/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/lance_tools.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/neo4j/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/neo4j/utils/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/neo4j/utils/system_message.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/relevance_extractor_agent.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/retriever_agent.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/sql/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/sql/utils/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/sql/utils/system_message.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/sql/utils/tools.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/special/table_chat_agent.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/task.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/tool_message.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/tools/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/tools/extract_tool.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/tools/generator_tool.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/tools/google_search_tool.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/tools/metaphor_search_tool.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/tools/recipient_tool.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/tools/run_python_code.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/tools/sciphi_search_rag_tool.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent/tools/segment_extract_tool.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/agent_config.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/cachedb/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/cachedb/base.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/cachedb/momento_cachedb.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/cachedb/redis_cachedb.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/embedding_models/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/embedding_models/base.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/embedding_models/clustering.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/embedding_models/models.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/language_models/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/language_models/azure_openai.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/language_models/base.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/language_models/config.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/language_models/openai_assistants.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/language_models/openai_gpt.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/language_models/prompt_formatter/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/language_models/prompt_formatter/base.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/language_models/utils.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/mytypes.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/agent_chats.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/code-parsing.md +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/code_parser.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/config.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/document_parser.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/json.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/para_sentence_split.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/parser.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/repo_loader.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/spider.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/table_loader.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/url_loader.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/url_loader_cookies.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/urls.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/parsing/web_search.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/prompts/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/prompts/dialog.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/prompts/prompts_config.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/prompts/templates.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/prompts/transforms.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/algorithms/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/algorithms/graph.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/configuration.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/constants.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/docker.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/globals.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/llms/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/llms/strings.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/logging.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/output/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/output/printing.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/pandas_utils.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/pydantic_utils.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/system.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/web/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/web/login.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/utils/web/selenium_login.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/vector_store/__init__.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/vector_store/chromadb.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/vector_store/meilisearch.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/vector_store/momento.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/vector_store/qdrant_cloud.py +0 -0
- {langroid-0.1.207 → langroid-0.1.209}/langroid/vector_store/qdrantdb.py +0 -0
@@ -927,6 +927,13 @@ class DocChatAgent(ChatAgent):
|
|
927
927
|
"""
|
928
928
|
if self.vecdb is None or self.config.n_neighbor_chunks == 0:
|
929
929
|
return docs_scores
|
930
|
+
if len(docs_scores) == 0:
|
931
|
+
return []
|
932
|
+
if set(docs_scores[0][0].__fields__) != {"content", "metadata"}:
|
933
|
+
# Do not add context window when there are other fields besides just
|
934
|
+
# content and metadata, since we do not know how to set those other fields
|
935
|
+
# for newly created docs with combined content.
|
936
|
+
return docs_scores
|
930
937
|
return self.vecdb.add_context_window(docs_scores, self.config.n_neighbor_chunks)
|
931
938
|
|
932
939
|
def get_semantic_search_results(
|
@@ -1005,11 +1012,11 @@ class DocChatAgent(ChatAgent):
|
|
1005
1012
|
# keep only docs with unique d.id()
|
1006
1013
|
id2doc_score = {d.id(): (d, s) for d, s in docs_and_scores}
|
1007
1014
|
docs_and_scores = list(id2doc_score.values())
|
1008
|
-
|
1009
|
-
passages = [
|
1010
|
-
|
1011
|
-
|
1012
|
-
]
|
1015
|
+
passages = [d for (d, _) in docs_and_scores]
|
1016
|
+
# passages = [
|
1017
|
+
# Document(content=d.content, metadata=d.metadata)
|
1018
|
+
# for (d, _) in docs_and_scores
|
1019
|
+
# ]
|
1013
1020
|
|
1014
1021
|
if self.config.use_bm25_search:
|
1015
1022
|
docs_scores = self.get_similar_chunks_bm25(query, retrieval_multiple)
|
@@ -1138,13 +1145,19 @@ class DocChatAgent(ChatAgent):
|
|
1138
1145
|
input_map=lambda msg: msg.content,
|
1139
1146
|
output_map=lambda ans: ans.content if ans is not None else NO_ANSWER,
|
1140
1147
|
)
|
1141
|
-
|
1142
|
-
#
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
+
|
1149
|
+
# Caution: Retain ALL other fields in the Documents (which could be
|
1150
|
+
# other than just `content` and `metadata`), while simply replacing
|
1151
|
+
# `content` with the extracted portions
|
1152
|
+
passage_extracts = []
|
1153
|
+
for p, e in zip(passages, extracts):
|
1154
|
+
if e == NO_ANSWER or len(e) == 0:
|
1155
|
+
continue
|
1156
|
+
p_copy = p.copy()
|
1157
|
+
p_copy.content = e
|
1158
|
+
passage_extracts.append(p_copy)
|
1159
|
+
|
1160
|
+
return passage_extracts
|
1148
1161
|
|
1149
1162
|
def answer_from_docs(self, query: str) -> ChatDocument:
|
1150
1163
|
"""
|
@@ -64,6 +64,14 @@ def find_fuzzy_matches_in_docs(
|
|
64
64
|
break
|
65
65
|
if words_after is None and words_before is None:
|
66
66
|
return orig_doc_matches
|
67
|
+
if len(orig_doc_matches) == 0:
|
68
|
+
return []
|
69
|
+
if set(orig_doc_matches[0].__fields__) != {"content", "metadata"}:
|
70
|
+
# If there are fields beyond just content and metadata,
|
71
|
+
# we do NOT want to create new document objects with content fields
|
72
|
+
# based on words_before and words_after, since we don't know how to
|
73
|
+
# set those other fields.
|
74
|
+
return orig_doc_matches
|
67
75
|
|
68
76
|
contextual_matches = []
|
69
77
|
for match in orig_doc_matches:
|
@@ -284,7 +284,8 @@ def extract_numbered_segments(s: str, specs: str) -> str:
|
|
284
284
|
|
285
285
|
# Regular expression to identify numbered segments like
|
286
286
|
# <#1#> Hello world! This is me. <#2#> How are you? <#3#> Have a good day.
|
287
|
-
|
287
|
+
# Note we match any character between segment markers, including newlines.
|
288
|
+
segment_pattern = re.compile(r"<#(\d+)#>([\s\S]*?)(?=<#\d+#>|$)")
|
288
289
|
|
289
290
|
# Split the text into paragraphs while preserving their boundaries
|
290
291
|
paragraphs = split_paragraphs(s)
|
@@ -133,10 +133,6 @@ class VectorStore(ABC):
|
|
133
133
|
"""Compute a result on a set of documents,
|
134
134
|
using a dataframe calc string like `df.groupby('state')['income'].mean()`.
|
135
135
|
"""
|
136
|
-
# docs may be missing some fields since they may have come from
|
137
|
-
# DocChatAgent retrieval, so we use the ids to get the full docs
|
138
|
-
ids = [str(doc.id()) for doc in docs]
|
139
|
-
docs = self.get_documents_by_ids(ids)
|
140
136
|
dicts = [doc.dict() for doc in docs]
|
141
137
|
df = pd.DataFrame(dicts)
|
142
138
|
|
@@ -420,9 +420,8 @@ class LanceDB(VectorStore):
|
|
420
420
|
docs = []
|
421
421
|
for _id in _ids:
|
422
422
|
results = self._lance_result_to_docs(tbl.search().where(f"id == '{_id}'"))
|
423
|
-
if len(results)
|
424
|
-
|
425
|
-
docs.append(results[0])
|
423
|
+
if len(results) > 0:
|
424
|
+
docs.append(results[0])
|
426
425
|
return docs
|
427
426
|
|
428
427
|
def similar_texts_with_scores(
|
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.1.207 → langroid-0.1.209}/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
|
File without changes
|
{langroid-0.1.207 → langroid-0.1.209}/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
|
{langroid-0.1.207 → langroid-0.1.209}/langroid/language_models/prompt_formatter/hf_formatter.py
RENAMED
File without changes
|
{langroid-0.1.207 → langroid-0.1.209}/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
|