twimbit-ai commited on
Commit
e4a98dc
·
1 Parent(s): 60be797

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -10,9 +10,6 @@ from langchain.embeddings.openai import OpenAIEmbeddings
10
 
11
  embeddings = OpenAIEmbeddings()
12
 
13
- # PINECONE_API_KEY = '6af52b8a-a3df-4189-899b-b21163027bb8'
14
- # PINECONE_API_ENV = 'asia-southeast1-gcp'
15
-
16
  PINECONE_API_KEY = os.getenv("PINECONE_API_KEY")
17
  PINECONE_API_ENV = os.getenv("PINECONE_API_ENV")
18
  PINECONE_INDEX = os.getenv("PINECONE_INDEX")
@@ -26,13 +23,16 @@ pinecone.init(
26
  index_name = PINECONE_INDEX
27
  vectorstore = Pinecone.from_existing_index(index_name=index_name, embedding=embeddings)
28
 
 
 
 
29
  class ChatWrapper:
30
 
31
  def __init__(self):
32
  self.lock = Lock()
33
 
34
  def __call__(
35
- self, inp: str, history: Optional[Tuple[str, str]], chain
36
  ):
37
  """Execute the chat functionality."""
38
  self.lock.acquire()
@@ -44,8 +44,6 @@ class ChatWrapper:
44
  # return history, history
45
  # Set OpenAI key
46
 
47
- chain = get_chain(vectorstore)
48
-
49
  import openai
50
  openai.api_key = os.getenv("OPENAI_API_KEY")
51
  # Run chain and append input.
@@ -94,8 +92,8 @@ with block:
94
 
95
  state = gr.State()
96
  agent_state = gr.State()
97
- submit.click(chat, inputs=[message, state, agent_state], outputs=[chatbot, state])
98
- message.submit(chat, inputs=[message, state, agent_state], outputs=[chatbot, state])
99
 
100
  # openai_api_key_textbox.change(
101
  # set_openai_api_key,
 
10
 
11
  embeddings = OpenAIEmbeddings()
12
 
 
 
 
13
  PINECONE_API_KEY = os.getenv("PINECONE_API_KEY")
14
  PINECONE_API_ENV = os.getenv("PINECONE_API_ENV")
15
  PINECONE_INDEX = os.getenv("PINECONE_INDEX")
 
23
  index_name = PINECONE_INDEX
24
  vectorstore = Pinecone.from_existing_index(index_name=index_name, embedding=embeddings)
25
 
26
+ chain = get_chain(vectorstore)
27
+
28
+
29
  class ChatWrapper:
30
 
31
  def __init__(self):
32
  self.lock = Lock()
33
 
34
  def __call__(
35
+ self, inp: str, history: Optional[Tuple[str, str]]
36
  ):
37
  """Execute the chat functionality."""
38
  self.lock.acquire()
 
44
  # return history, history
45
  # Set OpenAI key
46
 
 
 
47
  import openai
48
  openai.api_key = os.getenv("OPENAI_API_KEY")
49
  # Run chain and append input.
 
92
 
93
  state = gr.State()
94
  agent_state = gr.State()
95
+ submit.click(chat, inputs=[message, state], outputs=[chatbot, state])
96
+ message.submit(chat, inputs=[message, state], outputs=[chatbot, state])
97
 
98
  # openai_api_key_textbox.change(
99
  # set_openai_api_key,