julee.services.knowledge_service.memory¶
Memory-based implementation of KnowledgeService for testing and development.
This module provides an in-memory implementation of the KnowledgeService protocol that stores file registrations in memory and returns configurable canned responses for queries.
Submodules¶
Classes¶
In-memory implementation of the KnowledgeService protocol. |
Package Contents¶
- class julee.services.knowledge_service.memory.MemoryKnowledgeService(config)[source]¶
Bases:
julee.services.knowledge_service.knowledge_service.KnowledgeServiceIn-memory implementation of the KnowledgeService protocol.
This class stores file registrations in memory using a dictionary keyed by knowledge_service_file_id. Query results are returned from a configurable queue of canned responses.
Useful for testing and development scenarios where you want to avoid external service dependencies while still exercising the full knowledge service workflow.
- add_canned_query_result(query_result)[source]¶
Add a canned query result to be returned by execute_query.
- Parameters:
query_result (julee.services.knowledge_service.knowledge_service.QueryResult) – QueryResult to return from future execute_query calls
- add_canned_query_results(query_results)[source]¶
Add multiple canned query results to be returned by execute_query.
- Parameters:
query_results (list[julee.services.knowledge_service.knowledge_service.QueryResult]) – List of QueryResult objects to return from future execute_query calls
- async execute_query(config, query_text, output_schema=None, service_file_ids=None, query_metadata=None, assistant_prompt=None)[source]¶
Execute a query by returning a canned response.
- Parameters:
config (julee.domain.models.knowledge_service_config.KnowledgeServiceConfig) – KnowledgeServiceConfig for this operation
query_text (str) – The query to execute
output_schema (dict[str, Any] | None) – Optional JSON schema for structured response
service_file_ids (list[str] | None) – Optional list of service file IDs for query
query_metadata (dict[str, Any] | None) – Optional service-specific metadata
assistant_prompt (str | None) – Optional assistant message content (ignored in memory implementation)
- Returns:
QueryResult from the queue of canned responses
- Raises:
ValueError – If no canned query results are available
- Return type:
julee.services.knowledge_service.knowledge_service.QueryResult
- get_all_registered_files()[source]¶
Get all registered files.
- Returns:
Dictionary mapping knowledge_service_file_id to FileRegistrationResult
- Return type:
dict[str, julee.services.knowledge_service.knowledge_service.FileRegistrationResult]
- get_registered_file(knowledge_service_file_id)[source]¶
Get a registered file by its knowledge service file ID.
- Parameters:
knowledge_service_file_id (str) – The file ID assigned by this service
- Returns:
FileRegistrationResult if found, None otherwise
- Return type:
julee.services.knowledge_service.knowledge_service.FileRegistrationResult | None
- async register_file(config, document)[source]¶
Register a document file by storing metadata in memory.
- Parameters:
config (julee.domain.models.knowledge_service_config.KnowledgeServiceConfig) – KnowledgeServiceConfig for this operation
document (julee.domain.models.document.Document) – Document domain object to register
- Returns:
FileRegistrationResult with memory-specific details
- Return type:
julee.services.knowledge_service.knowledge_service.FileRegistrationResult
- config¶