Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,23 +31,23 @@ chat_prompt = ChatPromptTemplate.from_messages([("system", rag_system_prompt_tem
|
|
| 31 |
|
| 32 |
@cl.on_chat_start
|
| 33 |
async def on_chat_start():
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
|
| 50 |
-
await cl.Message(content="
|
| 51 |
|
| 52 |
@cl.author_rename
|
| 53 |
def rename(orig_author: str):
|
|
@@ -55,6 +55,5 @@ def rename(orig_author: str):
|
|
| 55 |
|
| 56 |
@cl.on_message
|
| 57 |
async def main(message: cl.Message):
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
await cl.Message(content="Response").send()
|
|
|
|
| 31 |
|
| 32 |
@cl.on_chat_start
|
| 33 |
async def on_chat_start():
|
| 34 |
+
qdrant_client = QdrantClient(url=os.environ["QDRANT_ENDPOINT"], api_key=os.environ["QDRANT_API_KEY"])
|
| 35 |
+
qdrant_store = Qdrant(
|
| 36 |
+
client=qdrant_client,
|
| 37 |
+
collection_name="kai_test_docs",
|
| 38 |
+
embeddings=te3_small
|
| 39 |
+
)
|
| 40 |
+
retriever = qdrant_store.as_retriever()
|
| 41 |
|
| 42 |
+
global retrieval_augmented_qa_chain
|
| 43 |
+
retrieval_augmented_qa_chain = (
|
| 44 |
+
{"context": itemgetter("question") | retriever, "question": itemgetter("question")}
|
| 45 |
+
| RunnablePassthrough.assign(context=itemgetter("context"))
|
| 46 |
+
| chat_prompt
|
| 47 |
+
| chat_model
|
| 48 |
+
)
|
| 49 |
|
| 50 |
+
await cl.Message(content="Ask away!").send()
|
| 51 |
|
| 52 |
@cl.author_rename
|
| 53 |
def rename(orig_author: str):
|
|
|
|
| 55 |
|
| 56 |
@cl.on_message
|
| 57 |
async def main(message: cl.Message):
|
| 58 |
+
response = retrieval_augmented_qa_chain.invoke({"question": message.content})
|
| 59 |
+
await cl.Message(content=response.content).send()
|
|
|