billxbf commited on
Commit
4d11c91
1 Parent(s): ebca2a7

disable tmp key

Browse files
Files changed (3) hide show
  1. app.py +8 -13
  2. data/tmp_key/openai.key +0 -1
  3. data/tmp_key/serpapi.key +0 -1
app.py CHANGED
@@ -1,18 +1,11 @@
1
  import gradio as gr
2
  import os
3
- with open(os.path.join('./data/tmp_key/', 'openai.key'), 'r') as f:
4
- os.environ["OPENAI_API_KEY"] = f.read().strip()
5
- with open(os.path.join('./data/tmp_key/', 'serpapi.key'), 'r') as f:
6
- os.environ["SERPAPI_API_KEY"] = f.read().strip()
7
 
8
- from algos.PWS import *
9
- from utils.util import *
10
-
11
- def process(tools, model, input_text):
12
- # This is a placeholder function. Replace it with your own logic.
13
- planner = "Planner output for " + input_text
14
- solver = "Solver output for " + input_text
15
- output = "Output for " + input_text
16
 
17
  method = PWS_Base(planner_model=model, solver_model=model,
18
  fewshot=fewshots.TRIVIAQA_PWS, available_tools=tools)
@@ -25,13 +18,15 @@ def process(tools, model, input_text):
25
  tools = gr.components.CheckboxGroup(['Wikipedia', 'Google', 'LLM', 'WolframAlpha', 'Calculator'],label="Tools")
26
  model = gr.components.Dropdown(["text-davinci-003", "gpt-3.5-turbo"], label="Model")
27
  input_text = gr.components.Textbox(lines=2, placeholder="Input Here...", label="Input")
 
 
28
  planner = gr.components.Textbox(lines=4, label="Planner")
29
  solver = gr.components.Textbox(lines=4, label="Solver")
30
  output = gr.components.Textbox(label="Output")
31
 
32
  iface = gr.Interface(
33
  fn=process,
34
- inputs=[tools, model, input_text],
35
  outputs=[planner, solver, output],
36
  examples=[
37
  [["Wikipedia", "LLM"], "gpt-3.5-turbo", "American Callan Pinckney’s eponymously named system became a best-selling (1980s-2000s) book/video franchise in what genre?"],
 
1
  import gradio as gr
2
  import os
 
 
 
 
3
 
4
+ def process(tools, model, input_text, openai_key, serpapi_key):
5
+ os.environ["OPENAI_API_KEY"] = openai_key
6
+ os.environ["SERPAPI_API_KEY"] = serpapi_key
7
+ from algos.PWS import PWS_Base
8
+ from utils.util import fewshots
 
 
 
9
 
10
  method = PWS_Base(planner_model=model, solver_model=model,
11
  fewshot=fewshots.TRIVIAQA_PWS, available_tools=tools)
 
18
  tools = gr.components.CheckboxGroup(['Wikipedia', 'Google', 'LLM', 'WolframAlpha', 'Calculator'],label="Tools")
19
  model = gr.components.Dropdown(["text-davinci-003", "gpt-3.5-turbo"], label="Model")
20
  input_text = gr.components.Textbox(lines=2, placeholder="Input Here...", label="Input")
21
+ openai_key = gr.components.Textbox(lines=1, placeholder="Provide your openai key Here...", label="OpenAI Key")
22
+ serpapi_key = gr.components.Textbox(lines=1, placeholder="Only needed if you use Google tool.", label="SerpAPI Key")
23
  planner = gr.components.Textbox(lines=4, label="Planner")
24
  solver = gr.components.Textbox(lines=4, label="Solver")
25
  output = gr.components.Textbox(label="Output")
26
 
27
  iface = gr.Interface(
28
  fn=process,
29
+ inputs=[tools, model, input_text, openai_key, serpapi_key],
30
  outputs=[planner, solver, output],
31
  examples=[
32
  [["Wikipedia", "LLM"], "gpt-3.5-turbo", "American Callan Pinckney’s eponymously named system became a best-selling (1980s-2000s) book/video franchise in what genre?"],
data/tmp_key/openai.key DELETED
@@ -1 +0,0 @@
1
- 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
 
 
data/tmp_key/serpapi.key DELETED
@@ -1 +0,0 @@
1
- 8a158c526d6f258efab645fc935e846655678766f05ec444aa19009eac63989e