-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add utils module with Query result pydantic model and prompt configur…
…ation
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Config: | ||
template_str = """ | ||
You are very helpful assistant for question answering tasks. Use the pieces of retrieved context to answer question given. If you do not know | ||
the answer, Just say that you do not know the answer instead of making up an answer. | ||
Retrieved context: {context} | ||
Query: {query} | ||
format instructions: {format_instructions} | ||
""" | ||
|
||
default_google_model = "gemini-pro" | ||
default_openai_model = "gpt-3.5-turbo-0125" | ||
default_cohere_model = "command" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from typing import List, Union | ||
from pydantic import BaseModel, Field | ||
|
||
class Document(BaseModel): | ||
page_content: str = Field(..., description="The content of the page from the source document.") | ||
source: Union[float, int] = Field(..., description="The page number of the page_content in the document") | ||
title: str = Field(..., description="The title or URL of the source document.") | ||
|
||
|
||
class QueryResult(BaseModel): | ||
query: str = Field(..., description="The query that was submitted.") | ||
result: str = Field(..., description="The result of the query, including any retrieved information.") | ||
page: Union[float, int] = Field(..., description="The page number of the final result of the query.") | ||
source_documents: List[Document] = Field(..., description="A list of source documents related to the query.") | ||
|
||
# Example usage: | ||
# data = { | ||
# 'query': 'how did RAG come up?', | ||
# 'result': 'RAG came up as a language model that is more strongly grounded in ' | ||
# 'than BART and has been effective in Jeopardy question generation.\n' | ||
# '\n' | ||
# 'Sources:\n' | ||
# '- https://arxiv.org/pdf/2005.11401.pdf (page 5.0)', | ||
# 'page': 5.0, # A | ||
# 'source_documents': [ | ||
# { | ||
# 'page_content': 'page-content-where-the-response-is-from.\n10', | ||
# 'source': 9.0, | ||
# 'title': 'document-title' | ||
# }, | ||
# { | ||
# 'page_content': 'page-content-where-the-response-is-from.\n17', | ||
# 'source': 5.0, | ||
# 'title': 'document-title' | ||
# } | ||
# ] | ||
# } | ||
|