Spaces:
Sleeping
Sleeping
guangliang.yin commited on
Commit ·
6978c3c
1
Parent(s): 5fb9ac1
openai key 和 智谱的 key 分开
Browse files
app.py
CHANGED
|
@@ -6,14 +6,13 @@ from langchain.vectorstores import Zilliz
|
|
| 6 |
from langchain.document_loaders import WebBaseLoader
|
| 7 |
from langchain.text_splitter import CharacterTextSplitter
|
| 8 |
from langchain.chains import RetrievalQAWithSourcesChain
|
| 9 |
-
from langchain.llms import OpenAI
|
| 10 |
import uuid
|
| 11 |
from project.llm.zhipuai_llm import ZhipuAILLM
|
| 12 |
|
| 13 |
chain: Optional[Callable] = None
|
| 14 |
|
| 15 |
|
| 16 |
-
def web_loader(url_list, openai_key, zilliz_uri, user, password):
|
| 17 |
if not url_list:
|
| 18 |
return "please enter url list"
|
| 19 |
loader = WebBaseLoader(url_list.split())
|
|
@@ -45,7 +44,7 @@ def web_loader(url_list, openai_key, zilliz_uri, user, password):
|
|
| 45 |
|
| 46 |
global chain
|
| 47 |
chain = RetrievalQAWithSourcesChain.from_chain_type(
|
| 48 |
-
ZhipuAILLM(model="glm-3-turbo", temperature=0.1, zhipuai_api_key=
|
| 49 |
chain_type="map_reduce",
|
| 50 |
retriever=docsearch.as_retriever(),
|
| 51 |
)
|
|
@@ -70,7 +69,7 @@ if __name__ == "__main__":
|
|
| 70 |
<h1><center>Langchain And Zilliz Cloud Example</center></h1>
|
| 71 |
This is how to use Zilliz Cloud as vector store in LangChain.
|
| 72 |
The purpose of this example is to allow you to input multiple URLs (separated by newlines) and then ask questions about the content of the corresponding web pages.
|
| 73 |
-
|
| 74 |
## 📋 Prerequisite:
|
| 75 |
|
| 76 |
1. 🔑 To obtain an OpenAI key, please visit https://platform.openai.com/account/api-keys.
|
|
@@ -93,6 +92,7 @@ if __name__ == "__main__":
|
|
| 93 |
placeholder="https://milvus.io/docs/overview.md",
|
| 94 |
)
|
| 95 |
openai_key_text = gr.Textbox(label="openai api key", type="password", placeholder="sk-******")
|
|
|
|
| 96 |
with gr.Row():
|
| 97 |
zilliz_uri_text = gr.Textbox(
|
| 98 |
label="zilliz cloud uri",
|
|
@@ -109,6 +109,7 @@ if __name__ == "__main__":
|
|
| 109 |
inputs=[
|
| 110 |
url_list_text,
|
| 111 |
openai_key_text,
|
|
|
|
| 112 |
zilliz_uri_text,
|
| 113 |
user_text,
|
| 114 |
password_text,
|
|
|
|
| 6 |
from langchain.document_loaders import WebBaseLoader
|
| 7 |
from langchain.text_splitter import CharacterTextSplitter
|
| 8 |
from langchain.chains import RetrievalQAWithSourcesChain
|
|
|
|
| 9 |
import uuid
|
| 10 |
from project.llm.zhipuai_llm import ZhipuAILLM
|
| 11 |
|
| 12 |
chain: Optional[Callable] = None
|
| 13 |
|
| 14 |
|
| 15 |
+
def web_loader(url_list, openai_key, puzhiai_key, zilliz_uri, user, password):
|
| 16 |
if not url_list:
|
| 17 |
return "please enter url list"
|
| 18 |
loader = WebBaseLoader(url_list.split())
|
|
|
|
| 44 |
|
| 45 |
global chain
|
| 46 |
chain = RetrievalQAWithSourcesChain.from_chain_type(
|
| 47 |
+
ZhipuAILLM(model="glm-3-turbo", temperature=0.1, zhipuai_api_key=puzhiai_key),
|
| 48 |
chain_type="map_reduce",
|
| 49 |
retriever=docsearch.as_retriever(),
|
| 50 |
)
|
|
|
|
| 69 |
<h1><center>Langchain And Zilliz Cloud Example</center></h1>
|
| 70 |
This is how to use Zilliz Cloud as vector store in LangChain.
|
| 71 |
The purpose of this example is to allow you to input multiple URLs (separated by newlines) and then ask questions about the content of the corresponding web pages.
|
| 72 |
+
v.2.26.19.47
|
| 73 |
## 📋 Prerequisite:
|
| 74 |
|
| 75 |
1. 🔑 To obtain an OpenAI key, please visit https://platform.openai.com/account/api-keys.
|
|
|
|
| 92 |
placeholder="https://milvus.io/docs/overview.md",
|
| 93 |
)
|
| 94 |
openai_key_text = gr.Textbox(label="openai api key", type="password", placeholder="sk-******")
|
| 95 |
+
puzhiai_key_text = gr.Textbox(label="puzhi api key", type="password", placeholder="******")
|
| 96 |
with gr.Row():
|
| 97 |
zilliz_uri_text = gr.Textbox(
|
| 98 |
label="zilliz cloud uri",
|
|
|
|
| 109 |
inputs=[
|
| 110 |
url_list_text,
|
| 111 |
openai_key_text,
|
| 112 |
+
puzhiai_key_text,
|
| 113 |
zilliz_uri_text,
|
| 114 |
user_text,
|
| 115 |
password_text,
|