Spaces:
Sleeping
Sleeping
thoristhor
commited on
Commit
•
360e7d2
1
Parent(s):
c3972d5
Update app.py
Browse files
app.py
CHANGED
@@ -2,10 +2,7 @@ import os
|
|
2 |
import gradio as gr
|
3 |
import pinecone
|
4 |
from gpt_index import GPTIndexMemory, GPTPineconeIndex
|
5 |
-
|
6 |
-
from langchain.agents import Tool, ConversationalAgent, AgentExecutor, load_tools, tool
|
7 |
-
from langchain import OpenAI, LLMChain, LLMMathChain
|
8 |
-
from langchain.chains.conversation.memory import ConversationBufferMemory
|
9 |
from langchain.chains.conversation.memory import ConversationBufferMemory
|
10 |
from langchain import OpenAI
|
11 |
from langchain.agents import initialize_agent
|
@@ -27,16 +24,11 @@ tools = [
|
|
27 |
),
|
28 |
]
|
29 |
memory = ConversationBufferMemory(memory_key="chat_history")
|
30 |
-
llm=OpenAI(temperature=0)
|
31 |
agent_chain = initialize_agent(tools, llm, agent="conversational-react-description", memory=memory)
|
32 |
-
agent_executor = AgentExecutor.from_agent_and_tools(
|
33 |
-
agent=agent_chain,
|
34 |
-
tools=tools,
|
35 |
-
memory=memory,
|
36 |
-
verbose=False)
|
37 |
|
38 |
def predict(input, history=[]):
|
39 |
-
response =
|
40 |
history = history + [(input, response)]
|
41 |
response = history
|
42 |
# response = [response]
|
|
|
2 |
import gradio as gr
|
3 |
import pinecone
|
4 |
from gpt_index import GPTIndexMemory, GPTPineconeIndex
|
5 |
+
from langchain.agents import Tool
|
|
|
|
|
|
|
6 |
from langchain.chains.conversation.memory import ConversationBufferMemory
|
7 |
from langchain import OpenAI
|
8 |
from langchain.agents import initialize_agent
|
|
|
24 |
),
|
25 |
]
|
26 |
memory = ConversationBufferMemory(memory_key="chat_history")
|
27 |
+
llm=OpenAI(temperature=0.6)
|
28 |
agent_chain = initialize_agent(tools, llm, agent="conversational-react-description", memory=memory)
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
def predict(input, history=[]):
|
31 |
+
response = agent_chain.run(input)
|
32 |
history = history + [(input, response)]
|
33 |
response = history
|
34 |
# response = [response]
|