jpfearnworks commited on
Commit
3514c82
1 Parent(s): 279a6d2

Update example/api interaction

Browse files
modules/knowledge_retrieval/component.py CHANGED
@@ -3,7 +3,8 @@ import gradio as gr
3
  import os
4
  openai_api_key = os.getenv("OPENAI_API_KEY")
5
 
6
- def determine_and_execute(api_key, question: str, temperature: float):
 
7
  config = get_knowledge_domain_router_config(temperature=temperature)
8
  config.temperature = temperature
9
  determiner = KnowledgeDomainRouter(api_key=api_key, config=config, question=question, display=print)
@@ -22,6 +23,6 @@ def create_knowledge_router_ui(cache_examples=False):
22
  reasoning = gr.Textbox(label="Reasoning")
23
 
24
  generate_button = gr.Button(label="Generate")
25
- generate_button.click(determine_and_execute, outputs=[reasoning_strategy, reasoning], inputs=[api_key, question, temperature])
26
- gr.Examples(examples=examples, fn=determine_and_execute, cache_examples=cache_examples, inputs=[question, temperature], outputs=[reasoning_strategy, reasoning])
27
 
 
3
  import os
4
  openai_api_key = os.getenv("OPENAI_API_KEY")
5
 
6
+ def determine_and_execute(question: str, temperature: float, api_key = "" ):
7
+ os.environ["OPENAI_API_KEY"] = api_key
8
  config = get_knowledge_domain_router_config(temperature=temperature)
9
  config.temperature = temperature
10
  determiner = KnowledgeDomainRouter(api_key=api_key, config=config, question=question, display=print)
 
23
  reasoning = gr.Textbox(label="Reasoning")
24
 
25
  generate_button = gr.Button(label="Generate")
26
+ generate_button.click(determine_and_execute, outputs=[reasoning_strategy, reasoning], inputs=[question, temperature, api_key])
27
+ gr.Examples(examples=examples, fn=determine_and_execute, cache_examples=cache_examples, inputs=[question, temperature, api_key], outputs=[reasoning_strategy, reasoning])
28
 
modules/reasoning/component.py CHANGED
@@ -4,7 +4,8 @@ import os
4
  openai_api_key = os.getenv("OPENAI_API_KEY")
5
 
6
 
7
- def determine_and_execute(api_key,question, temperature):
 
8
  config = get_reasoning_router_config(temperature=temperature)
9
  config.temperature = temperature
10
  determiner = ReasoningRouter(api_key=api_key, config=config, question=question, display=print)
@@ -28,6 +29,6 @@ def create_reasoning_router_ui(cache_examples=False):
28
  reasoning = gr.Textbox(label="Reasoning")
29
 
30
  generate_button = gr.Button(label="Generate")
31
- generate_button.click(determine_and_execute, outputs=[reasoning_strategy, reasoning], inputs=[api_key, question, temperature])
32
- gr.Examples(examples=examples, fn=determine_and_execute, cache_examples=cache_examples, inputs=[question, temperature], outputs=[reasoning_strategy, reasoning])
33
 
 
4
  openai_api_key = os.getenv("OPENAI_API_KEY")
5
 
6
 
7
+ def determine_and_execute(question, temperature, api_key=""):
8
+ os.environ["OPENAI_API_KEY"] = api_key
9
  config = get_reasoning_router_config(temperature=temperature)
10
  config.temperature = temperature
11
  determiner = ReasoningRouter(api_key=api_key, config=config, question=question, display=print)
 
29
  reasoning = gr.Textbox(label="Reasoning")
30
 
31
  generate_button = gr.Button(label="Generate")
32
+ generate_button.click(determine_and_execute, outputs=[reasoning_strategy, reasoning], inputs=[question, temperature, api_key])
33
+ gr.Examples(examples=examples, fn=determine_and_execute, cache_examples=cache_examples, inputs=[question, temperature, api_key], outputs=[reasoning_strategy, reasoning])
34