langroid 0.52.7__tar.gz → 0.52.9__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.52.7 → langroid-0.52.9}/PKG-INFO +1 -1
- {langroid-0.52.7 → langroid-0.52.9}/langroid/language_models/base.py +2 -3
- {langroid-0.52.7 → langroid-0.52.9}/langroid/language_models/openai_gpt.py +23 -9
- langroid-0.52.9/langroid/parsing/pdf_utils.py +89 -0
- {langroid-0.52.7 → langroid-0.52.9}/pyproject.toml +1 -1
- langroid-0.52.7/langroid/parsing/pdf_utils.py +0 -54
- {langroid-0.52.7 → langroid-0.52.9}/.gitignore +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/LICENSE +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/README.md +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/base.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/batch.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/callbacks/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/callbacks/chainlit.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/chat_agent.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/chat_document.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/openai_assistant.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/arangodb/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/arangodb/arangodb_agent.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/arangodb/system_messages.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/arangodb/tools.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/arangodb/utils.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/doc_chat_agent.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/doc_chat_task.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/lance_rag/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/lance_tools.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/neo4j/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/neo4j/system_messages.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/neo4j/tools.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/relevance_extractor_agent.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/retriever_agent.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/sql/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/sql/utils/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/sql/utils/system_message.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/sql/utils/tools.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/special/table_chat_agent.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/task.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/tool_message.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/tools/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/tools/exa_search_tool.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/tools/file_tools.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/tools/google_search_tool.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/tools/metaphor_search_tool.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/tools/orchestration.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/tools/recipient_tool.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/tools/retrieval_tool.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/tools/rewind_tool.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/tools/segment_extract_tool.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/tools/tavily_search_tool.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/agent/xml_tool_message.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/cachedb/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/cachedb/base.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/cachedb/redis_cachedb.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/embedding_models/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/embedding_models/base.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/embedding_models/models.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/embedding_models/protoc/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/embedding_models/protoc/embeddings.proto +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/embedding_models/remote_embeds.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/exceptions.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/language_models/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/language_models/azure_openai.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/language_models/config.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/language_models/mock_lm.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/language_models/model_info.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/language_models/prompt_formatter/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/language_models/prompt_formatter/base.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/language_models/utils.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/mytypes.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/agent_chats.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/code_parser.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/document_parser.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/file_attachment.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/md_parser.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/para_sentence_split.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/parse_json.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/parser.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/repo_loader.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/routing.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/search.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/spider.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/table_loader.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/url_loader.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/urls.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/utils.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/parsing/web_search.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/prompts/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/prompts/dialog.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/prompts/prompts_config.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/prompts/templates.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/py.typed +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/pydantic_v1/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/pydantic_v1/main.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/algorithms/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/algorithms/graph.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/configuration.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/constants.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/git_utils.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/globals.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/logging.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/object_registry.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/output/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/output/citations.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/output/printing.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/output/status.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/pandas_utils.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/pydantic_utils.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/system.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/utils/types.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/vector_store/__init__.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/vector_store/base.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/vector_store/chromadb.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/vector_store/lancedb.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/vector_store/meilisearch.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/vector_store/pineconedb.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/vector_store/postgres.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/vector_store/qdrantdb.py +0 -0
- {langroid-0.52.7 → langroid-0.52.9}/langroid/vector_store/weaviatedb.py +0 -0
@@ -99,9 +99,8 @@ class LLMConfig(BaseSettings):
|
|
99
99
|
|
100
100
|
@property
|
101
101
|
def model_max_output_tokens(self) -> int:
|
102
|
-
return
|
103
|
-
self.max_output_tokens or get_model_info(self.chat_model).max_output_tokens
|
104
|
-
get_model_info(self.chat_model).max_output_tokens,
|
102
|
+
return (
|
103
|
+
self.max_output_tokens or get_model_info(self.chat_model).max_output_tokens
|
105
104
|
)
|
106
105
|
|
107
106
|
|
@@ -336,15 +336,16 @@ class OpenAIGPTConfig(LLMConfig):
|
|
336
336
|
# (e.g. anthropic doesn't like first msg to be system msg)
|
337
337
|
litellm.modify_params = True
|
338
338
|
self.seed = None # some local mdls don't support seed
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
339
|
+
if self.api_key == DUMMY_API_KEY:
|
340
|
+
keys_dict = litellm.utils.validate_environment(self.chat_model)
|
341
|
+
missing_keys = keys_dict.get("missing_keys", [])
|
342
|
+
if len(missing_keys) > 0:
|
343
|
+
raise ValueError(
|
344
|
+
f"""
|
345
|
+
Missing environment variables for litellm-proxied model:
|
346
|
+
{missing_keys}
|
347
|
+
"""
|
348
|
+
)
|
348
349
|
|
349
350
|
@classmethod
|
350
351
|
def create(cls, prefix: str) -> Type["OpenAIGPTConfig"]:
|
@@ -1504,6 +1505,9 @@ class OpenAIGPT(LanguageModel):
|
|
1504
1505
|
from litellm import completion as litellm_completion
|
1505
1506
|
|
1506
1507
|
completion_call = litellm_completion
|
1508
|
+
|
1509
|
+
if self.api_key != DUMMY_API_KEY:
|
1510
|
+
kwargs["api_key"] = self.api_key
|
1507
1511
|
else:
|
1508
1512
|
if self.client is None:
|
1509
1513
|
raise ValueError(
|
@@ -1587,6 +1591,10 @@ class OpenAIGPT(LanguageModel):
|
|
1587
1591
|
else:
|
1588
1592
|
if self.config.litellm:
|
1589
1593
|
from litellm import acompletion as litellm_acompletion
|
1594
|
+
|
1595
|
+
if self.api_key != DUMMY_API_KEY:
|
1596
|
+
kwargs["api_key"] = self.api_key
|
1597
|
+
|
1590
1598
|
# TODO this may not work: text_completion is not async,
|
1591
1599
|
# and we didn't find an async version in litellm
|
1592
1600
|
assert isinstance(self.async_client, AsyncOpenAI)
|
@@ -1734,6 +1742,9 @@ class OpenAIGPT(LanguageModel):
|
|
1734
1742
|
from litellm import completion as litellm_completion
|
1735
1743
|
|
1736
1744
|
completion_call = litellm_completion
|
1745
|
+
|
1746
|
+
if self.api_key != DUMMY_API_KEY:
|
1747
|
+
kwargs["api_key"] = self.api_key
|
1737
1748
|
else:
|
1738
1749
|
if self.client is None:
|
1739
1750
|
raise ValueError("OpenAI/equivalent chat-completion client not set")
|
@@ -1792,6 +1803,9 @@ class OpenAIGPT(LanguageModel):
|
|
1792
1803
|
from litellm import acompletion as litellm_acompletion
|
1793
1804
|
|
1794
1805
|
acompletion_call = litellm_acompletion
|
1806
|
+
|
1807
|
+
if self.api_key != DUMMY_API_KEY:
|
1808
|
+
kwargs["api_key"] = self.api_key
|
1795
1809
|
else:
|
1796
1810
|
if self.async_client is None:
|
1797
1811
|
raise ValueError(
|
@@ -0,0 +1,89 @@
|
|
1
|
+
import tempfile
|
2
|
+
from io import BytesIO
|
3
|
+
from pathlib import Path
|
4
|
+
from tempfile import TemporaryDirectory
|
5
|
+
from typing import TYPE_CHECKING, Any, BinaryIO, List, Optional, Tuple, Union
|
6
|
+
|
7
|
+
try:
|
8
|
+
import fitz
|
9
|
+
except ImportError:
|
10
|
+
if not TYPE_CHECKING:
|
11
|
+
fitz = None
|
12
|
+
|
13
|
+
from langroid.exceptions import LangroidImportError
|
14
|
+
|
15
|
+
if fitz is None:
|
16
|
+
raise LangroidImportError("fitz", ["pymupdf", "all", "pdf-parsers", "doc-chat"])
|
17
|
+
|
18
|
+
|
19
|
+
def pdf_split_pages(
|
20
|
+
input_pdf: Union[BytesIO, BinaryIO, str],
|
21
|
+
splits: Optional[List[int]] = None,
|
22
|
+
) -> Tuple[List[Path], TemporaryDirectory[Any]]:
|
23
|
+
"""Splits a PDF into individual pages or chunks in a temporary directory.
|
24
|
+
|
25
|
+
Args:
|
26
|
+
input_pdf: Input PDF file in bytes, binary mode, or a file path
|
27
|
+
splits: Optional list of page numbers to split at.
|
28
|
+
If provided, pages will be grouped into chunks ending at
|
29
|
+
these page numbers.
|
30
|
+
For example, if splits = [4, 9], the result will have pages 1-4, 5-9,
|
31
|
+
and 10-end.
|
32
|
+
If not provided, default to splitting into individual pages.
|
33
|
+
max_workers: Maximum number of concurrent workers for parallel processing
|
34
|
+
|
35
|
+
Returns:
|
36
|
+
Tuple containing:
|
37
|
+
- List of paths to individual PDF pages or chunks
|
38
|
+
- Temporary directory object (caller must call cleanup())
|
39
|
+
|
40
|
+
Example:
|
41
|
+
paths, tmp_dir = split_pdf_temp("input.pdf")
|
42
|
+
# Use paths...
|
43
|
+
tmp_dir.cleanup() # Clean up temp files when done
|
44
|
+
"""
|
45
|
+
tmp_dir = tempfile.TemporaryDirectory()
|
46
|
+
if isinstance(input_pdf, str):
|
47
|
+
doc = fitz.open(input_pdf)
|
48
|
+
else:
|
49
|
+
doc = fitz.open(stream=input_pdf, filetype="pdf")
|
50
|
+
paths = []
|
51
|
+
|
52
|
+
total_pages = len(doc)
|
53
|
+
|
54
|
+
if splits is None:
|
55
|
+
# Split into individual pages (original behavior)
|
56
|
+
for page_num in range(total_pages):
|
57
|
+
new_doc = fitz.open()
|
58
|
+
new_doc.insert_pdf(doc, from_page=page_num, to_page=page_num)
|
59
|
+
output = Path(tmp_dir.name) / f"page_{page_num + 1}.pdf"
|
60
|
+
new_doc.save(str(output))
|
61
|
+
new_doc.close()
|
62
|
+
paths.append(output)
|
63
|
+
else:
|
64
|
+
# Split according to specified page ranges
|
65
|
+
# Make sure the splits list is sorted and includes all valid splits
|
66
|
+
splits = sorted([s for s in splits if 1 <= s <= total_pages])
|
67
|
+
|
68
|
+
# Create the ranges to process
|
69
|
+
ranges = []
|
70
|
+
start_page = 0
|
71
|
+
for end_page in splits:
|
72
|
+
ranges.append((start_page, end_page - 1))
|
73
|
+
start_page = end_page
|
74
|
+
|
75
|
+
# Add the final range if there are pages after the last split
|
76
|
+
if start_page < total_pages:
|
77
|
+
ranges.append((start_page, total_pages - 1))
|
78
|
+
|
79
|
+
# Process each range
|
80
|
+
for i, (from_page, to_page) in enumerate(ranges):
|
81
|
+
new_doc = fitz.open()
|
82
|
+
new_doc.insert_pdf(doc, from_page=from_page, to_page=to_page)
|
83
|
+
output = Path(tmp_dir.name) / f"pages_{from_page + 1}_to_{to_page + 1}.pdf"
|
84
|
+
new_doc.save(str(output))
|
85
|
+
new_doc.close()
|
86
|
+
paths.append(output)
|
87
|
+
|
88
|
+
doc.close()
|
89
|
+
return paths, tmp_dir
|
@@ -1,54 +0,0 @@
|
|
1
|
-
import tempfile
|
2
|
-
from io import BytesIO
|
3
|
-
from pathlib import Path
|
4
|
-
from tempfile import TemporaryDirectory
|
5
|
-
from typing import TYPE_CHECKING, Any, BinaryIO, List, Tuple, Union
|
6
|
-
|
7
|
-
try:
|
8
|
-
import fitz
|
9
|
-
except ImportError:
|
10
|
-
if not TYPE_CHECKING:
|
11
|
-
fitz = None
|
12
|
-
|
13
|
-
from langroid.exceptions import LangroidImportError
|
14
|
-
|
15
|
-
if fitz is None:
|
16
|
-
raise LangroidImportError("fitz", ["pymupdf", "all", "pdf-parsers", "doc-chat"])
|
17
|
-
|
18
|
-
|
19
|
-
def pdf_split_pages(
|
20
|
-
input_pdf: Union[BytesIO, BinaryIO, str],
|
21
|
-
) -> Tuple[List[Path], TemporaryDirectory[Any]]:
|
22
|
-
"""Splits a PDF into individual pages in a temporary directory.
|
23
|
-
|
24
|
-
Args:
|
25
|
-
input_pdf: Input PDF file in bytes, binary mode, or a file path
|
26
|
-
max_workers: Maximum number of concurrent workers for parallel processing
|
27
|
-
|
28
|
-
Returns:
|
29
|
-
Tuple containing:
|
30
|
-
- List of paths to individual PDF pages
|
31
|
-
- Temporary directory object (caller must call cleanup())
|
32
|
-
|
33
|
-
Example:
|
34
|
-
paths, tmp_dir = split_pdf_temp("input.pdf")
|
35
|
-
# Use paths...
|
36
|
-
tmp_dir.cleanup() # Clean up temp files when done
|
37
|
-
"""
|
38
|
-
tmp_dir = tempfile.TemporaryDirectory()
|
39
|
-
if isinstance(input_pdf, str):
|
40
|
-
doc = fitz.open(input_pdf)
|
41
|
-
else:
|
42
|
-
doc = fitz.open(stream=input_pdf, filetype="pdf")
|
43
|
-
paths = []
|
44
|
-
|
45
|
-
for page_num in range(len(doc)):
|
46
|
-
new_doc = fitz.open()
|
47
|
-
new_doc.insert_pdf(doc, from_page=page_num, to_page=page_num)
|
48
|
-
output = Path(tmp_dir.name) / f"page_{page_num + 1}.pdf"
|
49
|
-
new_doc.save(str(output))
|
50
|
-
new_doc.close()
|
51
|
-
paths.append(output)
|
52
|
-
|
53
|
-
doc.close()
|
54
|
-
return paths, tmp_dir
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
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.52.7 → langroid-0.52.9}/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
|
File without changes
|
File without changes
|
{langroid-0.52.7 → langroid-0.52.9}/langroid/language_models/prompt_formatter/hf_formatter.py
RENAMED
File without changes
|
{langroid-0.52.7 → langroid-0.52.9}/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
|