thoristhor commited on
Commit
d0304da
1 Parent(s): 7bb6784

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -2
app.py CHANGED
@@ -4,5 +4,29 @@ import gradio as gr
4
  import pinecone
5
  from gpt_index import GPTIndexMemory, GPTPineconeIndex
6
 
7
- os.environ['OPENAI_API_KEY']
8
- os.environ['PINECONE_API_KEY']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  import pinecone
5
  from gpt_index import GPTIndexMemory, GPTPineconeIndex
6
 
7
+ openaiapi=os.environ['OPENAI_API_KEY']
8
+ pineconeapi=os.environ['PINECONE_API_KEY']
9
+ os.environ['PINECONE_ENV']
10
+
11
+ pointing_pinecone_index=pinecone.Index("sethgodin")
12
+
13
+ main_index=GPTPineconeIndex([],pinecone_index=pointing_pinecone_index)
14
+ memory = GPTIndexMemory(index=main_index, memory_key="chat_history", query_kwargs={"response_mode": "compact"})
15
+ llm=OpenAI(temperature=0)
16
+ agent_chain = initialize_agent([], llm, agent="conversational-react-description", memory=memory
17
+
18
+ def predict(input, history[])
19
+ agent_chain.run(input=input)
20
+ return agent_chain
21
+
22
+
23
+ with gr.Blocks() as demo:
24
+ chatbot = gr.Chatbot()
25
+ state = gr.State([])
26
+
27
+ with gr.Row():
28
+ txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter").style(container=False)
29
+
30
+ txt.submit(predict, [txt, state], [chatbot, state])
31
+
32
+ demo.launch()