Update app.py
Browse files
app.py
CHANGED
|
@@ -38,15 +38,13 @@ docsearch = FAISS.load_local("./faiss_index", embeddings)
|
|
| 38 |
template="您是回答ANSYS软件使用查询的得力助手,所有回复必需用中文"
|
| 39 |
chain = load_qa_chain(OpenAI(temperature=0,model_name="gpt-3.5-turbo"), chain_type="stuff",verbose=True)
|
| 40 |
def predict(message, history):
|
| 41 |
-
llm = OpenAI(model_name="gpt-3.5-turbo",max_tokens=1024)
|
| 42 |
-
en_message = llm("""翻译 {message} 为英文""")
|
| 43 |
history_langchain_format = []
|
| 44 |
for human, ai in history:
|
| 45 |
history_langchain_format.append(HumanMessage(content=human))
|
| 46 |
history_langchain_format.append(AIMessage(content=ai))
|
| 47 |
history_langchain_format.append(HumanMessage(content=en_message))
|
| 48 |
-
docs = docsearch.similarity_search(
|
| 49 |
-
response = chain.run(input_documents=docs, question=
|
| 50 |
|
| 51 |
partial_message = ""
|
| 52 |
for chunk in response:
|
|
|
|
| 38 |
template="您是回答ANSYS软件使用查询的得力助手,所有回复必需用中文"
|
| 39 |
chain = load_qa_chain(OpenAI(temperature=0,model_name="gpt-3.5-turbo"), chain_type="stuff",verbose=True)
|
| 40 |
def predict(message, history):
|
|
|
|
|
|
|
| 41 |
history_langchain_format = []
|
| 42 |
for human, ai in history:
|
| 43 |
history_langchain_format.append(HumanMessage(content=human))
|
| 44 |
history_langchain_format.append(AIMessage(content=ai))
|
| 45 |
history_langchain_format.append(HumanMessage(content=en_message))
|
| 46 |
+
docs = docsearch.similarity_search(message)
|
| 47 |
+
response = chain.run(input_documents=docs, question=message + template)
|
| 48 |
|
| 49 |
partial_message = ""
|
| 50 |
for chunk in response:
|