oliveirabruno01 commited on
Commit
c46c78f
·
1 Parent(s): 2032808

Add base URL input

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -14,7 +14,7 @@ previous_answer = ""
14
  is_clearing = False
15
 
16
 
17
- def ai_response(api_key, input_text, shared_text, temperature):
18
  global previous_thought
19
 
20
  in_context_learning = [*prompts.continue_skill_example, *prompts.boilerplate_example, *prompts.continue_complete_skill_example,
@@ -36,7 +36,7 @@ def ai_response(api_key, input_text, shared_text, temperature):
36
 
37
  # Initialize OpenAI client
38
  client = OpenAI(
39
- base_url="https://openai-proxy.replicate.com/v1",
40
  api_key=api_key
41
  )
42
 
@@ -77,6 +77,7 @@ def ai_response(api_key, input_text, shared_text, temperature):
77
 
78
  with gr.Blocks() as demo:
79
  api_input = gr.Textbox(label="Your OpenAI API key", type="password")
 
80
 
81
  user_input = gr.Textbox(lines=2, label="User Input")
82
  cot_textbox = gr.Textbox(label="CoT etc.")
@@ -84,7 +85,7 @@ with gr.Blocks() as demo:
84
  temperature = gr.Slider(label="Temperature", minimum=0, maximum=2, step=0.01, value=0.01)
85
  # n_shots = gr.Slider(label="N-shots (~150 tokens each. It should not work 0-shot)", minimum=0, maximum=5, step=1, value=1)
86
  ai_btn = gr.Button("Generate AI Response")
87
- generation = ai_btn.click(fn=ai_response, inputs=[api_input, user_input, shared_textbox, temperature],
88
  outputs=[shared_textbox, cot_textbox])
89
 
90
 
 
14
  is_clearing = False
15
 
16
 
17
+ def ai_response(api_key, base_url, input_text, shared_text, temperature):
18
  global previous_thought
19
 
20
  in_context_learning = [*prompts.continue_skill_example, *prompts.boilerplate_example, *prompts.continue_complete_skill_example,
 
36
 
37
  # Initialize OpenAI client
38
  client = OpenAI(
39
+ base_url=base_url,
40
  api_key=api_key
41
  )
42
 
 
77
 
78
  with gr.Blocks() as demo:
79
  api_input = gr.Textbox(label="Your OpenAI API key", type="password")
80
+ base_url = gr.Textbox(label="OpenAI API base URL", value="https://openai-proxy.replicate.com/v1")
81
 
82
  user_input = gr.Textbox(lines=2, label="User Input")
83
  cot_textbox = gr.Textbox(label="CoT etc.")
 
85
  temperature = gr.Slider(label="Temperature", minimum=0, maximum=2, step=0.01, value=0.01)
86
  # n_shots = gr.Slider(label="N-shots (~150 tokens each. It should not work 0-shot)", minimum=0, maximum=5, step=1, value=1)
87
  ai_btn = gr.Button("Generate AI Response")
88
+ generation = ai_btn.click(fn=ai_response, inputs=[api_input, base_url, user_input, shared_textbox, temperature],
89
  outputs=[shared_textbox, cot_textbox])
90
 
91