Spaces:
Sleeping
Sleeping
thoristhor
commited on
Commit
•
91526e3
1
Parent(s):
99ce173
Update app.py
Browse files
app.py
CHANGED
@@ -5,16 +5,30 @@ from gpt_index import GPTIndexMemory, GPTPineconeIndex
|
|
5 |
import streamlit as st
|
6 |
from streamlit_chat import message
|
7 |
|
|
|
|
|
|
|
|
|
|
|
8 |
OPENAI_API_KEY=os.environ.get("OPENAI_API_KEY")
|
9 |
PINECONE_API_KEY=os.environ.get("PINECONE_API_KEY")
|
10 |
PINECONE_ENV=os.environ.get("PINECONE_ENV")
|
11 |
|
12 |
pointing_pinecone_index=pinecone.Index("sethgodin")
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
main_index=GPTPineconeIndex([],pinecone_index=pointing_pinecone_index)
|
15 |
memory = GPTIndexMemory(index=main_index, memory_key="chat_history", query_kwargs={"response_mode": "compact"})
|
16 |
-
llm=OpenAI(temperature=0
|
17 |
-
agent_chain = initialize_agent([], llm, agent="conversational-react-description", memory=memory)
|
18 |
|
19 |
if "history" not in st.session_state:
|
20 |
st.session_state.history = []
|
|
|
5 |
import streamlit as st
|
6 |
from streamlit_chat import message
|
7 |
|
8 |
+
from langchain.agents import Tool
|
9 |
+
from langchain.chains.conversation.memory import ConversationBufferMemory
|
10 |
+
from langchain import OpenAI
|
11 |
+
from langchain.agents import initialize_agent
|
12 |
+
|
13 |
OPENAI_API_KEY=os.environ.get("OPENAI_API_KEY")
|
14 |
PINECONE_API_KEY=os.environ.get("PINECONE_API_KEY")
|
15 |
PINECONE_ENV=os.environ.get("PINECONE_ENV")
|
16 |
|
17 |
pointing_pinecone_index=pinecone.Index("sethgodin")
|
18 |
|
19 |
+
tools = [
|
20 |
+
Tool(
|
21 |
+
name = "GPT Index",
|
22 |
+
func=lambda q: str(index.query(q)),
|
23 |
+
description="useful for when you want to answer questions about the author. The input to this tool should be a complete english sentence.",
|
24 |
+
return_direct=True
|
25 |
+
),
|
26 |
+
]
|
27 |
+
|
28 |
main_index=GPTPineconeIndex([],pinecone_index=pointing_pinecone_index)
|
29 |
memory = GPTIndexMemory(index=main_index, memory_key="chat_history", query_kwargs={"response_mode": "compact"})
|
30 |
+
llm=OpenAI(temperature=0)
|
31 |
+
agent_chain = initialize_agent([], llm, agent="conversational-react-description", memory=memory)ory)
|
32 |
|
33 |
if "history" not in st.session_state:
|
34 |
st.session_state.history = []
|