Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -48,12 +48,12 @@ vectorstore = Chroma.from_documents(documents=splits, embedding=embedding)
|
|
48 |
def format_docs(docs):
|
49 |
return "\n\n".join(doc.page_content for doc in docs)
|
50 |
|
51 |
-
retriever = vectorstore.as_retriever()
|
52 |
|
53 |
prompt = hub.pull("rlm/rag-prompt")
|
54 |
llm = HuggingFaceEndpoint(repo_id="mistralai/Mistral-7B-Instruct-v0.3")
|
55 |
rag_chain = (
|
56 |
-
{"context": retriever | format_docs, "question": RunnablePassthrough()}
|
57 |
| prompt
|
58 |
| llm
|
59 |
| StrOutputParser()
|
@@ -87,6 +87,7 @@ You are a Cupertino High School Q/A chatbot, designed to assist students, parent
|
|
87 |
Use the pieces of context to answer the question.
|
88 |
Use markdown with spaces in between sentences for readability.
|
89 |
Refer to the provided context only as 'my data'. Only answer questions from the context.
|
|
|
90 |
"""
|
91 |
qa_prompt = ChatPromptTemplate.from_messages(
|
92 |
[
|
|
|
48 |
def format_docs(docs):
|
49 |
return "\n\n".join(doc.page_content for doc in docs)
|
50 |
|
51 |
+
retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": 0.3}, k=1)
|
52 |
|
53 |
prompt = hub.pull("rlm/rag-prompt")
|
54 |
llm = HuggingFaceEndpoint(repo_id="mistralai/Mistral-7B-Instruct-v0.3")
|
55 |
rag_chain = (
|
56 |
+
{"context": retriever† | format_docs, "question": RunnablePassthrough()}
|
57 |
| prompt
|
58 |
| llm
|
59 |
| StrOutputParser()
|
|
|
87 |
Use the pieces of context to answer the question.
|
88 |
Use markdown with spaces in between sentences for readability.
|
89 |
Refer to the provided context only as 'my data'. Only answer questions from the context.
|
90 |
+
Do not give any response related
|
91 |
"""
|
92 |
qa_prompt = ChatPromptTemplate.from_messages(
|
93 |
[
|