Spaces:
Sleeping
Sleeping
Chris Alexiuk
commited on
Commit
·
bc76327
1
Parent(s):
b642769
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,14 +19,11 @@ text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=10
|
|
| 19 |
system_template = """
|
| 20 |
Use the following pieces of context to answer the users question.
|
| 21 |
If you don't know the answer, just say that you don't know, don't try to make up an answer.
|
| 22 |
-
ALWAYS return a "Review_Url" part in your answer.
|
| 23 |
-
The "Review_Url" part should be a reference to the source of the document from which you got your answer.
|
| 24 |
|
| 25 |
Example of your response should be:
|
| 26 |
|
| 27 |
```
|
| 28 |
The answer is foo
|
| 29 |
-
Review_Url: xyz
|
| 30 |
```
|
| 31 |
|
| 32 |
Begin!
|
|
@@ -79,11 +76,7 @@ async def init():
|
|
| 79 |
@cl.on_message
|
| 80 |
async def main(message):
|
| 81 |
chain = cl.user_session.get("chain")
|
| 82 |
-
|
| 83 |
-
stream_final_answer=True, answer_prefix_tokens=["FINAL", "ANSWER"]
|
| 84 |
-
)
|
| 85 |
-
cb.answer_reached = True
|
| 86 |
-
res = await chain.acall(message, callbacks=[cb])
|
| 87 |
|
| 88 |
answer = res["result"]
|
| 89 |
source_elements = []
|
|
@@ -108,8 +101,4 @@ async def main(message):
|
|
| 108 |
else:
|
| 109 |
answer += "\nNo sources found"
|
| 110 |
|
| 111 |
-
|
| 112 |
-
cb.final_stream.elements = source_elements
|
| 113 |
-
await cb.final_stream.update()
|
| 114 |
-
else:
|
| 115 |
-
await cl.Message(content=answer, elements=source_elements).send()
|
|
|
|
| 19 |
system_template = """
|
| 20 |
Use the following pieces of context to answer the users question.
|
| 21 |
If you don't know the answer, just say that you don't know, don't try to make up an answer.
|
|
|
|
|
|
|
| 22 |
|
| 23 |
Example of your response should be:
|
| 24 |
|
| 25 |
```
|
| 26 |
The answer is foo
|
|
|
|
| 27 |
```
|
| 28 |
|
| 29 |
Begin!
|
|
|
|
| 76 |
@cl.on_message
|
| 77 |
async def main(message):
|
| 78 |
chain = cl.user_session.get("chain")
|
| 79 |
+
res = await chain.acall(message)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
answer = res["result"]
|
| 82 |
source_elements = []
|
|
|
|
| 101 |
else:
|
| 102 |
answer += "\nNo sources found"
|
| 103 |
|
| 104 |
+
await cl.Message(content=answer, elements=source_elements).send()
|
|
|
|
|
|
|
|
|
|
|
|