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 main():
"""Example of using WatsonX with DeepSearcher."""
# Initialize configuration
config = Configuration()
# Set up environment variables (alternatively, set these in your shell)
# os.environ["WATSONX_APIKEY"] = "your-watsonx-api-key"
# os.environ["WATSONX_URL"] = "https://your-watsonx-... | Example of using WatsonX with DeepSearcher. | main | python | zilliztech/deep-searcher | examples/basic_watsonx_example.py | https://github.com/zilliztech/deep-searcher/blob/master/examples/basic_watsonx_example.py | Apache-2.0 |
def __init__(self, predefined_responses=None):
"""
Initialize the MockLLM.
Args:
predefined_responses: Dictionary mapping prompt substrings to responses
"""
self.chat_called = False
self.last_messages = None
self.predefined_responses = predefi... |
Initialize the MockLLM.
Args:
predefined_responses: Dictionary mapping prompt substrings to responses
| __init__ | python | zilliztech/deep-searcher | tests/agent/test_base.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_base.py | Apache-2.0 |
def chat(self, messages, **kwargs):
"""Mock implementation of chat that returns predefined responses or a default response."""
self.chat_called = True
self.last_messages = messages
if self.predefined_responses:
message_content = messages[0]["content"] if messages els... | Mock implementation of chat that returns predefined responses or a default response. | chat | python | zilliztech/deep-searcher | tests/agent/test_base.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_base.py | Apache-2.0 |
def __init__(self, collections=None):
"""
Initialize the MockVectorDB.
Args:
collections: List of collection names to initialize with
"""
self.default_collection = "test_collection"
self.search_called = False
self.insert_called = False
... |
Initialize the MockVectorDB.
Args:
collections: List of collection names to initialize with
| __init__ | python | zilliztech/deep-searcher | tests/agent/test_base.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_base.py | Apache-2.0 |
def search_data(self, collection, vector, top_k=10, **kwargs):
"""Mock implementation that returns test results."""
self.search_called = True
self.last_search_collection = collection
self.last_search_vector = vector
self.last_search_top_k = top_k
return [
... | Mock implementation that returns test results. | search_data | python | zilliztech/deep-searcher | tests/agent/test_base.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_base.py | Apache-2.0 |
def setUp(self):
"""Set up test fixtures for agent tests."""
self.llm = MockLLM()
self.embedding_model = MockEmbedding(dimension=8)
self.vector_db = MockVectorDB() | Set up test fixtures for agent tests. | setUp | python | zilliztech/deep-searcher | tests/agent/test_base.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_base.py | Apache-2.0 |
def setUp(self):
"""Set up test fixtures for ChainOfRAG tests."""
super().setUp()
# Set up predefined responses for the LLM for exact prompt substrings
self.llm.predefined_responses = {
"previous queries and answers, generate a new simple follow-up question": "What i... | Set up test fixtures for ChainOfRAG tests. | setUp | python | zilliztech/deep-searcher | tests/agent/test_chain_of_rag.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_chain_of_rag.py | Apache-2.0 |
def setUp(self):
"""Set up test fixtures for CollectionRouter tests."""
super().setUp()
# Create mock collections
self.collection_infos = [
CollectionInfo(collection_name="books", description="Collection of book summaries"),
CollectionInfo(collection_name... | Set up test fixtures for CollectionRouter tests. | setUp | python | zilliztech/deep-searcher | tests/agent/test_collection_router.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_collection_router.py | Apache-2.0 |
def test_invoke_with_multiple_collections(self):
"""Test the invoke method with multiple collections."""
query = "What are the latest scientific breakthroughs?"
# Mock LLM to return specific collections based on query
self.llm.chat = MagicMock(return_value=ChatResponse(
... | Test the invoke method with multiple collections. | test_invoke_with_multiple_collections | python | zilliztech/deep-searcher | tests/agent/test_collection_router.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_collection_router.py | Apache-2.0 |
def test_invoke_with_empty_response(self):
"""Test the invoke method when LLM returns an empty list."""
query = "Something completely unrelated"
# Mock LLM to return empty list
self.llm.chat = MagicMock(return_value=ChatResponse(
content='[]',
total_token... | Test the invoke method when LLM returns an empty list. | test_invoke_with_empty_response | python | zilliztech/deep-searcher | tests/agent/test_collection_router.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_collection_router.py | Apache-2.0 |
def test_invoke_with_no_collections(self):
"""Test the invoke method when no collections are available."""
query = "Test query"
# Mock vector_db to return empty list
self.vector_db.list_collections = MagicMock(return_value=[])
# Disable log warnings for testing
... | Test the invoke method when no collections are available. | test_invoke_with_no_collections | python | zilliztech/deep-searcher | tests/agent/test_collection_router.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_collection_router.py | Apache-2.0 |
def test_invoke_with_single_collection(self):
"""Test the invoke method when only one collection is available."""
query = "Test query"
# Create a fresh mock for llm.chat to verify it's not called
mock_chat = MagicMock(return_value=ChatResponse(content='[]', total_tokens=0))
... | Test the invoke method when only one collection is available. | test_invoke_with_single_collection | python | zilliztech/deep-searcher | tests/agent/test_collection_router.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_collection_router.py | Apache-2.0 |
def test_invoke_with_no_description(self):
"""Test the invoke method when a collection has no description."""
query = "Test query"
# Create collections with one having no description
collections_with_no_desc = [
CollectionInfo(collection_name="with_desc", description... | Test the invoke method when a collection has no description. | test_invoke_with_no_description | python | zilliztech/deep-searcher | tests/agent/test_collection_router.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_collection_router.py | Apache-2.0 |
def setUp(self):
"""Set up test fixtures for DeepSearch tests."""
super().setUp()
# Set up predefined responses for the LLM for exact prompt substrings
self.llm.predefined_responses = {
"Original Question:": '["What is deep learning?", "How does deep learning work?",... | Set up test fixtures for DeepSearch tests. | setUp | python | zilliztech/deep-searcher | tests/agent/test_deep_search.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_deep_search.py | Apache-2.0 |
def test_query_no_results(self):
"""Test the query method when no results are found."""
query = "Tell me about deep learning"
# Mock the retrieve method to return no results
self.deep_search.retrieve = MagicMock(
return_value=([], 10, {"all_sub_queries": ["What is de... | Test the query method when no results are found. | test_query_no_results | python | zilliztech/deep-searcher | tests/agent/test_deep_search.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_deep_search.py | Apache-2.0 |
def setUp(self):
"""Set up test fixtures for NaiveRAG tests."""
super().setUp()
self.naive_rag = NaiveRAG(
llm=self.llm,
embedding_model=self.embedding_model,
vector_db=self.vector_db,
top_k=5,
route_collection=True,
text_wi... | Set up test fixtures for NaiveRAG tests. | setUp | python | zilliztech/deep-searcher | tests/agent/test_naive_rag.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_naive_rag.py | Apache-2.0 |
def test_retrieve_without_routing(self):
"""Test retrieve method with routing disabled."""
self.naive_rag.route_collection = False
query = "Test query without routing"
results, tokens, metadata = self.naive_rag.retrieve(query)
# Check that routing was not called... | Test retrieve method with routing disabled. | test_retrieve_without_routing | python | zilliztech/deep-searcher | tests/agent/test_naive_rag.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_naive_rag.py | Apache-2.0 |
def test_with_window_splitter_disabled(self):
"""Test with text window splitter disabled."""
self.naive_rag.text_window_splitter = False
query = "Test query with window splitter off"
# Mock the retrieve method
mock_results = [
RetrievalResult(
... | Test with text window splitter disabled. | test_with_window_splitter_disabled | python | zilliztech/deep-searcher | tests/agent/test_naive_rag.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_naive_rag.py | Apache-2.0 |
def setUp(self):
"""Set up test fixtures for RAGRouter tests."""
super().setUp()
# Create mock agent instances
self.naive_rag = MagicMock(spec=NaiveRAG)
self.chain_of_rag = MagicMock(spec=ChainOfRAG)
# Create the RAGRouter with the mock agents
se... | Set up test fixtures for RAGRouter tests. | setUp | python | zilliztech/deep-searcher | tests/agent/test_rag_router.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_rag_router.py | Apache-2.0 |
def test_route_with_non_numeric_response(self):
"""Test the _route method with a non-numeric response from LLM."""
query = "What is the history of deep learning?"
# Mock the LLM to return a response with a trailing digit
self.llm.chat = MagicMock(return_value=ChatResponse(conten... | Test the _route method with a non-numeric response from LLM. | test_route_with_non_numeric_response | python | zilliztech/deep-searcher | tests/agent/test_rag_router.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_rag_router.py | Apache-2.0 |
def test_auto_description_fallback(self):
"""Test that RAGRouter falls back to __description__ when no descriptions provided."""
# Create classes with __description__ attribute
class MockAgent1:
__description__ = "Auto description 1"
class MockAgent2:
... | Test that RAGRouter falls back to __description__ when no descriptions provided. | test_auto_description_fallback | python | zilliztech/deep-searcher | tests/agent/test_rag_router.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/agent/test_rag_router.py | Apache-2.0 |
def test_dimension_property(self):
"""Test the dimension property for different models."""
# Create instance to test with Titan Text V2
embedding = BedrockEmbedding()
self.assertEqual(embedding.dimension, 1024)
# Test Titan Text G1
embedding = BedrockEmbedding(mo... | Test the dimension property for different models. | test_dimension_property | python | zilliztech/deep-searcher | tests/embedding/test_bedrock_embedding.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/embedding/test_bedrock_embedding.py | Apache-2.0 |
def test_lazy_loading(self):
"""Test that the model is loaded lazily."""
# Create a new instance
embedding = FastEmbedEmbedding()
# Check that TextEmbedding wasn't called during initialization
self.mock_fastembed.TextEmbedding.reset_mock()
self.mock_fastembed.Tex... | Test that the model is loaded lazily. | test_lazy_loading | python | zilliztech/deep-searcher | tests/embedding/test_fastembed_embedding.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/embedding/test_fastembed_embedding.py | Apache-2.0 |
def test_init_with_api_key_parameter(self):
"""Test initialization with API key as parameter."""
api_key = "test_api_key_param"
embedding = GeminiEmbedding(api_key=api_key)
self.mock_genai.Client.assert_called_with(api_key=api_key) | Test initialization with API key as parameter. | test_init_with_api_key_parameter | python | zilliztech/deep-searcher | tests/embedding/test_gemini_embedding.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/embedding/test_gemini_embedding.py | Apache-2.0 |
def test_embed_chunks(self):
"""Test embedding chunks with batch processing."""
# Create instance to test
embedding = GeminiEmbedding()
# Set up mock response for batched documents
batch1_embeddings = [MagicMock(values=[0.1] * 768)] * 100
batch2_embeddings = [Mag... | Test embedding chunks with batch processing. | test_embed_chunks | python | zilliztech/deep-searcher | tests/embedding/test_gemini_embedding.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/embedding/test_gemini_embedding.py | Apache-2.0 |
def test_init_with_api_key(self):
"""Test initialization with API key parameter."""
# Initialize with API key
embedding = GLMEmbedding(api_key='test-api-key')
# Check that ZhipuAI was initialized with the provided API key
self.mock_zhipuai.ZhipuAI.assert_called_with(
... | Test initialization with API key parameter. | test_init_with_api_key | python | zilliztech/deep-searcher | tests/embedding/test_glm_embedding.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/embedding/test_glm_embedding.py | Apache-2.0 |
def test_init_with_base_url(self):
"""Test initialization with base URL parameter."""
# Initialize with base URL
embedding = GLMEmbedding(base_url='https://custom-api.example.com')
# Check that ZhipuAI was initialized with the provided base URL
self.mock_zhipuai.ZhipuAI.... | Test initialization with base URL parameter. | test_init_with_base_url | python | zilliztech/deep-searcher | tests/embedding/test_glm_embedding.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/embedding/test_glm_embedding.py | Apache-2.0 |
def test_init_with_base_url(self):
"""Test initialization with custom base URL."""
# Reset mock
self.mock_ollama_client.reset_mock()
# Create embedding with custom base URL
embedding = OllamaEmbedding(base_url="http://custom-ollama-server:11434/")
# Chec... | Test initialization with custom base URL. | test_init_with_base_url | python | zilliztech/deep-searcher | tests/embedding/test_ollama_embedding.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/embedding/test_ollama_embedding.py | Apache-2.0 |
def test_embed_documents_small_batch(self):
"""Test embedding documents with a small batch (less than batch size)."""
# Create instance to test
embedding = OllamaEmbedding(model="bge-m3")
# Set up mock response for multiple documents
mock_embeddings = [
[0.1,... | Test embedding documents with a small batch (less than batch size). | test_embed_documents_small_batch | python | zilliztech/deep-searcher | tests/embedding/test_ollama_embedding.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/embedding/test_ollama_embedding.py | Apache-2.0 |
def test_embed_documents_large_batch(self):
"""Test embedding documents with a large batch (more than batch size)."""
# Create instance to test
embedding = OllamaEmbedding(model="bge-m3")
# Set a smaller batch size for testing
embedding.batch_size = 2
# ... | Test embedding documents with a large batch (more than batch size). | test_embed_documents_large_batch | python | zilliztech/deep-searcher | tests/embedding/test_ollama_embedding.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/embedding/test_ollama_embedding.py | Apache-2.0 |
def test_embed_documents_no_batching(self):
"""Test embedding documents with batching disabled."""
# Create instance to test
embedding = OllamaEmbedding(model="bge-m3")
# Disable batching
embedding.batch_size = 0
# Mock the embed_query method
ori... | Test embedding documents with batching disabled. | test_embed_documents_no_batching | python | zilliztech/deep-searcher | tests/embedding/test_ollama_embedding.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/embedding/test_ollama_embedding.py | Apache-2.0 |
def test_init_with_azure_deployment(self, mock_azure_openai):
"""Test initialization with Azure OpenAI and custom deployment."""
# Set up mock Azure client
mock_azure_client = MagicMock()
mock_azure_openai.return_value = mock_azure_client
# Initialize with Azure endpoint... | Test initialization with Azure OpenAI and custom deployment. | test_init_with_azure_deployment | python | zilliztech/deep-searcher | tests/embedding/test_openai_embedding.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/embedding/test_openai_embedding.py | Apache-2.0 |
def test_embed_query_azure(self):
"""Test embedding a single query with Azure."""
# Set up Azure embedding
with patch('openai.AzureOpenAI') as mock_azure_openai:
# Set up mock Azure client
mock_azure_client = MagicMock()
mock_azure_openai.return_value = mock_a... | Test embedding a single query with Azure. | test_embed_query_azure | python | zilliztech/deep-searcher | tests/embedding/test_openai_embedding.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/embedding/test_openai_embedding.py | Apache-2.0 |
def test_init_missing_api_key(self, mock_credentials_class, mock_embeddings_class):
"""Test initialization with missing API key."""
from deepsearcher.embedding.watsonx_embedding import WatsonXEmbedding
with patch.dict(os.environ, {}, clear=True):
with self.assertRaises(ValueError) a... | Test initialization with missing API key. | test_init_missing_api_key | python | zilliztech/deep-searcher | tests/embedding/test_watsonx_embedding.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/embedding/test_watsonx_embedding.py | Apache-2.0 |
def test_init_missing_project_and_space_id(self, mock_credentials_class, mock_embeddings_class):
"""Test initialization with missing both project_id and space_id."""
from deepsearcher.embedding.watsonx_embedding import WatsonXEmbedding
with self.assertRaises(ValueError) as context:
... | Test initialization with missing both project_id and space_id. | test_init_missing_project_and_space_id | python | zilliztech/deep-searcher | tests/embedding/test_watsonx_embedding.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/embedding/test_watsonx_embedding.py | Apache-2.0 |
def test_chat_with_error(self):
"""Test chat when an error occurs."""
# Create Aliyun instance with mocked environment
with patch.dict('os.environ', {}, clear=True):
llm = Aliyun()
# Mock an error response
self.mock_completions.create.side_effect ... | Test chat when an error occurs. | test_chat_with_error | python | zilliztech/deep-searcher | tests/llm/test_aliyun.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/llm/test_aliyun.py | Apache-2.0 |
def test_init_with_custom_model_and_tokens(self):
"""Test initialization with custom model and max tokens."""
with patch.dict('os.environ', {}, clear=True):
model = "claude-3-opus-20240229"
max_tokens = 4096
llm = Anthropic(model=model, max_tokens=max_tokens)
... | Test initialization with custom model and max tokens. | test_init_with_custom_model_and_tokens | python | zilliztech/deep-searcher | tests/llm/test_anthropic.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/llm/test_anthropic.py | Apache-2.0 |
def test_remove_think_multiple_tags(self):
"""Test remove_think with multiple think tags - should only remove first block."""
content = '''<think>First think block</think>
Actual response
<think>Second think block</think>'''
result = BaseLLM.remove_think(content)
self.ass... | Test remove_think with multiple think tags - should only remove first block. | test_remove_think_multiple_tags | python | zilliztech/deep-searcher | tests/llm/test_base.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/llm/test_base.py | Apache-2.0 |
def test_init_with_aws_credentials_from_env(self):
"""Test initialization with AWS credentials from environment variables."""
credentials = {
"AWS_ACCESS_KEY_ID": "test_access_key",
"AWS_SECRET_ACCESS_KEY": "test_secret_key",
"AWS_SESSION_TOKEN": "test_session_token"
... | Test initialization with AWS credentials from environment variables. | test_init_with_aws_credentials_from_env | python | zilliztech/deep-searcher | tests/llm/test_bedrock.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/llm/test_bedrock.py | Apache-2.0 |
def test_init_with_aws_credentials_parameters(self):
"""Test initialization with AWS credentials as parameters."""
with patch.dict('os.environ', {}, clear=True):
llm = Bedrock(
aws_access_key_id="param_access_key",
aws_secret_access_key="param_secret_key",
... | Test initialization with AWS credentials as parameters. | test_init_with_aws_credentials_parameters | python | zilliztech/deep-searcher | tests/llm/test_bedrock.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/llm/test_bedrock.py | Apache-2.0 |
def test_chat_with_preformatted_messages(self):
"""Test chat with messages that are already in the correct format."""
# Create Bedrock instance with mocked environment
with patch.dict('os.environ', {}, clear=True):
llm = Bedrock()
messages = [
{
... | Test chat with messages that are already in the correct format. | test_chat_with_preformatted_messages | python | zilliztech/deep-searcher | tests/llm/test_bedrock.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/llm/test_bedrock.py | Apache-2.0 |
def test_init_with_custom_params(self, mock_gen_text_params_class, mock_credentials_class, mock_model_inference_class):
"""Test initialization with custom generation parameters."""
from deepsearcher.llm.watsonx import WatsonX
mock_credentials_instance = MagicMock()
mock_model_inference_... | Test initialization with custom generation parameters. | test_init_with_custom_params | python | zilliztech/deep-searcher | tests/llm/test_watsonx.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/llm/test_watsonx.py | Apache-2.0 |
def test_chat_with_system_message(self, mock_gen_text_params_class, mock_credentials_class, mock_model_inference_class):
"""Test chat with system and user messages."""
from deepsearcher.llm.watsonx import WatsonX
mock_credentials_instance = MagicMock()
mock_model_inference_instance = Ma... | Test chat with system and user messages. | test_chat_with_system_message | python | zilliztech/deep-searcher | tests/llm/test_watsonx.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/llm/test_watsonx.py | Apache-2.0 |
def test_chat_error_handling(self, mock_gen_text_params_class, mock_credentials_class, mock_model_inference_class):
"""Test error handling in chat method."""
from deepsearcher.llm.watsonx import WatsonX
mock_credentials_instance = MagicMock()
mock_model_inference_instance = MagicMock()
... | Test error handling in chat method. | test_chat_error_handling | python | zilliztech/deep-searcher | tests/llm/test_watsonx.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/llm/test_watsonx.py | Apache-2.0 |
def test_abstract_methods(self):
"""Test that BaseLoader defines abstract methods."""
# For abstract base classes, we can check if methods are defined
# but not implemented in the base class
self.assertTrue(hasattr(BaseLoader, 'load_file'))
self.assertTrue(hasattr(BaseLoader, 'su... | Test that BaseLoader defines abstract methods. | test_abstract_methods | python | zilliztech/deep-searcher | tests/loader/file_loader/test_base.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/loader/file_loader/test_base.py | Apache-2.0 |
def test_load_file_error(self):
"""Test error handling when loading a file."""
# Configure converter to raise an exception
self.mock_converter_instance.convert.side_effect = Exception("Test error")
# Verify that the error is propagated
with self.assertRaises(IOError):
... | Test error handling when loading a file. | test_load_file_error | python | zilliztech/deep-searcher | tests/loader/file_loader/test_docling_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/loader/file_loader/test_docling_loader.py | Apache-2.0 |
def test_invalid_jsonl_file(self):
"""Test loading a JSONL file with invalid lines."""
documents = self.loader.load_file(self.invalid_jsonl_file_path)
# Only the valid line should be loaded
self.assertEqual(len(documents), 1)
self.assertEqual(documents[0].page_content, "... | Test loading a JSONL file with invalid lines. | test_invalid_jsonl_file | python | zilliztech/deep-searcher | tests/loader/file_loader/test_json_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/loader/file_loader/test_json_loader.py | Apache-2.0 |
def test_load_directory(self):
"""Test loading a directory with mixed file types."""
# Create the loader
loader = PDFLoader()
# Mock the load_file method to track calls
original_load_file = loader.load_file
calls = []
def mock_load_file(file_path... | Test loading a directory with mixed file types. | test_load_directory | python | zilliztech/deep-searcher | tests/loader/file_loader/test_pdf_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/loader/file_loader/test_pdf_loader.py | Apache-2.0 |
def test_load_directory(self):
"""Test loading a directory with text files."""
# Create additional test files
md_file_path = os.path.join(self.temp_dir.name, "test.md")
with open(md_file_path, "w", encoding="utf-8") as f:
f.write("# Markdown Test\nThis is a markdown file.")
... | Test loading a directory with text files. | test_load_directory | python | zilliztech/deep-searcher | tests/loader/file_loader/test_text_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/loader/file_loader/test_text_loader.py | Apache-2.0 |
def test_load_with_api(self, mock_listdir):
"""Test loading with API environment variables."""
# Create a mock for os.environ.get
with patch('os.environ.get') as mock_env_get:
# Configure environment variables
mock_env_get.side_effect = lambda key, default=None: {
... | Test loading with API environment variables. | test_load_with_api | python | zilliztech/deep-searcher | tests/loader/file_loader/test_unstructured_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/loader/file_loader/test_unstructured_loader.py | Apache-2.0 |
def test_empty_output(self, mock_listdir):
"""Test handling of empty output directory."""
# Configure listdir to return no JSON files
mock_listdir.return_value = []
# Call the method
documents = self.loader.load_file(self.test_file_path)
# Check results
... | Test handling of empty output directory. | test_empty_output | python | zilliztech/deep-searcher | tests/loader/file_loader/test_unstructured_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/loader/file_loader/test_unstructured_loader.py | Apache-2.0 |
def test_error_reading_json(self, mock_listdir):
"""Test handling of errors when reading JSON files."""
# Configure listdir mock
mock_listdir.return_value = ["test_output.json"]
# Configure elements_from_json to raise an IOError
self.unstructured_modules['unstructured.st... | Test handling of errors when reading JSON files. | test_error_reading_json | python | zilliztech/deep-searcher | tests/loader/file_loader/test_unstructured_loader.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/loader/file_loader/test_unstructured_loader.py | Apache-2.0 |
def test_abstract_methods(self):
"""Test that BaseCrawler defines abstract methods."""
# For abstract base classes, we can check if methods are defined
# but not implemented in the base class
self.assertTrue(hasattr(BaseCrawler, 'crawl_url')) | Test that BaseCrawler defines abstract methods. | test_abstract_methods | python | zilliztech/deep-searcher | tests/loader/web_crawler/test_base.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/loader/web_crawler/test_base.py | Apache-2.0 |
def test_lazy_init(self):
"""Test the lazy initialization of the crawler."""
# Call _lazy_init method
self.crawler._lazy_init()
# Verify BrowserConfig.from_kwargs was called
self.mock_browser_config.from_kwargs.assert_called_once_with(self.test_browser_config)
... | Test the lazy initialization of the crawler. | test_lazy_init | python | zilliztech/deep-searcher | tests/loader/web_crawler/test_crawl4ai_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/loader/web_crawler/test_crawl4ai_crawler.py | Apache-2.0 |
def test_crawl_url_error(self, mock_asyncio_run):
"""Test error handling when crawling a URL."""
url = "https://example.com"
# Configure asyncio.run to raise an exception
mock_asyncio_run.side_effect = Exception("Test error")
# Call the method
documents ... | Test error handling when crawling a URL. | test_crawl_url_error | python | zilliztech/deep-searcher | tests/loader/web_crawler/test_crawl4ai_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/loader/web_crawler/test_crawl4ai_crawler.py | Apache-2.0 |
def test_crawl_urls_error(self, mock_asyncio_run):
"""Test error handling when crawling multiple URLs."""
urls = ["https://example.com", "https://example.org"]
# Configure asyncio.run to raise an exception
mock_asyncio_run.side_effect = Exception("Test error")
#... | Test error handling when crawling multiple URLs. | test_crawl_urls_error | python | zilliztech/deep-searcher | tests/loader/web_crawler/test_crawl4ai_crawler.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/loader/web_crawler/test_crawl4ai_crawler.py | Apache-2.0 |
def test_format_unknown_level(self):
"""Test formatting messages with unknown log level."""
record = logging.LogRecord(
"test", 60, "test.py", 1, "Custom level message", (), None
)
record.levelname = "CUSTOM"
formatted = self.formatter.format(record)
expected ... | Test formatting messages with unknown log level. | test_format_unknown_level | python | zilliztech/deep-searcher | tests/utils/test_log.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/utils/test_log.py | Apache-2.0 |
def test_debug_in_dev_mode(self):
"""Test debug logging in dev mode."""
log.set_dev_mode(True)
log.debug("Test debug")
self.mock_dev_logger.debug.assert_called_once_with("Test debug") | Test debug logging in dev mode. | test_debug_in_dev_mode | python | zilliztech/deep-searcher | tests/utils/test_log.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/utils/test_log.py | Apache-2.0 |
def test_debug_not_in_dev_mode(self):
"""Test debug logging not in dev mode."""
log.set_dev_mode(False)
log.debug("Test debug")
self.mock_dev_logger.debug.assert_not_called() | Test debug logging not in dev mode. | test_debug_not_in_dev_mode | python | zilliztech/deep-searcher | tests/utils/test_log.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/utils/test_log.py | Apache-2.0 |
def test_info_in_dev_mode(self):
"""Test info logging in dev mode."""
log.set_dev_mode(True)
log.info("Test info")
self.mock_dev_logger.info.assert_called_once_with("Test info") | Test info logging in dev mode. | test_info_in_dev_mode | python | zilliztech/deep-searcher | tests/utils/test_log.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/utils/test_log.py | Apache-2.0 |
def test_info_not_in_dev_mode(self):
"""Test info logging not in dev mode."""
log.set_dev_mode(False)
log.info("Test info")
self.mock_dev_logger.info.assert_not_called() | Test info logging not in dev mode. | test_info_not_in_dev_mode | python | zilliztech/deep-searcher | tests/utils/test_log.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/utils/test_log.py | Apache-2.0 |
def test_warning_in_dev_mode(self):
"""Test warning logging in dev mode."""
log.set_dev_mode(True)
log.warning("Test warning")
self.mock_dev_logger.warning.assert_called_once_with("Test warning") | Test warning logging in dev mode. | test_warning_in_dev_mode | python | zilliztech/deep-searcher | tests/utils/test_log.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/utils/test_log.py | Apache-2.0 |
def test_warning_not_in_dev_mode(self):
"""Test warning logging not in dev mode."""
log.set_dev_mode(False)
log.warning("Test warning")
self.mock_dev_logger.warning.assert_not_called() | Test warning logging not in dev mode. | test_warning_not_in_dev_mode | python | zilliztech/deep-searcher | tests/utils/test_log.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/utils/test_log.py | Apache-2.0 |
def test_error_in_dev_mode(self):
"""Test error logging in dev mode."""
log.set_dev_mode(True)
log.error("Test error")
self.mock_dev_logger.error.assert_called_once_with("Test error") | Test error logging in dev mode. | test_error_in_dev_mode | python | zilliztech/deep-searcher | tests/utils/test_log.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/utils/test_log.py | Apache-2.0 |
def test_error_not_in_dev_mode(self):
"""Test error logging not in dev mode."""
log.set_dev_mode(False)
log.error("Test error")
self.mock_dev_logger.error.assert_not_called() | Test error logging not in dev mode. | test_error_not_in_dev_mode | python | zilliztech/deep-searcher | tests/utils/test_log.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/utils/test_log.py | Apache-2.0 |
def test_critical(self):
"""Test critical logging and exception raising."""
with self.assertRaises(RuntimeError) as context:
log.critical("Test critical")
self.mock_dev_logger.critical.assert_called_once_with("Test critical")
self.assertEqual(str(context.exception), ... | Test critical logging and exception raising. | test_critical | python | zilliztech/deep-searcher | tests/utils/test_log.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/utils/test_log.py | Apache-2.0 |
def test_init_default_score(self):
"""Test initialization of RetrievalResult with default score."""
result = RetrievalResult(
embedding=self.embedding,
text=self.text,
reference=self.reference,
metadata=self.metadata,
)
self.assertEqual(res... | Test initialization of RetrievalResult with default score. | test_init_default_score | python | zilliztech/deep-searcher | tests/vector_db/test_base.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/vector_db/test_base.py | Apache-2.0 |
def test_no_duplicates(self):
"""Test deduplication with no duplicate results."""
results = [
RetrievalResult(self.embedding1, self.text1, self.reference, self.metadata),
RetrievalResult(self.embedding2, self.text2, self.reference, self.metadata),
]
deduplicated =... | Test deduplication with no duplicate results. | test_no_duplicates | python | zilliztech/deep-searcher | tests/vector_db/test_base.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/vector_db/test_base.py | Apache-2.0 |
def test_init_custom_collection(self):
"""Test initialization with custom collection name."""
custom_collection = "custom_collection"
db = MockVectorDB(default_collection=custom_collection)
self.assertEqual(db.default_collection, custom_collection) | Test initialization with custom collection name. | test_init_custom_collection | python | zilliztech/deep-searcher | tests/vector_db/test_base.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/vector_db/test_base.py | Apache-2.0 |
def test_insert_data_with_retrieval_results(self):
"""Test inserting data using RetrievalResult objects."""
milvus = Milvus(uri="./milvus.db")
# Create test data
d = 8
collection = "hello_deepsearcher"
rng = np.random.default_rng(seed=19530)
# Cr... | Test inserting data using RetrievalResult objects. | test_insert_data_with_retrieval_results | python | zilliztech/deep-searcher | tests/vector_db/test_milvus.py | https://github.com/zilliztech/deep-searcher/blob/master/tests/vector_db/test_milvus.py | Apache-2.0 |
async def create_agent(
params: AgentCreationParamsDTO,
) -> AgentDTO:
"""
Creates a new agent in the system.
The agent will be initialized with the provided name and optional settings.
A unique identifier will be automatically generated.
Default behaviors:
... |
Creates a new agent in the system.
The agent will be initialized with the provided name and optional settings.
A unique identifier will be automatically generated.
Default behaviors:
- `name` defaults to `"Unnamed Agent"` if not provided
- `description` defaults to `No... | create_agent | python | emcie-co/parlant | src/parlant/api/agents.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/agents.py | Apache-2.0 |
async def list_agents() -> Sequence[AgentDTO]:
"""
Retrieves a list of all agents in the system.
Returns an empty list if no agents exist.
Agents are returned in no guaranteed order.
"""
agents = await agent_store.list_agents()
return [
AgentDTO(
... |
Retrieves a list of all agents in the system.
Returns an empty list if no agents exist.
Agents are returned in no guaranteed order.
| list_agents | python | emcie-co/parlant | src/parlant/api/agents.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/agents.py | Apache-2.0 |
async def read_agent(
agent_id: AgentIdPath,
) -> AgentDTO:
"""
Retrieves details of a specific agent by ID.
"""
agent = await agent_store.read_agent(agent_id=agent_id)
return AgentDTO(
id=agent.id,
name=agent.name,
description=age... |
Retrieves details of a specific agent by ID.
| read_agent | python | emcie-co/parlant | src/parlant/api/agents.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/agents.py | Apache-2.0 |
async def update_agent(
agent_id: AgentIdPath,
params: AgentUpdateParamsDTO,
) -> AgentDTO:
"""
Updates an existing agent's attributes.
Only the provided attributes will be updated; others will remain unchanged.
The agent's ID and creation timestamp cannot be modifie... |
Updates an existing agent's attributes.
Only the provided attributes will be updated; others will remain unchanged.
The agent's ID and creation timestamp cannot be modified.
| update_agent | python | emcie-co/parlant | src/parlant/api/agents.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/agents.py | Apache-2.0 |
async def delete_agent(
agent_id: AgentIdPath,
) -> None:
"""
Deletes an agent from the agent.
Deleting a non-existent agent will return 404.
No content will be returned from a successful deletion.
"""
await agent_store.read_agent(agent_id=agent_id)
... |
Deletes an agent from the agent.
Deleting a non-existent agent will return 404.
No content will be returned from a successful deletion.
| delete_agent | python | emcie-co/parlant | src/parlant/api/agents.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/agents.py | Apache-2.0 |
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
"""FastAPI's built-in exception handling doesn't catch BaseExceptions
such as asyncio.CancelledError. This causes the server process to terminate
with an ugly traceback. This wrapper addresses that by specifically allo... | FastAPI's built-in exception handling doesn't catch BaseExceptions
such as asyncio.CancelledError. This causes the server process to terminate
with an ugly traceback. This wrapper addresses that by specifically allowing
asyncio.CancelledError to gracefully exit.
| __call__ | python | emcie-co/parlant | src/parlant/api/app.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/app.py | Apache-2.0 |
async def create_variable(
agent_id: AgentIdPath,
params: LegacyContextVariableCreationParamsDTO,
) -> LegacyContextVariableDTO:
"""
[DEPRECATED] Creates a new context variable for tracking customer-specific or tag-specific data.
This endpoint is deprecated. Please use the t... |
[DEPRECATED] Creates a new context variable for tracking customer-specific or tag-specific data.
This endpoint is deprecated. Please use the tag-based context variables API instead.
Example uses:
- Track subscription tiers to control feature access
- Store usage patterns for p... | create_variable | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def update_variable(
agent_id: AgentIdPath,
variable_id: ContextVariableIdPath,
params: LegacyContextVariableUpdateParamsDTO,
) -> LegacyContextVariableDTO:
"""
[DEPRECATED] Updates an existing context variable.
This endpoint is deprecated. Please use the tag-b... |
[DEPRECATED] Updates an existing context variable.
This endpoint is deprecated. Please use the tag-based context variables API instead.
Only provided fields will be updated; others remain unchanged.
| update_variable | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def delete_all_variables(
agent_id: AgentIdPath,
) -> None:
"""
[DEPRECATED] Deletes all context variables and their values for the provided agent ID.
This endpoint is deprecated. Please use the tag-based context variables API instead.
"""
variables = await con... |
[DEPRECATED] Deletes all context variables and their values for the provided agent ID.
This endpoint is deprecated. Please use the tag-based context variables API instead.
| delete_all_variables | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def delete_variable(
agent_id: AgentIdPath,
variable_id: ContextVariableIdPath,
) -> None:
"""
[DEPRECATED] Deletes a specific context variable and all its values.
This endpoint is deprecated. Please use the tag-based context variables API instead.
"""
... |
[DEPRECATED] Deletes a specific context variable and all its values.
This endpoint is deprecated. Please use the tag-based context variables API instead.
| delete_variable | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def list_variables(
agent_id: AgentIdPath,
) -> Sequence[LegacyContextVariableDTO]:
"""
[DEPRECATED] Lists all context variables set for the provided agent.
This endpoint is deprecated. Please use the tag-based context variables API instead.
"""
variables = awa... |
[DEPRECATED] Lists all context variables set for the provided agent.
This endpoint is deprecated. Please use the tag-based context variables API instead.
| list_variables | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def update_variable_value(
agent_id: AgentIdPath,
variable_id: ContextVariableIdPath,
key: ContextVariableKeyPath,
params: ContextVariableValueUpdateParamsDTO,
) -> ContextVariableValueDTO:
"""
[DEPRECATED] Updates the value of a context variable.
This ... |
[DEPRECATED] Updates the value of a context variable.
This endpoint is deprecated. Please use the tag-based context variables API instead.
The `key` represents a customer identifier or a customer tag in the format `tag:{tag_id}`.
If `key="DEFAULT"`, the update applies to all customers... | update_variable_value | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def read_variable_value(
agent_id: AgentIdPath,
variable_id: ContextVariableIdPath,
key: ContextVariableKeyPath,
) -> ContextVariableValueDTO:
"""
[DEPRECATED] Retrieves the value of a context variable for a specific customer or tag.
This endpoint is deprecated... |
[DEPRECATED] Retrieves the value of a context variable for a specific customer or tag.
This endpoint is deprecated. Please use the tag-based context variables API instead.
The key should be a customer identifier or a customer tag in the format `tag:{tag_id}`.
| read_variable_value | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def read_variable(
agent_id: AgentIdPath,
variable_id: ContextVariableIdPath,
include_values: IncludeValuesQuery = True,
) -> LegacyContextVariableReadResult:
"""
[DEPRECATED] Retrieves a context variable's details and optionally its values.
This endpoint is de... |
[DEPRECATED] Retrieves a context variable's details and optionally its values.
This endpoint is deprecated. Please use the tag-based context variables API instead.
Can return all customer or tag values for this variable type if include_values=True.
| read_variable | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def delete_value(
agent_id: AgentIdPath,
variable_id: ContextVariableIdPath,
key: ContextVariableKeyPath,
) -> None:
"""
[DEPRECATED] Deletes a specific customer's or tag's value for this context variable.
This endpoint is deprecated. Please use the tag-based c... |
[DEPRECATED] Deletes a specific customer's or tag's value for this context variable.
This endpoint is deprecated. Please use the tag-based context variables API instead.
The key should be a customer identifier or a customer tag in the format `tag:{tag_id}`.
Removes only the value for ... | delete_value | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def create_variable(
params: ContextVariableCreationParamsDTO,
) -> ContextVariableDTO:
"""
Creates a new context variable
Example uses:
- Track subscription tiers to control feature access
- Store usage patterns for personalized recommendations
- Remem... |
Creates a new context variable
Example uses:
- Track subscription tiers to control feature access
- Store usage patterns for personalized recommendations
- Remember preferences for tailored responses
| create_variable | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def update_variable(
variable_id: ContextVariableIdPath,
params: ContextVariableUpdateParamsDTO,
) -> ContextVariableDTO:
"""
Updates an existing context variable.
Only provided fields will be updated; others remain unchanged.
"""
def from_dto(dto: Con... |
Updates an existing context variable.
Only provided fields will be updated; others remain unchanged.
| update_variable | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def list_variables(
tag_id: TagIdQuery = None,
) -> Sequence[ContextVariableDTO]:
"""Lists all context variables set for the provided tag or all context variables if no tag is provided"""
if tag_id:
variables = await context_variable_store.list_variables(
ta... | Lists all context variables set for the provided tag or all context variables if no tag is provided | list_variables | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def read_variable(
variable_id: ContextVariableIdPath,
include_values: IncludeValuesQuery = True,
) -> ContextVariableReadResult:
"""
Retrieves a context variable's details and optionally its values.
Can return all customer or tag values for this variable type if inclu... |
Retrieves a context variable's details and optionally its values.
Can return all customer or tag values for this variable type if include_values=True.
| read_variable | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def delete_variables(
tag_id: TagIdQuery = None,
) -> None:
"""Deletes all context variables for the provided tag"""
if tag_id:
variables = await context_variable_store.list_variables(
tags=[tag_id],
)
for v in variables:
... | Deletes all context variables for the provided tag | delete_variables | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def read_variable_value(
variable_id: ContextVariableIdPath,
key: ContextVariableKeyPath,
) -> ContextVariableValueDTO:
"""Retrieves a customer or tag value for the provided context variable"""
_ = await context_variable_store.read_variable(id=variable_id)
value = awai... | Retrieves a customer or tag value for the provided context variable | read_variable_value | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def update_variable_value(
variable_id: ContextVariableIdPath,
key: ContextVariableKeyPath,
params: ContextVariableValueUpdateParamsDTO,
) -> ContextVariableValueDTO:
"""Updates a customer or tag value for the provided context variable"""
_ = await context_variable_stor... | Updates a customer or tag value for the provided context variable | update_variable_value | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def delete_value(
variable_id: ContextVariableIdPath,
key: ContextVariableKeyPath,
) -> None:
"""Deletes a customer or tag value for the provided context variable"""
_ = await context_variable_store.read_variable(id=variable_id)
if not context_variable_store.read_value... | Deletes a customer or tag value for the provided context variable | delete_value | python | emcie-co/parlant | src/parlant/api/context_variables.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/context_variables.py | Apache-2.0 |
async def create_customer(
params: CustomerCreationParamsDTO,
) -> CustomerDTO:
"""
Creates a new customer in the system.
A customer may be created with as little as a `name`.
`extra` key-value pairs and additional `tags` may be attached to a customer.
"""
ta... |
Creates a new customer in the system.
A customer may be created with as little as a `name`.
`extra` key-value pairs and additional `tags` may be attached to a customer.
| create_customer | python | emcie-co/parlant | src/parlant/api/customers.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/customers.py | Apache-2.0 |
async def read_customer(
customer_id: CustomerIdPath,
) -> CustomerDTO:
"""
Retrieves details of a specific customer by ID.
Returns a complete customer object including their metadata and tags.
The customer must exist in the system.
"""
customer = await custo... |
Retrieves details of a specific customer by ID.
Returns a complete customer object including their metadata and tags.
The customer must exist in the system.
| read_customer | python | emcie-co/parlant | src/parlant/api/customers.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/customers.py | Apache-2.0 |
async def list_customers() -> Sequence[CustomerDTO]:
"""
Retrieves a list of all customers in the system.
Returns an empty list if no customers exist.
Customers are returned in no guaranteed order.
"""
customers = await customer_store.list_customers()
return [
... |
Retrieves a list of all customers in the system.
Returns an empty list if no customers exist.
Customers are returned in no guaranteed order.
| list_customers | python | emcie-co/parlant | src/parlant/api/customers.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/customers.py | Apache-2.0 |
async def update_customer(
customer_id: CustomerIdPath,
params: CustomerUpdateParamsDTO,
) -> CustomerDTO:
"""
Updates an existing customer's attributes.
Only provided attributes will be updated; others remain unchanged.
The customer's ID and creation timestamp canno... |
Updates an existing customer's attributes.
Only provided attributes will be updated; others remain unchanged.
The customer's ID and creation timestamp cannot be modified.
Extra metadata and tags can be added or removed independently.
| update_customer | python | emcie-co/parlant | src/parlant/api/customers.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/customers.py | Apache-2.0 |
async def delete_customer(
customer_id: CustomerIdPath,
) -> None:
"""
Deletes a customer from the agent.
Deleting a non-existent customer will return 404.
No content will be returned from a successful deletion.
"""
await customer_store.delete_customer(custom... |
Deletes a customer from the agent.
Deleting a non-existent customer will return 404.
No content will be returned from a successful deletion.
| delete_customer | python | emcie-co/parlant | src/parlant/api/customers.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/customers.py | Apache-2.0 |
async def create_evaluation(
params: EvaluationCreationParamsDTO,
) -> EvaluationDTO:
"""
Creates a new evaluation task for the specified payloads.
Returns immediately with the created evaluation's initial state.
"""
try:
evaluation_id = await evaluation_... |
Creates a new evaluation task for the specified payloads.
Returns immediately with the created evaluation's initial state.
| create_evaluation | python | emcie-co/parlant | src/parlant/api/evaluations.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/evaluations.py | Apache-2.0 |
async def read_evaluation(
evaluation_id: EvaluationIdPath,
wait_for_completion: WaitForCompletionQuery = 60,
) -> EvaluationDTO:
"""Retrieves the current state of an evaluation.
* If wait_for_completion == 0, returns current state immediately.
* If wait_for_completion > 0, ... | Retrieves the current state of an evaluation.
* If wait_for_completion == 0, returns current state immediately.
* If wait_for_completion > 0, waits for completion/failure or timeout. Defaults to 60.
Notes:
When wait_for_completion > 0:
- Returns final state if evaluation comple... | read_evaluation | python | emcie-co/parlant | src/parlant/api/evaluations.py | https://github.com/emcie-co/parlant/blob/master/src/parlant/api/evaluations.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.