vikaskookna commited on
Commit
0930722
·
1 Parent(s): 35da36f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -5,7 +5,8 @@ from langchain.agents import initialize_agent
5
  from langchain import PromptTemplate, HuggingFaceHub, LLMChain
6
  from langchain.llms import OpenAI
7
 
8
- def funct(sentence):
 
9
  llm = OpenAI(temperature=0)
10
 
11
  # Next, let's load some tools to use. Note that the `llm-math` tool uses an LLM, so we need to pass that in.
@@ -17,6 +18,13 @@ def funct(sentence):
17
 
18
 
19
  with gr.Blocks() as app:
 
 
 
 
 
 
 
20
  message = gr.Textbox(label='input')
21
  sentiment = gr.Textbox(label='chatbot')
22
  submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
@@ -34,7 +42,7 @@ with gr.Blocks() as app:
34
  )
35
 
36
  submit.click(fn=funct,
37
- inputs=message,
38
  outputs=sentiment)
39
 
40
  app.launch(debug=True)
 
5
  from langchain import PromptTemplate, HuggingFaceHub, LLMChain
6
  from langchain.llms import OpenAI
7
 
8
+ def funct(key, sentence):
9
+ os.environ["OPENAI_API_KEY"] = key
10
  llm = OpenAI(temperature=0)
11
 
12
  # Next, let's load some tools to use. Note that the `llm-math` tool uses an LLM, so we need to pass that in.
 
18
 
19
 
20
  with gr.Blocks() as app:
21
+ with gr.Row():
22
+ with gr.Column():
23
+ gr.HTML(
24
+ """<b><center>GPT + Google</center></b>""")
25
+
26
+ openai_api_key_textbox = gr.Textbox(placeholder="Paste your OpenAI API key (sk-...)",
27
+ show_label=False, lines=1, type='password')
28
  message = gr.Textbox(label='input')
29
  sentiment = gr.Textbox(label='chatbot')
30
  submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
 
42
  )
43
 
44
  submit.click(fn=funct,
45
+ inputs=[openai_api_key_textbox, message],
46
  outputs=sentiment)
47
 
48
  app.launch(debug=True)