fengtc commited on
Commit
0b0c1d7
1 Parent(s): 7868931

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -7,9 +7,9 @@ from langchain.llms import OpenAI
7
  from gradio import gradio as gr
8
  from langchain.chat_models import ChatOpenAI
9
  from langchain.schema import AIMessage, HumanMessage
10
-
11
-
12
-
13
  import os
14
  OPENAI_API_KEY=os.getenv('OPENAI_API_KEY')
15
 
@@ -44,7 +44,7 @@ def predict(message, history):
44
  partial_message = partial_message + chunk[0]
45
  yield partial_message
46
 
47
-
48
  gr.ChatInterface(predict, theme=gr.themes.Default(),
49
  textbox=gr.Textbox(placeholder="请输入您的问题...", container=False, scale=7),
50
  title="欢迎使用智造云AI机器人",
 
7
  from gradio import gradio as gr
8
  from langchain.chat_models import ChatOpenAI
9
  from langchain.schema import AIMessage, HumanMessage
10
+ from langchain.cache import InMemoryCache
11
+ import langchain
12
+ import time
13
  import os
14
  OPENAI_API_KEY=os.getenv('OPENAI_API_KEY')
15
 
 
44
  partial_message = partial_message + chunk[0]
45
  yield partial_message
46
 
47
+ langchain.llm_cache = InMemoryCache()
48
  gr.ChatInterface(predict, theme=gr.themes.Default(),
49
  textbox=gr.Textbox(placeholder="请输入您的问题...", container=False, scale=7),
50
  title="欢迎使用智造云AI机器人",