Spaces:
Runtime error
Runtime error
Commit
·
8f5fc25
1
Parent(s):
288b789
Update app.py
Browse files
app.py
CHANGED
@@ -52,32 +52,6 @@ User Query:
|
|
52 |
|
53 |
user_prompt = UserRolePrompt(USER_PROMPT_TEMPLATE)
|
54 |
|
55 |
-
class RetrievalAugmentedQAPipeline:
|
56 |
-
def __init__(self, llm: ChatOpenAI(), vector_db_retriever: VectorDatabase) -> None:
|
57 |
-
self.llm = llm
|
58 |
-
self.vector_db_retriever = vector_db_retriever
|
59 |
-
|
60 |
-
def run_pipeline(self, user_query: str) -> str:
|
61 |
-
context_list = self.vector_db_retriever.search_by_text(user_query, k=4)
|
62 |
-
|
63 |
-
context_prompt = ""
|
64 |
-
for context in context_list:
|
65 |
-
context_prompt += context[0] + "\n"
|
66 |
-
|
67 |
-
formatted_system_prompt = raqa_prompt.create_message(context=context_prompt)
|
68 |
-
|
69 |
-
formatted_user_prompt = user_prompt.create_message(user_query=user_query)
|
70 |
-
|
71 |
-
return self.llm.run([formatted_system_prompt, formatted_user_prompt])
|
72 |
-
|
73 |
-
|
74 |
-
chat_openai = ChatOpenAI()
|
75 |
-
|
76 |
-
retrieval_augmented_qa_pipeline = RetrievalAugmentedQAPipeline(
|
77 |
-
vector_db_retriever=vector_db,
|
78 |
-
llm=chat_openai
|
79 |
-
)
|
80 |
-
|
81 |
@cl.on_chat_start
|
82 |
async def start_chat():
|
83 |
settings = {
|
|
|
52 |
|
53 |
user_prompt = UserRolePrompt(USER_PROMPT_TEMPLATE)
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
@cl.on_chat_start
|
56 |
async def start_chat():
|
57 |
settings = {
|