Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
from langchain.embeddings.openai import OpenAIEmbeddings
|
| 2 |
from langchain.embeddings import HuggingFaceEmbeddings
|
| 3 |
-
from langchain.text_splitter import CharacterTextSplitter
|
| 4 |
from langchain.vectorstores import FAISS
|
| 5 |
from langchain.chains.question_answering import load_qa_chain
|
| 6 |
from langchain.llms import OpenAI
|
|
@@ -43,7 +42,7 @@ def predict(message, history):
|
|
| 43 |
for human, ai in history:
|
| 44 |
history_langchain_format.append(HumanMessage(content=human))
|
| 45 |
history_langchain_format.append(AIMessage(content=ai))
|
| 46 |
-
history_langchain_format.append(HumanMessage(content=
|
| 47 |
docs = docsearch.similarity_search(message)
|
| 48 |
response = chain.run(input_documents=docs, question=message + template)
|
| 49 |
|
|
@@ -60,4 +59,4 @@ gr.ChatInterface(predict,
|
|
| 60 |
textbox=gr.Textbox(placeholder="请提问关于ANSYS软件的问题", container=False, scale=7),
|
| 61 |
title="欢迎使用ANSYS软件AI机器人",
|
| 62 |
examples=["你是谁?", "请介绍一下Fluent 软件", "create-bounding-box","ANSYS Fluent Architecture","ANSYS Fluent 的软件架构是怎么样的"],
|
| 63 |
-
description="
|
|
|
|
| 1 |
from langchain.embeddings.openai import OpenAIEmbeddings
|
| 2 |
from langchain.embeddings import HuggingFaceEmbeddings
|
|
|
|
| 3 |
from langchain.vectorstores import FAISS
|
| 4 |
from langchain.chains.question_answering import load_qa_chain
|
| 5 |
from langchain.llms import OpenAI
|
|
|
|
| 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=message))
|
| 46 |
docs = docsearch.similarity_search(message)
|
| 47 |
response = chain.run(input_documents=docs, question=message + template)
|
| 48 |
|
|
|
|
| 59 |
textbox=gr.Textbox(placeholder="请提问关于ANSYS软件的问题", container=False, scale=7),
|
| 60 |
title="欢迎使用ANSYS软件AI机器人",
|
| 61 |
examples=["你是谁?", "请介绍一下Fluent 软件", "create-bounding-box","ANSYS Fluent Architecture","ANSYS Fluent 的软件架构是怎么样的"],
|
| 62 |
+
description="请避免输入有违公序良俗的问题,模型可能无法回答不合适的问题",).queue().launch(debug=True)
|