code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def chat(self, messages: List[Dict]) -> ChatResponse:
"""
Send a chat message to the Bedrock model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
... |
Send a chat message to the Bedrock model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
{"role": "user", "content": "..."}]
... | chat | python | zilliztech/deep-searcher | deepsearcher/llm/bedrock.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/bedrock.py | Apache-2.0 |
def __init__(self, model: str = "deepseek-reasoner", **kwargs):
"""
Initialize a DeepSeek language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "deepseek-reasoner".
**kwargs: Additional keyword arguments to pass to the OpenAI client... |
Initialize a DeepSeek language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "deepseek-reasoner".
**kwargs: Additional keyword arguments to pass to the OpenAI client.
- api_key: DeepSeek API key. If not provided, uses DEEPSE... | __init__ | python | zilliztech/deep-searcher | deepsearcher/llm/deepseek.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/deepseek.py | Apache-2.0 |
def chat(self, messages: List[Dict]) -> ChatResponse:
"""
Send a chat message to the DeepSeek model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
... |
Send a chat message to the DeepSeek model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
{"role": "user", "content": "..."}]... | chat | python | zilliztech/deep-searcher | deepsearcher/llm/deepseek.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/deepseek.py | Apache-2.0 |
def __init__(self, model: str = "gemini-2.0-flash", **kwargs):
"""
Initialize a Gemini language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "gemini-2.0-flash".
**kwargs: Additional keyword arguments to pass to the Gemini client.
... |
Initialize a Gemini language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "gemini-2.0-flash".
**kwargs: Additional keyword arguments to pass to the Gemini client.
- api_key: Gemini API key. If not provided, uses GEMINI_API_... | __init__ | python | zilliztech/deep-searcher | deepsearcher/llm/gemini.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/gemini.py | Apache-2.0 |
def chat(self, messages: List[Dict]) -> ChatResponse:
"""
Send a chat message to the Gemini model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
... |
Send a chat message to the Gemini model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
{"role": "user", "content": "..."}]
... | chat | python | zilliztech/deep-searcher | deepsearcher/llm/gemini.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/gemini.py | Apache-2.0 |
def __init__(self, model: str = "qwq", **kwargs):
"""
Initialize an Ollama language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "qwq".
**kwargs: Additional keyword arguments to pass to the Ollama client.
- base_url:... |
Initialize an Ollama language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "qwq".
**kwargs: Additional keyword arguments to pass to the Ollama client.
- base_url: Ollama API base URL. If not provided, defaults to "http://lo... | __init__ | python | zilliztech/deep-searcher | deepsearcher/llm/ollama.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/ollama.py | Apache-2.0 |
def chat(self, messages: List[Dict]) -> ChatResponse:
"""
Send a chat message to the Ollama model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
... |
Send a chat message to the Ollama model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
{"role": "user", "content": "..."}]
... | chat | python | zilliztech/deep-searcher | deepsearcher/llm/ollama.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/ollama.py | Apache-2.0 |
def __init__(self, model: str = "o1-mini", **kwargs):
"""
Initialize an OpenAI language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "o1-mini".
**kwargs: Additional keyword arguments to pass to the OpenAI client.
- a... |
Initialize an OpenAI language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "o1-mini".
**kwargs: Additional keyword arguments to pass to the OpenAI client.
- api_key: OpenAI API key. If not provided, uses OPENAI_API_KEY envi... | __init__ | python | zilliztech/deep-searcher | deepsearcher/llm/openai_llm.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/openai_llm.py | Apache-2.0 |
def chat(self, messages: List[Dict]) -> ChatResponse:
"""
Send a chat message to the OpenAI model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
... |
Send a chat message to the OpenAI model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
{"role": "user", "content": "..."}]
... | chat | python | zilliztech/deep-searcher | deepsearcher/llm/openai_llm.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/openai_llm.py | Apache-2.0 |
def __init__(self, model: str = "deepseek/deepseek-r1-turbo", **kwargs):
"""
Initialize a PPIO language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "deepseek/deepseek-r1-turbo".
**kwargs: Additional keyword arguments to pass to the... |
Initialize a PPIO language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "deepseek/deepseek-r1-turbo".
**kwargs: Additional keyword arguments to pass to the OpenAI client.
- api_key: PPIO API key. If not provided, uses PPIO_... | __init__ | python | zilliztech/deep-searcher | deepsearcher/llm/ppio.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/ppio.py | Apache-2.0 |
def chat(self, messages: List[Dict]) -> ChatResponse:
"""
Send a chat message to the PPIO model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
... |
Send a chat message to the PPIO model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
{"role": "user", "content": "..."}]
... | chat | python | zilliztech/deep-searcher | deepsearcher/llm/ppio.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/ppio.py | Apache-2.0 |
def __init__(self, model: str = "deepseek-ai/DeepSeek-R1", **kwargs):
"""
Initialize a SiliconFlow language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "deepseek-ai/DeepSeek-R1".
**kwargs: Additional keyword arguments to pass to th... |
Initialize a SiliconFlow language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "deepseek-ai/DeepSeek-R1".
**kwargs: Additional keyword arguments to pass to the OpenAI client.
- api_key: SiliconFlow API key. If not provided,... | __init__ | python | zilliztech/deep-searcher | deepsearcher/llm/siliconflow.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/siliconflow.py | Apache-2.0 |
def chat(self, messages: List[Dict]) -> ChatResponse:
"""
Send a chat message to the SiliconFlow model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
... |
Send a chat message to the SiliconFlow model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
{"role": "user", "content": "...... | chat | python | zilliztech/deep-searcher | deepsearcher/llm/siliconflow.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/siliconflow.py | Apache-2.0 |
def __init__(self, model: str = "deepseek-ai/DeepSeek-R1", **kwargs):
"""
Initialize a TogetherAI language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "deepseek-ai/DeepSeek-R1".
**kwargs: Additional keyword arguments to pass to the... |
Initialize a TogetherAI language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "deepseek-ai/DeepSeek-R1".
**kwargs: Additional keyword arguments to pass to the Together client.
- api_key: Together AI API key. If not provided... | __init__ | python | zilliztech/deep-searcher | deepsearcher/llm/together_ai.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/together_ai.py | Apache-2.0 |
def chat(self, messages: List[Dict]) -> ChatResponse:
"""
Send a chat message to the TogetherAI model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
... |
Send a chat message to the TogetherAI model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
{"role": "user", "content": "..."... | chat | python | zilliztech/deep-searcher | deepsearcher/llm/together_ai.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/together_ai.py | Apache-2.0 |
def __init__(self, model: str = "deepseek-r1-250120", **kwargs):
"""
Initialize a Volcengine language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "deepseek-r1-250120".
**kwargs: Additional keyword arguments to pass to the OpenAI cl... |
Initialize a Volcengine language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "deepseek-r1-250120".
**kwargs: Additional keyword arguments to pass to the OpenAI client.
- api_key: Volcengine API key. If not provided, uses V... | __init__ | python | zilliztech/deep-searcher | deepsearcher/llm/volcengine.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/volcengine.py | Apache-2.0 |
def chat(self, messages: List[Dict]) -> ChatResponse:
"""
Send a chat message to the Volcengine model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
... |
Send a chat message to the Volcengine model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
{"role": "user", "content": "..."... | chat | python | zilliztech/deep-searcher | deepsearcher/llm/volcengine.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/volcengine.py | Apache-2.0 |
def __init__(self, model: str = "ibm/granite-3-3-8b-instruct", **kwargs):
"""
Initialize the WatsonX language model.
Args:
model (str): The model identifier to use.
Default is "ibm/granite-3-3-8b-instruct".
**kwargs: Additional keyword arguments fo... |
Initialize the WatsonX language model.
Args:
model (str): The model identifier to use.
Default is "ibm/granite-3-3-8b-instruct".
**kwargs: Additional keyword arguments for WatsonX configuration.
- url (str): WatsonX endpoint URL
... | __init__ | python | zilliztech/deep-searcher | deepsearcher/llm/watsonx.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/watsonx.py | Apache-2.0 |
def chat(self, messages: List[Dict]) -> ChatResponse:
"""
Send a chat message to the WatsonX model and get a response.
Args:
messages: A list of message dictionaries in the format
[{"role": "system", "content": "..."}, {"role": "user", "content": "..."}]
... |
Send a chat message to the WatsonX model and get a response.
Args:
messages: A list of message dictionaries in the format
[{"role": "system", "content": "..."}, {"role": "user", "content": "..."}]
Returns:
ChatResponse: A ChatResponse object contai... | chat | python | zilliztech/deep-searcher | deepsearcher/llm/watsonx.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/watsonx.py | Apache-2.0 |
def _messages_to_prompt(self, messages: List[Dict]) -> str:
"""
Convert a list of chat messages to a single prompt string.
Args:
messages: List of message dictionaries with 'role' and 'content' keys.
Returns:
str: Formatted prompt string.
"""
pro... |
Convert a list of chat messages to a single prompt string.
Args:
messages: List of message dictionaries with 'role' and 'content' keys.
Returns:
str: Formatted prompt string.
| _messages_to_prompt | python | zilliztech/deep-searcher | deepsearcher/llm/watsonx.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/watsonx.py | Apache-2.0 |
def __init__(self, model: str = "grok-2-latest", **kwargs):
"""
Initialize an X.AI language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "grok-2-latest".
**kwargs: Additional keyword arguments to pass to the OpenAI client.
... |
Initialize an X.AI language model client.
Args:
model (str, optional): The model identifier to use. Defaults to "grok-2-latest".
**kwargs: Additional keyword arguments to pass to the OpenAI client.
- api_key: X.AI API key. If not provided, uses XAI_API_KEY envir... | __init__ | python | zilliztech/deep-searcher | deepsearcher/llm/xai.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/xai.py | Apache-2.0 |
def chat(self, messages: List[Dict]) -> ChatResponse:
"""
Send a chat message to the X.AI model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
... |
Send a chat message to the X.AI model and get a response.
Args:
messages (List[Dict]): A list of message dictionaries, typically in the format
[{"role": "system", "content": "..."},
{"role": "user", "content": "..."}]
... | chat | python | zilliztech/deep-searcher | deepsearcher/llm/xai.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/xai.py | Apache-2.0 |
def __init__(
self,
text: str,
reference: str,
metadata: dict = None,
embedding: List[float] = None,
):
"""
Initialize a Chunk object.
Args:
text: The text content of the chunk.
reference: A reference to the source of the chunk... |
Initialize a Chunk object.
Args:
text: The text content of the chunk.
reference: A reference to the source of the chunk.
metadata: Additional metadata associated with the chunk. Defaults to an empty dict.
embedding: The vector embedding of the chunk. Def... | __init__ | python | zilliztech/deep-searcher | deepsearcher/loader/splitter.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/splitter.py | Apache-2.0 |
def _sentence_window_split(
split_docs: List[Document], original_document: Document, offset: int = 200
) -> List[Chunk]:
"""
Create chunks with context windows from split documents.
This function takes documents that have been split into smaller pieces and
adds context from the original document by... |
Create chunks with context windows from split documents.
This function takes documents that have been split into smaller pieces and
adds context from the original document by including text before and after
each split piece, up to the specified offset.
Args:
split_docs: List of documents ... | _sentence_window_split | python | zilliztech/deep-searcher | deepsearcher/loader/splitter.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/splitter.py | Apache-2.0 |
def split_docs_to_chunks(
documents: List[Document], chunk_size: int = 1500, chunk_overlap=100
) -> List[Chunk]:
"""
Split documents into chunks with context windows.
This function splits a list of documents into smaller chunks with overlapping text,
and adds context windows to each chunk by includ... |
Split documents into chunks with context windows.
This function splits a list of documents into smaller chunks with overlapping text,
and adds context windows to each chunk by including text before and after the chunk.
Args:
documents: List of documents to split.
chunk_size: Size of e... | split_docs_to_chunks | python | zilliztech/deep-searcher | deepsearcher/loader/splitter.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/splitter.py | Apache-2.0 |
def load_directory(self, directory: str) -> List[Document]:
"""
Load all supported files from a directory and its subdirectories recursively.
Args:
directory: Path to the directory containing files to be loaded.
Returns:
A list of Document objects from all suppo... |
Load all supported files from a directory and its subdirectories recursively.
Args:
directory: Path to the directory containing files to be loaded.
Returns:
A list of Document objects from all supported files in the directory and subdirectories.
| load_directory | python | zilliztech/deep-searcher | deepsearcher/loader/file_loader/base.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/file_loader/base.py | Apache-2.0 |
def __init__(self):
"""
Initialize the DoclingLoader with DocumentConverter and HierarchicalChunker instances.
"""
from docling.document_converter import DocumentConverter
from docling_core.transforms.chunker import HierarchicalChunker
self.converter = DocumentConverter(... |
Initialize the DoclingLoader with DocumentConverter and HierarchicalChunker instances.
| __init__ | python | zilliztech/deep-searcher | deepsearcher/loader/file_loader/docling_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/file_loader/docling_loader.py | Apache-2.0 |
def load_file(self, file_path: str) -> List[Document]:
"""
Load a local file (or URL) using docling's conversion and perform hierarchical chunking.
Args:
file_path: Path or URL of the file to be loaded.
Returns:
A list of Document objects, each representing a ch... |
Load a local file (or URL) using docling's conversion and perform hierarchical chunking.
Args:
file_path: Path or URL of the file to be loaded.
Returns:
A list of Document objects, each representing a chunk.
Raises:
FileNotFoundError: If the file d... | load_file | python | zilliztech/deep-searcher | deepsearcher/loader/file_loader/docling_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/file_loader/docling_loader.py | Apache-2.0 |
def load_directory(self, directory: str) -> List[Document]:
"""
Load all supported files from a directory.
Args:
directory: Path to the directory containing files to be loaded.
Returns:
A list of Document objects from all supported files in the directory.
... |
Load all supported files from a directory.
Args:
directory: Path to the directory containing files to be loaded.
Returns:
A list of Document objects from all supported files in the directory.
Raises:
NotADirectoryError: If the specified path is not... | load_directory | python | zilliztech/deep-searcher | deepsearcher/loader/file_loader/docling_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/file_loader/docling_loader.py | Apache-2.0 |
def supported_file_types(self) -> List[str]:
"""
Return the list of file extensions supported by this loader.
Supported formats (refer to the official website: https://docling-project.github.io/docling/usage/supported_formats/):
- PDF
- Office formats: DOCX, XLSX, PPTX
-... |
Return the list of file extensions supported by this loader.
Supported formats (refer to the official website: https://docling-project.github.io/docling/usage/supported_formats/):
- PDF
- Office formats: DOCX, XLSX, PPTX
- Markdown
- AsciiDoc
- HTML, XHTML
... | supported_file_types | python | zilliztech/deep-searcher | deepsearcher/loader/file_loader/docling_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/file_loader/docling_loader.py | Apache-2.0 |
def load_file(self, file_path: str) -> List[Document]:
"""
Load a JSON or JSONL file and convert it to Document objects.
Args:
file_path: Path to the JSON or JSONL file to be loaded.
Returns:
A list of Document objects, one for each entry in the JSON/JSONL file.... |
Load a JSON or JSONL file and convert it to Document objects.
Args:
file_path: Path to the JSON or JSONL file to be loaded.
Returns:
A list of Document objects, one for each entry in the JSON/JSONL file.
| load_file | python | zilliztech/deep-searcher | deepsearcher/loader/file_loader/json_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/file_loader/json_loader.py | Apache-2.0 |
def _read_json_file(self, file_path: str) -> list[dict]:
"""
Read and parse a JSON file.
Args:
file_path: Path to the JSON file.
Returns:
A list of dictionaries parsed from the JSON file.
Raises:
ValueError: If the JSON file does not contain... |
Read and parse a JSON file.
Args:
file_path: Path to the JSON file.
Returns:
A list of dictionaries parsed from the JSON file.
Raises:
ValueError: If the JSON file does not contain a list of dictionaries.
| _read_json_file | python | zilliztech/deep-searcher | deepsearcher/loader/file_loader/json_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/file_loader/json_loader.py | Apache-2.0 |
def _read_jsonl_file(self, file_path: str) -> List[dict]:
"""
Read and parse a JSONL file (JSON Lines format).
Args:
file_path: Path to the JSONL file.
Returns:
A list of dictionaries parsed from the JSONL file.
"""
data_list = []
with op... |
Read and parse a JSONL file (JSON Lines format).
Args:
file_path: Path to the JSONL file.
Returns:
A list of dictionaries parsed from the JSONL file.
| _read_jsonl_file | python | zilliztech/deep-searcher | deepsearcher/loader/file_loader/json_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/file_loader/json_loader.py | Apache-2.0 |
def load_file(self, file_path: str) -> List[Document]:
"""
Load a PDF file and convert it to a Document object.
Args:
file_path: Path to the PDF file to be loaded.
Returns:
A list containing a single Document object with the file content and reference.
... |
Load a PDF file and convert it to a Document object.
Args:
file_path: Path to the PDF file to be loaded.
Returns:
A list containing a single Document object with the file content and reference.
Note:
This loader also supports .txt and .md files for... | load_file | python | zilliztech/deep-searcher | deepsearcher/loader/file_loader/pdf_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/file_loader/pdf_loader.py | Apache-2.0 |
def load_file(self, file_path: str) -> List[Document]:
"""
Load a text file and convert it to a Document object.
Args:
file_path: Path to the text file to be loaded.
Returns:
A list containing a single Document object with the file content and reference.
... |
Load a text file and convert it to a Document object.
Args:
file_path: Path to the text file to be loaded.
Returns:
A list containing a single Document object with the file content and reference.
| load_file | python | zilliztech/deep-searcher | deepsearcher/loader/file_loader/text_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/file_loader/text_loader.py | Apache-2.0 |
def __init__(self):
"""
Initialize the UnstructuredLoader.
Creates a temporary directory for processed outputs and cleans up any existing ones.
"""
self.directory_with_results = "./pdf_processed_outputs"
if os.path.exists(self.directory_with_results):
shutil.... |
Initialize the UnstructuredLoader.
Creates a temporary directory for processed outputs and cleans up any existing ones.
| __init__ | python | zilliztech/deep-searcher | deepsearcher/loader/file_loader/unstructured_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/file_loader/unstructured_loader.py | Apache-2.0 |
def load_pipeline(self, input_path: str) -> List[Document]:
"""
Process documents using the unstructured-io pipeline.
Args:
input_path: Path to the file or directory to be processed.
Returns:
A list of Document objects extracted from the processed files.
... |
Process documents using the unstructured-io pipeline.
Args:
input_path: Path to the file or directory to be processed.
Returns:
A list of Document objects extracted from the processed files.
Note:
If UNSTRUCTURED_API_KEY and UNSTRUCTURED_API_URL en... | load_pipeline | python | zilliztech/deep-searcher | deepsearcher/loader/file_loader/unstructured_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/file_loader/unstructured_loader.py | Apache-2.0 |
def supported_file_types(self) -> List[str]:
"""
Get the list of file extensions supported by the unstructured-io library. Please refer to the Unstructured documentation for more details: https://docs.unstructured.io/ui/supported-file-types.
Returns:
A comprehensive list of supporte... |
Get the list of file extensions supported by the unstructured-io library. Please refer to the Unstructured documentation for more details: https://docs.unstructured.io/ui/supported-file-types.
Returns:
A comprehensive list of supported file extensions.
Note:
The unstru... | supported_file_types | python | zilliztech/deep-searcher | deepsearcher/loader/file_loader/unstructured_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/file_loader/unstructured_loader.py | Apache-2.0 |
def crawl_urls(self, urls: List[str], **crawl_kwargs) -> List[Document]:
"""
Crawl multiple URLs and return a list of Document objects.
Args:
urls: A list of URLs to crawl.
**crawl_kwargs: Optional keyword arguments for the crawling process.
Returns:
... |
Crawl multiple URLs and return a list of Document objects.
Args:
urls: A list of URLs to crawl.
**crawl_kwargs: Optional keyword arguments for the crawling process.
Returns:
A list of Document objects containing the content and metadata from all URLs.
... | crawl_urls | python | zilliztech/deep-searcher | deepsearcher/loader/web_crawler/base.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/web_crawler/base.py | Apache-2.0 |
def __init__(self, **kwargs):
"""
Initialize the Crawl4AICrawler.
Args:
**kwargs: Optional keyword arguments.
browser_config: Configuration for the browser used by Crawl4AI.
"""
super().__init__(**kwargs)
self.crawler = None # Lazy init
... |
Initialize the Crawl4AICrawler.
Args:
**kwargs: Optional keyword arguments.
browser_config: Configuration for the browser used by Crawl4AI.
| __init__ | python | zilliztech/deep-searcher | deepsearcher/loader/web_crawler/crawl4ai_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/web_crawler/crawl4ai_crawler.py | Apache-2.0 |
def _lazy_init(self):
"""
Initialize the crawler lazily when needed.
This method creates the AsyncWebCrawler instance with the provided browser configuration
only when it's first needed, to avoid unnecessary initialization.
"""
from crawl4ai import AsyncWebCrawler, Brows... |
Initialize the crawler lazily when needed.
This method creates the AsyncWebCrawler instance with the provided browser configuration
only when it's first needed, to avoid unnecessary initialization.
| _lazy_init | python | zilliztech/deep-searcher | deepsearcher/loader/web_crawler/crawl4ai_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/web_crawler/crawl4ai_crawler.py | Apache-2.0 |
async def _async_crawl(self, url: str) -> Document:
"""
Asynchronously crawl a single URL.
Args:
url: The URL to crawl.
Returns:
A Document object with the markdown content and metadata from the URL.
"""
if self.crawler is None:
self.... |
Asynchronously crawl a single URL.
Args:
url: The URL to crawl.
Returns:
A Document object with the markdown content and metadata from the URL.
| _async_crawl | python | zilliztech/deep-searcher | deepsearcher/loader/web_crawler/crawl4ai_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/web_crawler/crawl4ai_crawler.py | Apache-2.0 |
def crawl_url(self, url: str) -> List[Document]:
"""
Crawl a single URL.
Args:
url: The URL to crawl.
Returns:
A list containing a single Document object with the markdown content and metadata,
or an empty list if an error occurs.
"""
... |
Crawl a single URL.
Args:
url: The URL to crawl.
Returns:
A list containing a single Document object with the markdown content and metadata,
or an empty list if an error occurs.
| crawl_url | python | zilliztech/deep-searcher | deepsearcher/loader/web_crawler/crawl4ai_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/web_crawler/crawl4ai_crawler.py | Apache-2.0 |
async def _async_crawl_many(self, urls: List[str]) -> List[Document]:
"""
Asynchronously crawl multiple URLs.
Args:
urls: A list of URLs to crawl.
Returns:
A list of Document objects with the markdown content and metadata from all URLs.
"""
if se... |
Asynchronously crawl multiple URLs.
Args:
urls: A list of URLs to crawl.
Returns:
A list of Document objects with the markdown content and metadata from all URLs.
| _async_crawl_many | python | zilliztech/deep-searcher | deepsearcher/loader/web_crawler/crawl4ai_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/web_crawler/crawl4ai_crawler.py | Apache-2.0 |
def crawl_urls(self, urls: List[str], **crawl_kwargs) -> List[Document]:
"""
Crawl multiple URLs.
Args:
urls: A list of URLs to crawl.
**crawl_kwargs: Optional keyword arguments for the crawling process.
Returns:
A list of Document objects with the m... |
Crawl multiple URLs.
Args:
urls: A list of URLs to crawl.
**crawl_kwargs: Optional keyword arguments for the crawling process.
Returns:
A list of Document objects with the markdown content and metadata from all URLs,
or an empty list if an error... | crawl_urls | python | zilliztech/deep-searcher | deepsearcher/loader/web_crawler/crawl4ai_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/web_crawler/crawl4ai_crawler.py | Apache-2.0 |
def __init__(self, **kwargs):
"""
Initialize the DoclingCrawler with DocumentConverter and HierarchicalChunker instances.
Args:
**kwargs: Optional keyword arguments.
"""
super().__init__(**kwargs)
from docling.document_converter import DocumentConverter
... |
Initialize the DoclingCrawler with DocumentConverter and HierarchicalChunker instances.
Args:
**kwargs: Optional keyword arguments.
| __init__ | python | zilliztech/deep-searcher | deepsearcher/loader/web_crawler/docling_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/web_crawler/docling_crawler.py | Apache-2.0 |
def crawl_url(self, url: str, **crawl_kwargs) -> List[Document]:
"""
Crawl a single URL using Docling's conversion and perform hierarchical chunking.
Args:
url: The URL to crawl.
**crawl_kwargs: Optional keyword arguments for the crawling process.
Returns:
... |
Crawl a single URL using Docling's conversion and perform hierarchical chunking.
Args:
url: The URL to crawl.
**crawl_kwargs: Optional keyword arguments for the crawling process.
Returns:
A list of Document objects, each representing a chunk from the crawle... | crawl_url | python | zilliztech/deep-searcher | deepsearcher/loader/web_crawler/docling_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/web_crawler/docling_crawler.py | Apache-2.0 |
def supported_file_types(self) -> List[str]:
"""
Return the list of file types and formats supported by Docling.
Supported formats (refer to the official Docling documentation: https://docling-project.github.io/docling/usage/supported_formats/):
- PDF
- Office formats: DOCX, XLS... |
Return the list of file types and formats supported by Docling.
Supported formats (refer to the official Docling documentation: https://docling-project.github.io/docling/usage/supported_formats/):
- PDF
- Office formats: DOCX, XLSX, PPTX
- Markdown
- AsciiDoc
- ... | supported_file_types | python | zilliztech/deep-searcher | deepsearcher/loader/web_crawler/docling_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/web_crawler/docling_crawler.py | Apache-2.0 |
def __init__(self, **kwargs):
"""
Initialize the FireCrawlCrawler.
Args:
**kwargs: Optional keyword arguments.
"""
super().__init__(**kwargs)
self.app = None |
Initialize the FireCrawlCrawler.
Args:
**kwargs: Optional keyword arguments.
| __init__ | python | zilliztech/deep-searcher | deepsearcher/loader/web_crawler/firecrawl_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/web_crawler/firecrawl_crawler.py | Apache-2.0 |
def __init__(self, **kwargs):
"""
Initialize the JinaCrawler.
Args:
**kwargs: Optional keyword arguments.
Raises:
ValueError: If the JINA_API_TOKEN environment variable is not set.
"""
super().__init__(**kwargs)
self.jina_api_token = os.g... |
Initialize the JinaCrawler.
Args:
**kwargs: Optional keyword arguments.
Raises:
ValueError: If the JINA_API_TOKEN environment variable is not set.
| __init__ | python | zilliztech/deep-searcher | deepsearcher/loader/web_crawler/jina_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/web_crawler/jina_crawler.py | Apache-2.0 |
def crawl_url(self, url: str) -> List[Document]:
"""
Crawl a single URL using Jina AI's rendering service.
Args:
url: The URL to crawl.
Returns:
A list containing a single Document object with the markdown content and metadata.
Raises:
HTTPE... |
Crawl a single URL using Jina AI's rendering service.
Args:
url: The URL to crawl.
Returns:
A list containing a single Document object with the markdown content and metadata.
Raises:
HTTPError: If the request to Jina AI's service fails.
| crawl_url | python | zilliztech/deep-searcher | deepsearcher/loader/web_crawler/jina_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/loader/web_crawler/jina_crawler.py | Apache-2.0 |
def format(self, record):
"""
Format a log record with colors.
Args:
record: The log record to format.
Returns:
The formatted log message with colors.
"""
# all line in log will be colored
log_message = super().format(record)
retu... |
Format a log record with colors.
Args:
record: The log record to format.
Returns:
The formatted log message with colors.
| format | python | zilliztech/deep-searcher | deepsearcher/utils/log.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/utils/log.py | Apache-2.0 |
def set_dev_mode(mode: bool):
"""
Set the development mode.
When in development mode, debug, info, and warning logs are displayed.
When not in development mode, only error and critical logs are displayed.
Args:
mode: True to enable development mode, False to disable it.
"""
global ... |
Set the development mode.
When in development mode, debug, info, and warning logs are displayed.
When not in development mode, only error and critical logs are displayed.
Args:
mode: True to enable development mode, False to disable it.
| set_dev_mode | python | zilliztech/deep-searcher | deepsearcher/utils/log.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/utils/log.py | Apache-2.0 |
def init_collection(self):
"""Initialize Azure Search index with proper schema"""
from azure.core.credentials import AzureKeyCredential
from azure.core.exceptions import ResourceNotFoundError
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents... | Initialize Azure Search index with proper schema | init_collection | python | zilliztech/deep-searcher | deepsearcher/vector_db/azure_search.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/azure_search.py | Apache-2.0 |
def insert_data(self, documents: List[dict]):
"""Batch insert documents with vector embeddings"""
from azure.core.credentials import AzureKeyCredential
from azure.search.documents import SearchClient
search_client = SearchClient(
endpoint=self.endpoint,
index_nam... | Batch insert documents with vector embeddings | insert_data | python | zilliztech/deep-searcher | deepsearcher/vector_db/azure_search.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/azure_search.py | Apache-2.0 |
def search_data(
self, collection: Optional[str], vector: List[float], top_k: int = 50
) -> List[RetrievalResult]:
"""Azure Cognitive Search implementation with compatibility for older SDK versions"""
from azure.core.credentials import AzureKeyCredential
from azure.search.documents i... | Azure Cognitive Search implementation with compatibility for older SDK versions | search_data | python | zilliztech/deep-searcher | deepsearcher/vector_db/azure_search.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/azure_search.py | Apache-2.0 |
def clear_db(self):
"""Delete all documents in the index"""
from azure.core.credentials import AzureKeyCredential
from azure.search.documents import SearchClient
search_client = SearchClient(
endpoint=self.endpoint,
index_name=self.index_name,
credent... | Delete all documents in the index | clear_db | python | zilliztech/deep-searcher | deepsearcher/vector_db/azure_search.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/azure_search.py | Apache-2.0 |
def get_all_collections(self) -> List[str]:
"""List all search indices in Azure Cognitive Search"""
from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes import SearchIndexClient
try:
index_client = SearchIndexClient(
endpo... | List all search indices in Azure Cognitive Search | get_all_collections | python | zilliztech/deep-searcher | deepsearcher/vector_db/azure_search.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/azure_search.py | Apache-2.0 |
def list_collections(self, *args, **kwargs) -> List[CollectionInfo]:
"""List all Azure Search indices with metadata"""
from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes import SearchIndexClient
try:
index_client = SearchIndexClient(
... | List all Azure Search indices with metadata | list_collections | python | zilliztech/deep-searcher | deepsearcher/vector_db/azure_search.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/azure_search.py | Apache-2.0 |
def __init__(
self,
embedding: np.array,
text: str,
reference: str,
metadata: dict,
score: float = 0.0,
):
"""
Initialize a RetrievalResult object.
Args:
embedding: The vector embedding of the document.
text: The text c... |
Initialize a RetrievalResult object.
Args:
embedding: The vector embedding of the document.
text: The text content of the document.
reference: A reference to the source of the document.
metadata: Additional metadata associated with the document.
... | __init__ | python | zilliztech/deep-searcher | deepsearcher/vector_db/base.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/base.py | Apache-2.0 |
def deduplicate_results(results: List[RetrievalResult]) -> List[RetrievalResult]:
"""
Remove duplicate results based on text content.
This function removes duplicate results from a list of RetrievalResult objects
by keeping only the first occurrence of each unique text content.
Args:
resul... |
Remove duplicate results based on text content.
This function removes duplicate results from a list of RetrievalResult objects
by keeping only the first occurrence of each unique text content.
Args:
results: A list of RetrievalResult objects to deduplicate.
Returns:
A list of ded... | deduplicate_results | python | zilliztech/deep-searcher | deepsearcher/vector_db/base.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/base.py | Apache-2.0 |
def __init__(self, collection_name: str, description: str):
"""
Initialize a CollectionInfo object.
Args:
collection_name: The name of the collection.
description: The description of the collection.
"""
self.collection_name = collection_name
self.... |
Initialize a CollectionInfo object.
Args:
collection_name: The name of the collection.
description: The description of the collection.
| __init__ | python | zilliztech/deep-searcher | deepsearcher/vector_db/base.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/base.py | Apache-2.0 |
def __init__(
self,
default_collection: str = "deepsearcher",
*args,
**kwargs,
):
"""
Initialize a BaseVectorDB object.
Args:
default_collection: The name of the default collection. Defaults to "deepsearcher".
*args: Variable length ar... |
Initialize a BaseVectorDB object.
Args:
default_collection: The name of the default collection. Defaults to "deepsearcher".
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
| __init__ | python | zilliztech/deep-searcher | deepsearcher/vector_db/base.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/base.py | Apache-2.0 |
def init_collection(
self,
dim: int,
collection: str,
description: str,
force_new_collection=False,
*args,
**kwargs,
):
"""
Initialize a collection in the vector database.
Args:
dim: The dimensionality of the vectors in the... |
Initialize a collection in the vector database.
Args:
dim: The dimensionality of the vectors in the collection.
collection: The name of the collection.
description: The description of the collection.
force_new_collection: If True, drop the existing colle... | init_collection | python | zilliztech/deep-searcher | deepsearcher/vector_db/base.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/base.py | Apache-2.0 |
def search_data(
self, collection: str, vector: Union[np.array, List[float]], *args, **kwargs
) -> List[RetrievalResult]:
"""
Search for similar vectors in a collection.
Args:
collection: The name of the collection.
vector: The query vector to search for.
... |
Search for similar vectors in a collection.
Args:
collection: The name of the collection.
vector: The query vector to search for.
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
Returns:
A list of Retriev... | search_data | python | zilliztech/deep-searcher | deepsearcher/vector_db/base.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/base.py | Apache-2.0 |
def __init__(
self,
default_collection: str = "deepsearcher",
uri: str = "http://localhost:19530",
token: str = "root:Milvus",
user: str = "",
password: str = "",
db: str = "default",
hybrid: bool = False,
**kwargs,
):
"""
Initi... |
Initialize the Milvus client.
Args:
default_collection (str, optional): Default collection name. Defaults to "deepsearcher".
uri (str, optional): URI for connecting to Milvus server. Defaults to "http://localhost:19530".
token (str, optional): Authentication token f... | __init__ | python | zilliztech/deep-searcher | deepsearcher/vector_db/milvus.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/milvus.py | Apache-2.0 |
def init_collection(
self,
dim: int,
collection: Optional[str] = "deepsearcher",
description: Optional[str] = "",
force_new_collection: bool = False,
text_max_length: int = 65_535,
reference_max_length: int = 2048,
metric_type: str = "L2",
*args,
... |
Initialize a collection in Milvus.
Args:
dim (int): Dimension of the vector embeddings.
collection (Optional[str], optional): Collection name. Defaults to "deepsearcher".
description (Optional[str], optional): Collection description. Defaults to "".
forc... | init_collection | python | zilliztech/deep-searcher | deepsearcher/vector_db/milvus.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/milvus.py | Apache-2.0 |
def insert_data(
self,
collection: Optional[str],
chunks: List[Chunk],
batch_size: int = 256,
*args,
**kwargs,
):
"""
Insert data into a Milvus collection.
Args:
collection (Optional[str]): Collection name. If None, uses default_co... |
Insert data into a Milvus collection.
Args:
collection (Optional[str]): Collection name. If None, uses default_collection.
chunks (List[Chunk]): List of Chunk objects to insert.
batch_size (int, optional): Number of chunks to insert in each batch. Defaults to 256.
... | insert_data | python | zilliztech/deep-searcher | deepsearcher/vector_db/milvus.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/milvus.py | Apache-2.0 |
def search_data(
self,
collection: Optional[str],
vector: Union[np.array, List[float]],
top_k: int = 5,
query_text: Optional[str] = None,
*args,
**kwargs,
) -> List[RetrievalResult]:
"""
Search for similar vectors in a Milvus collection.
... |
Search for similar vectors in a Milvus collection.
Args:
collection (Optional[str]): Collection name. If None, uses default_collection.
vector (Union[np.array, List[float]]): Query vector for similarity search.
top_k (int, optional): Number of results to return. Def... | search_data | python | zilliztech/deep-searcher | deepsearcher/vector_db/milvus.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/milvus.py | Apache-2.0 |
def list_collections(self, *args, **kwargs) -> List[CollectionInfo]:
"""
List all collections in the Milvus database.
Args:
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
Returns:
List[CollectionInfo]: List of collection... |
List all collections in the Milvus database.
Args:
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
Returns:
List[CollectionInfo]: List of collection information objects.
| list_collections | python | zilliztech/deep-searcher | deepsearcher/vector_db/milvus.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/milvus.py | Apache-2.0 |
def clear_db(self, collection: str = "deepsearcher", *args, **kwargs):
"""
Clear (drop) a collection from the Milvus database.
Args:
collection (str, optional): Collection name to drop. Defaults to "deepsearcher".
*args: Variable length argument list.
**kwarg... |
Clear (drop) a collection from the Milvus database.
Args:
collection (str, optional): Collection name to drop. Defaults to "deepsearcher".
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
| clear_db | python | zilliztech/deep-searcher | deepsearcher/vector_db/milvus.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/milvus.py | Apache-2.0 |
def __init__(
self,
user: str,
password: str,
dsn: str,
config_dir: str,
wallet_location: str,
wallet_password: str,
min: int = 1,
max: int = 10,
increment: int = 1,
default_collection: str = "deepsearcher",
):
"""
... |
Initialize the Oracle database connection.
Args:
user (str): Oracle database username.
password (str): Oracle database password.
dsn (str): Oracle database connection string.
config_dir (str): Directory containing Oracle configuration files.
... | __init__ | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def numpy_converter_in(self, value):
"""Convert numpy array to array.array"""
if value.dtype == np.float64:
dtype = "d"
elif value.dtype == np.float32:
dtype = "f"
else:
dtype = "b"
return array.array(dtype, value) | Convert numpy array to array.array | numpy_converter_in | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def input_type_handler(self, cursor, value, arraysize):
"""Set the type handler for the input data"""
if isinstance(value, np.ndarray):
return cursor.var(
self.DB_TYPE_VECTOR,
arraysize=arraysize,
inconverter=self.numpy_converter_in,
... | Set the type handler for the input data | input_type_handler | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def numpy_converter_out(self, value):
"""Convert array.array to numpy array"""
if value.typecode == "b":
dtype = np.int8
elif value.typecode == "f":
dtype = np.float32
else:
dtype = np.float64
return np.array(value, copy=False, dtype=dtype) | Convert array.array to numpy array | numpy_converter_out | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def output_type_handler(self, cursor, metadata):
"""Set the type handler for the output data"""
if metadata.type_code is self.DB_TYPE_VECTOR:
return cursor.var(
metadata.type_code,
arraysize=cursor.arraysize,
outconverter=self.numpy_converter_o... | Set the type handler for the output data | output_type_handler | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def query(self, sql: str, params: dict = None) -> Union[dict, None]:
"""
Execute a SQL query and return the results.
Args:
sql (str): SQL query to execute.
params (dict, optional): Parameters for the SQL query. Defaults to None.
Returns:
Union[dict, ... |
Execute a SQL query and return the results.
Args:
sql (str): SQL query to execute.
params (dict, optional): Parameters for the SQL query. Defaults to None.
Returns:
Union[dict, None]: Query results as a dictionary or None if no results.
Raises:
... | query | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def execute(self, sql: str, data: Union[list, dict] = None):
"""
Execute a SQL statement without returning results.
Args:
sql (str): SQL statement to execute.
data (Union[list, dict], optional): Data for the SQL statement. Defaults to None.
Raises:
E... |
Execute a SQL statement without returning results.
Args:
sql (str): SQL statement to execute.
data (Union[list, dict], optional): Data for the SQL statement. Defaults to None.
Raises:
Exception: If there's an error executing the statement.
| execute | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def has_collection(self, collection: str = "deepsearcher"):
"""
Check if a collection exists in the database.
Args:
collection (str, optional): Collection name to check. Defaults to "deepsearcher".
Returns:
bool: True if the collection exists, False otherwise.
... |
Check if a collection exists in the database.
Args:
collection (str, optional): Collection name to check. Defaults to "deepsearcher".
Returns:
bool: True if the collection exists, False otherwise.
| has_collection | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def check_table(self):
"""
Check if required tables exist and create them if they don't.
Raises:
Exception: If there's an error checking or creating tables.
"""
SQL = SQL_TEMPLATES["has_table"]
try:
res = self.query(SQL)
if len(res) < ... |
Check if required tables exist and create them if they don't.
Raises:
Exception: If there's an error checking or creating tables.
| check_table | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def create_tables(self, table_name):
"""
Create a table in the database.
Args:
table_name: Name of the table to create.
Raises:
Exception: If there's an error creating the table.
"""
SQL = TABLES[table_name]
try:
self.execute(... |
Create a table in the database.
Args:
table_name: Name of the table to create.
Raises:
Exception: If there's an error creating the table.
| create_tables | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def drop_collection(self, collection: str = "deepsearcher"):
"""
Drop a collection from the database.
Args:
collection (str, optional): Collection name to drop. Defaults to "deepsearcher".
Raises:
Exception: If there's an error dropping the collection.
"... |
Drop a collection from the database.
Args:
collection (str, optional): Collection name to drop. Defaults to "deepsearcher".
Raises:
Exception: If there's an error dropping the collection.
| drop_collection | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def insertone(self, data):
"""
Insert a single record into the database.
Args:
data: Data to insert.
"""
SQL = SQL_TEMPLATES["insert"]
self.execute(SQL, data)
log.debug("insert done!") |
Insert a single record into the database.
Args:
data: Data to insert.
| insertone | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def searchone(
self,
collection: Optional[str],
vector: Union[np.array, List[float]],
top_k: int = 5,
):
"""
Search for similar vectors in a collection.
Args:
collection (Optional[str]): Collection name to search in.
vector (Union[np.a... |
Search for similar vectors in a collection.
Args:
collection (Optional[str]): Collection name to search in.
vector (Union[np.array, List[float]]): Query vector for similarity search.
top_k (int, optional): Number of results to return. Defaults to 5.
Returns... | searchone | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def init_collection(
self,
dim: int,
collection: Optional[str] = "deepsearcher",
description: Optional[str] = "",
force_new_collection: bool = False,
text_max_length: int = 65_535,
reference_max_length: int = 2048,
metric_type: str = "L2",
*args,
... |
Initialize a collection in the database.
Args:
dim (int): Dimension of the vector embeddings.
collection (Optional[str], optional): Collection name. Defaults to "deepsearcher".
description (Optional[str], optional): Collection description. Defaults to "".
... | init_collection | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def insert_data(
self,
collection: Optional[str],
chunks: List[Chunk],
batch_size: int = 256,
*args,
**kwargs,
):
"""
Insert data into a collection.
Args:
collection (Optional[str]): Collection name. If None, uses default_collectio... |
Insert data into a collection.
Args:
collection (Optional[str]): Collection name. If None, uses default_collection.
chunks (List[Chunk]): List of Chunk objects to insert.
batch_size (int, optional): Number of chunks to insert in each batch. Defaults to 256.
... | insert_data | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def search_data(
self,
collection: Optional[str],
vector: Union[np.array, List[float]],
top_k: int = 5,
*args,
**kwargs,
) -> List[RetrievalResult]:
"""
Search for similar vectors in a collection.
Args:
collection (Optional[str]): ... |
Search for similar vectors in a collection.
Args:
collection (Optional[str]): Collection name. If None, uses default_collection.
vector (Union[np.array, List[float]]): Query vector for similarity search.
top_k (int, optional): Number of results to return. Defaults t... | search_data | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def list_collections(self, *args, **kwargs) -> List[CollectionInfo]:
"""
List all collections in the database.
Args:
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
Returns:
List[CollectionInfo]: List of collection inform... |
List all collections in the database.
Args:
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
Returns:
List[CollectionInfo]: List of collection information objects.
| list_collections | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def clear_db(self, collection: str = "deepsearcher", *args, **kwargs):
"""
Clear (drop) a collection from the database.
Args:
collection (str, optional): Collection name to drop. Defaults to "deepsearcher".
*args: Variable length argument list.
**kwargs: Arbi... |
Clear (drop) a collection from the database.
Args:
collection (str, optional): Collection name to drop. Defaults to "deepsearcher".
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
| clear_db | python | zilliztech/deep-searcher | deepsearcher/vector_db/oracle.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/oracle.py | Apache-2.0 |
def init_collection(
self,
dim: int,
collection: Optional[str] = None,
description: Optional[str] = "",
force_new_collection: bool = False,
text_max_length: int = 65_535,
reference_max_length: int = 2048,
distance_metric: str = "Cosine",
*args,
... |
Initialize a collection in Qdrant.
Args:
dim (int): Dimension of the vector embeddings.
collection (Optional[str], optional): Collection name.
description (Optional[str], optional): Collection description. Defaults to "".
force_new_collection (bool, opti... | init_collection | python | zilliztech/deep-searcher | deepsearcher/vector_db/qdrant.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/qdrant.py | Apache-2.0 |
def insert_data(
self,
collection: Optional[str],
chunks: List[Chunk],
batch_size: int = 256,
*args,
**kwargs,
):
"""
Insert data into a Qdrant collection.
Args:
collection (Optional[str]): Collection name.
chunks (List... |
Insert data into a Qdrant collection.
Args:
collection (Optional[str]): Collection name.
chunks (List[Chunk]): List of Chunk objects to insert.
batch_size (int, optional): Number of chunks to insert in each batch. Defaults to 256.
*args: Variable length ... | insert_data | python | zilliztech/deep-searcher | deepsearcher/vector_db/qdrant.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/qdrant.py | Apache-2.0 |
def search_data(
self,
collection: Optional[str],
vector: Union[np.array, List[float]],
top_k: int = 5,
*args,
**kwargs,
) -> List[RetrievalResult]:
"""
Search for similar vectors in a Qdrant collection.
Args:
collection (Optional[... |
Search for similar vectors in a Qdrant collection.
Args:
collection (Optional[str]): Collection name..
vector (Union[np.array, List[float]]): Query vector for similarity search.
top_k (int, optional): Number of results to return. Defaults to 5.
*args: Va... | search_data | python | zilliztech/deep-searcher | deepsearcher/vector_db/qdrant.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/qdrant.py | Apache-2.0 |
def list_collections(self, *args, **kwargs) -> List[CollectionInfo]:
"""
List all collections in the Qdrant database.
Args:
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
Returns:
List[CollectionInfo]: List of collection... |
List all collections in the Qdrant database.
Args:
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
Returns:
List[CollectionInfo]: List of collection information objects.
| list_collections | python | zilliztech/deep-searcher | deepsearcher/vector_db/qdrant.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/qdrant.py | Apache-2.0 |
def clear_db(self, collection: Optional[str] = None, *args, **kwargs):
"""
Clear (drop) a collection from the Qdrant database.
Args:
collection (str, optional): Collection name to drop.
*args: Variable length argument list.
**kwargs: Arbitrary keyword argumen... |
Clear (drop) a collection from the Qdrant database.
Args:
collection (str, optional): Collection name to drop.
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
| clear_db | python | zilliztech/deep-searcher | deepsearcher/vector_db/qdrant.py | https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/vector_db/qdrant.py | Apache-2.0 |
def _deepsearch_retrieve_titles(
question: str,
retry_num: int = 4,
base_wait_time: int = 4,
max_iter: int = 3,
) -> Tuple[List[str], int, bool]:
"""
Retrieve document titles using DeepSearcher with retry mechanism.
Args:
question (str): The query question.
retry_num (int, o... |
Retrieve document titles using DeepSearcher with retry mechanism.
Args:
question (str): The query question.
retry_num (int, optional): Number of retry attempts. Defaults to 4.
base_wait_time (int, optional): Base wait time between retries in seconds. Defaults to 4.
max_iter (in... | _deepsearch_retrieve_titles | python | zilliztech/deep-searcher | evaluation/evaluate.py | https://github.com/zilliztech/deep-searcher/blob/master/evaluation/evaluate.py | Apache-2.0 |
def _naive_retrieve_titles(question: str) -> List[str]:
"""
Retrieve document titles using naive retrieval method.
Args:
question (str): The query question.
Returns:
List[str]: List of retrieved document titles.
"""
retrieved_results = naive_retrieve(question)
retrieved_tit... |
Retrieve document titles using naive retrieval method.
Args:
question (str): The query question.
Returns:
List[str]: List of retrieved document titles.
| _naive_retrieve_titles | python | zilliztech/deep-searcher | evaluation/evaluate.py | https://github.com/zilliztech/deep-searcher/blob/master/evaluation/evaluate.py | Apache-2.0 |
def _calcu_recall(sample, retrieved_titles, dataset) -> dict:
"""
Calculate recall metrics for retrieved titles.
Args:
sample: The sample data containing ground truth information.
retrieved_titles: List of retrieved document titles.
dataset (str): The name of the dataset being evalu... |
Calculate recall metrics for retrieved titles.
Args:
sample: The sample data containing ground truth information.
retrieved_titles: List of retrieved document titles.
dataset (str): The name of the dataset being evaluated.
Returns:
dict: Dictionary containing recall values... | _calcu_recall | python | zilliztech/deep-searcher | evaluation/evaluate.py | https://github.com/zilliztech/deep-searcher/blob/master/evaluation/evaluate.py | Apache-2.0 |
def _print_recall_line(recall: dict, pre_str="", post_str="\n"):
"""
Print recall metrics in a formatted line.
Args:
recall (dict): Dictionary containing recall values at different k values.
pre_str (str, optional): String to print before recall values. Defaults to "".
post_str (str... |
Print recall metrics in a formatted line.
Args:
recall (dict): Dictionary containing recall values at different k values.
pre_str (str, optional): String to print before recall values. Defaults to "".
post_str (str, optional): String to print after recall values. Defaults to "
".
| _print_recall_line | python | zilliztech/deep-searcher | evaluation/evaluate.py | https://github.com/zilliztech/deep-searcher/blob/master/evaluation/evaluate.py | Apache-2.0 |
def evaluate(
dataset: str,
output_root: str,
pre_num: int = 10,
max_iter: int = 3,
skip_load=False,
flag: str = "result",
):
"""
Evaluate the retrieval performance on a dataset.
Args:
dataset (str): Name of the dataset to evaluate.
output_root (str): Root directory ... |
Evaluate the retrieval performance on a dataset.
Args:
dataset (str): Name of the dataset to evaluate.
output_root (str): Root directory for output files.
pre_num (int, optional): Number of samples to evaluate. Defaults to 10.
max_iter (int, optional): Maximum number of iterati... | evaluate | python | zilliztech/deep-searcher | evaluation/evaluate.py | https://github.com/zilliztech/deep-searcher/blob/master/evaluation/evaluate.py | Apache-2.0 |
def main_eval():
"""
Main function for running the evaluation from command line.
This function parses command line arguments and calls the evaluate function
with the appropriate parameters.
"""
parser = argparse.ArgumentParser(prog="evaluate", description="Deep Searcher evaluation.")
parser... |
Main function for running the evaluation from command line.
This function parses command line arguments and calls the evaluate function
with the appropriate parameters.
| main_eval | python | zilliztech/deep-searcher | evaluation/evaluate.py | https://github.com/zilliztech/deep-searcher/blob/master/evaluation/evaluate.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.