From 40c3cf2c803cce02c5da2fa75ea9b92bf32f0869 Mon Sep 17 00:00:00 2001 From: Amnon Catav Date: Wed, 1 Nov 2023 09:34:02 +0200 Subject: [PATCH] lint --- src/canopy/context_engine/context_engine.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/canopy/context_engine/context_engine.py b/src/canopy/context_engine/context_engine.py index 48691b7a..1b8f4691 100644 --- a/src/canopy/context_engine/context_engine.py +++ b/src/canopy/context_engine/context_engine.py @@ -26,25 +26,24 @@ async def aquery(self, queries: List[Query], max_context_tokens: int, ) -> Conte class ContextEngine(BaseContextEngine): """ ContextEngine is responsible for providing context to the LLM, given a set of search queries. - + Once called with a set of queries, the ContextEngine will go through the following steps: 1. Query the knowledge base for relevant documents 2. Build a context from the documents retrieved that can be injected into the LLM prompt - + The context engine considers token budgeting when building the context, and tries to maximize the amount of relevant information that can be provided to the LLM within the token budget. - + To create a context engine, you must provide a knowledge base and optionally a context builder. - + Example: >>> from canopy.context_engine import ContextEngine >>> from canopy.models.data_models import Query >>> context_engine = ContextEngine(knowledge_base=knowledge_base) >>> context_engine.query(Query(text="What is the capital of France?"), max_context_tokens=1000) - + To create a knowledge base, see the documentation for the knowledge base module (canopy.knowledge_base.knowledge_base). """ # noqa: E501 - _DEFAULT_COMPONENTS = { 'knowledge_base': KnowledgeBase, 'context_builder': StuffingContextBuilder, @@ -85,14 +84,14 @@ def __init__(self, def query(self, queries: List[Query], max_context_tokens: int, ) -> Context: """ Query the knowledge base for relevant documents and build a context from the retrieved documents that can be injected into the LLM prompt. - + Args: queries: A list of queries to use for retrieving documents from the knowledge base max_context_tokens: The maximum number of tokens to use for the context - + Returns: A Context object containing the retrieved documents and metadata - + Example: >>> from canopy.context_engine import ContextEngine >>> from canopy.models.data_models import Query