neuroqrs package#
Submodules#
neuroqrs.genai module#
- class neuroqrs.genai.SuggestedQueries(*, suggestions: List[str])[source]#
Bases:
BaseModelSuggested Queries model
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'suggestions': FieldInfo(annotation=List[str], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- suggestions: List[str]#
- async neuroqrs.genai.get_genai_suggestions(partial_query: str, context: dict, fields_info: dict, n_queries: int = 10) SuggestedQueries[source]#
Get genai suggestions for the given partial query, context and fields_info, Uses latest function call architecture.
- Parameters:
partial_query (str :type context: dict) – The partial query for which suggestions are needed
context – The context for the query
fields_info (dict) – The fields information
n_queries (int, optional) – Number of queries to suggest, defaults to 10
- Returns:
Suggested queries
- Return type:
neuroqrs.index module#
- class neuroqrs.index.NeuroIndex(namespace: str = '', dim: int = 768)[source]#
Bases:
objectFaiss powered index for searching through the dataset
- add(document_text: str, embedded_document_text)[source]#
Add a document to the index and save the query
- Parameters:
document_text (str) – Document text
embedded_document_text (list) – Embedded document text
neuroqrs.main module#
- class neuroqrs.main.NeuroQRS(embedding_model='all-mpnet-base-v2', model_dim: int = 768)[source]#
Bases:
objectNeuroQRS main class
- async query_and_index(query: str, namespace: str, extra_documents_data: dict, fields_info: dict = {}, k: int = 5)[source]#
Query and index the document (slow, uses even genai to improve context)
- Parameters:
query (str) – partial query to search
namespace (str) – Namespace associated
extra_documents_data (dict) – extra supporting data, simply dumped to llm prompt
fields_info (dict) – fields information (ie what filters are avaliable for the search)
k (int) – Number of results to return
- Returns:
List of results
- Return type:
list
- async query_maybe_index(query: str, namespace: str, extra_documents_data: dict, fields_info: dict = {}, k: int = 5)[source]#
Query the document quickly for results, if not enough results then index the document and query again (might be slow)
- Parameters:
query (str) – partial query to search
namespace (str) – Namespace associated
extra_documents_data (dict) – extra supporting data, simply dumped to llm prompt
fields_info (dict) – fields information (ie what filters are avaliable for the search)
k (int) – Number of results to return
- Returns:
List of results
- Return type:
list