wholewhale
commited on
Commit
•
7eb7306
1
Parent(s):
ce199cb
update model and N
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ def pdf_changes(pdf_doc):
|
|
27 |
retriever = db.as_retriever()
|
28 |
global qa
|
29 |
qa = ConversationalRetrievalChain.from_llm(
|
30 |
-
llm=OpenAI(temperature=0.2),
|
31 |
retriever=retriever,
|
32 |
return_source_documents=False)
|
33 |
return "Ready"
|
@@ -45,7 +45,8 @@ def add_text(history, text):
|
|
45 |
|
46 |
def bot(history):
|
47 |
response = infer(history[-1][0], history)
|
48 |
-
|
|
|
49 |
history[-1][1] = formatted_response
|
50 |
return history
|
51 |
|
@@ -57,7 +58,7 @@ def infer(question, history):
|
|
57 |
|
58 |
chat_history = res
|
59 |
query = question
|
60 |
-
result = qa({"question": query, "chat_history": chat_history})
|
61 |
return result["answer"]
|
62 |
|
63 |
def auto_clear_data():
|
@@ -110,4 +111,4 @@ with gr.Blocks(css=css) as demo:
|
|
110 |
bot, chatbot, chatbot
|
111 |
)
|
112 |
|
113 |
-
demo.launch()
|
|
|
27 |
retriever = db.as_retriever()
|
28 |
global qa
|
29 |
qa = ConversationalRetrievalChain.from_llm(
|
30 |
+
llm=OpenAI(temperature=0.2, model_name="gpt-3.5-turbo", max_tokens=-1, n=2),
|
31 |
retriever=retriever,
|
32 |
return_source_documents=False)
|
33 |
return "Ready"
|
|
|
45 |
|
46 |
def bot(history):
|
47 |
response = infer(history[-1][0], history)
|
48 |
+
sentences = ' \n'.join(response.split('. '))
|
49 |
+
formatted_response = f"**Bot:**\n\n{sentences}"
|
50 |
history[-1][1] = formatted_response
|
51 |
return history
|
52 |
|
|
|
58 |
|
59 |
chat_history = res
|
60 |
query = question
|
61 |
+
result = qa({"question": query, "chat_history": chat_history, "system:": "This is a world-class summarizing AI, be helpful."})
|
62 |
return result["answer"]
|
63 |
|
64 |
def auto_clear_data():
|
|
|
111 |
bot, chatbot, chatbot
|
112 |
)
|
113 |
|
114 |
+
demo.launch()
|