update 4
Browse files
app.py
CHANGED
@@ -68,16 +68,7 @@ def app():
|
|
68 |
('General Medicine', 'RespiratoryFishman', 'RespiratoryMurray', 'MedMRCP2', 'OldMedicine')
|
69 |
)
|
70 |
|
71 |
-
|
72 |
-
condense_question_chain = RunnableLambda(lambda x: {"chat_history": chistory, "question": x}) | CONDENSE_QUESTION_PROMPT | llmc
|
73 |
-
retriever_chain = RunnableLambda(lambda x: {"standalone_question": x}) | retriever | _combine_documents
|
74 |
-
answer_chain = ANSWER_PROMPT | llm
|
75 |
-
|
76 |
-
conversational_qa_chain = RunnableParallel(
|
77 |
-
condense_question=condense_question_chain,
|
78 |
-
retrieve=retriever_chain,
|
79 |
-
generate_answer=answer_chain
|
80 |
-
)
|
81 |
|
82 |
# Define retrievers based on option
|
83 |
persist_directory = {
|
@@ -98,6 +89,18 @@ def app():
|
|
98 |
|
99 |
vectordb = Chroma(persist_directory=persist_directory, embedding_function=embedding_function, collection_name=collection_name)
|
100 |
retriever = vectordb.as_retriever(search_kwargs={"k": 5})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
if "messages" not in st.session_state:
|
103 |
st.session_state.messages = [{"role": "assistant", "content": "How may I help you?"}]
|
|
|
68 |
('General Medicine', 'RespiratoryFishman', 'RespiratoryMurray', 'MedMRCP2', 'OldMedicine')
|
69 |
)
|
70 |
|
71 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
# Define retrievers based on option
|
74 |
persist_directory = {
|
|
|
89 |
|
90 |
vectordb = Chroma(persist_directory=persist_directory, embedding_function=embedding_function, collection_name=collection_name)
|
91 |
retriever = vectordb.as_retriever(search_kwargs={"k": 5})
|
92 |
+
|
93 |
+
|
94 |
+
# Define the chain using LCEL
|
95 |
+
condense_question_chain = RunnableLambda(lambda x: {"chat_history": chistory, "question": x}) | CONDENSE_QUESTION_PROMPT | llmc
|
96 |
+
retriever_chain = RunnableLambda(lambda x: {"standalone_question": x}) | retriever | _combine_documents
|
97 |
+
answer_chain = ANSWER_PROMPT | llm
|
98 |
+
|
99 |
+
conversational_qa_chain = RunnableParallel(
|
100 |
+
condense_question=condense_question_chain,
|
101 |
+
retrieve=retriever_chain,
|
102 |
+
generate_answer=answer_chain
|
103 |
+
)
|
104 |
|
105 |
if "messages" not in st.session_state:
|
106 |
st.session_state.messages = [{"role": "assistant", "content": "How may I help you?"}]
|