CultriX commited on
Commit
eaac079
Β·
verified Β·
1 Parent(s): e216d73

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -51,22 +51,22 @@ def launch_interface():
51
 
52
  with gr.Row():
53
  with gr.Column(scale=2):
54
- question = gr.Textbox(label="🧠 Question", placeholder="Ask me anything...")
55
- model_id = gr.Textbox(value="gpt-4o-mini", label="🧬 Model ID")
56
- hf_token = gr.Textbox(value=os.getenv("HF_TOKEN", ""), label="πŸ”‘ HuggingFace Token", type="password")
57
- openai_api_key = gr.Textbox(value=os.getenv("OPENAI_API_KEY", ""), label="πŸ”‘ OpenAI API Key", type="password")
58
  serpapi_key = gr.Textbox(value=os.getenv("SERPAPI_API_KEY", ""), label="πŸ” Serper API Key", type="password", visible=True)
59
  api_endpoint = gr.Textbox(value=os.getenv("API_ENDPOINT", "https://api.openai.com"), label="Default API Endpoint", placeholder="https://api.openai.com", visible=True)
60
  custom_api_endpoint = gr.Textbox(label="πŸ”Œ Custom API Endpoint URL", placeholder="https://your-api-endpoint.com", visible=False)
61
- use_custom_endpoint = gr.Checkbox(label="🌐 Use Custom API Endpoint")
62
  custom_api_endpoint = gr.Textbox(label="πŸ”Œ Custom API Endpoint URL", placeholder="https://your-api-endpoint.com", visible=False)
63
  custom_api_key = gr.Textbox(label="πŸ” Custom API Endpoint Key", type="password", visible=False)
64
- search_provider = gr.Dropdown(label="πŸ”Ž Search Provider", choices=["serper", "searxng"], value="serper")
65
  search_api_key = gr.Textbox(label="πŸ”‘ Search Provider API Key (optional)", type="password", visible=False)
66
  custom_search_url = gr.Textbox(label="🌐 Custom SearxNG Instance URL", placeholder="https://your-searxng-instance/search", visible=False)
67
- submit_btn = gr.Button("πŸš€ Run Agent")
68
  with gr.Column(scale=1):
69
- output = gr.Textbox(label="πŸ“€ Answer", lines=15)
70
 
71
  def update_search_visibility(provider):
72
  return {
@@ -77,7 +77,6 @@ def launch_interface():
77
 
78
  def update_custom_endpoint_visibility(checked):
79
  return {
80
- api_endpoint: gr.update(visible=False),
81
  custom_api_endpoint: gr.update(visible=checked),
82
  custom_api_key: gr.update(visible=checked),
83
  }
@@ -86,7 +85,7 @@ def launch_interface():
86
  outputs=[serpapi_key, custom_search_url, search_api_key])
87
 
88
  use_custom_endpoint.change(fn=update_custom_endpoint_visibility, inputs=use_custom_endpoint,
89
- outputs=[custom_api_endpoint, custom_api_key])
90
 
91
  submit_btn.click(fn=setup_agent,
92
  inputs=[question, model_id, hf_token, openai_api_key, serpapi_key, api_endpoint,
 
51
 
52
  with gr.Row():
53
  with gr.Column(scale=2):
54
+ question = gr.Textbox(label="🧠 Question", placeholder="Ask me anything...", visible=True)
55
+ model_id = gr.Textbox(value="gpt-4o-mini", label="🧬 Model ID", visible=True)
56
+ hf_token = gr.Textbox(value=os.getenv("HF_TOKEN", ""), label="πŸ”‘ HuggingFace Token", type="password", visible=True)
57
+ openai_api_key = gr.Textbox(value=os.getenv("OPENAI_API_KEY", ""), label="πŸ”‘ OpenAI API Key", type="password", visible=True)
58
  serpapi_key = gr.Textbox(value=os.getenv("SERPAPI_API_KEY", ""), label="πŸ” Serper API Key", type="password", visible=True)
59
  api_endpoint = gr.Textbox(value=os.getenv("API_ENDPOINT", "https://api.openai.com"), label="Default API Endpoint", placeholder="https://api.openai.com", visible=True)
60
  custom_api_endpoint = gr.Textbox(label="πŸ”Œ Custom API Endpoint URL", placeholder="https://your-api-endpoint.com", visible=False)
61
+ use_custom_endpoint = gr.Checkbox(label="🌐 Use Custom API Endpoint", visible=True)
62
  custom_api_endpoint = gr.Textbox(label="πŸ”Œ Custom API Endpoint URL", placeholder="https://your-api-endpoint.com", visible=False)
63
  custom_api_key = gr.Textbox(label="πŸ” Custom API Endpoint Key", type="password", visible=False)
64
+ search_provider = gr.Dropdown(label="πŸ”Ž Search Provider", choices=["serper", "searxng"], value="serper", visible=True)
65
  search_api_key = gr.Textbox(label="πŸ”‘ Search Provider API Key (optional)", type="password", visible=False)
66
  custom_search_url = gr.Textbox(label="🌐 Custom SearxNG Instance URL", placeholder="https://your-searxng-instance/search", visible=False)
67
+ submit_btn = gr.Button("πŸš€ Run Agent", visible=True)
68
  with gr.Column(scale=1):
69
+ output = gr.Textbox(label="πŸ“€ Answer", lines=20)
70
 
71
  def update_search_visibility(provider):
72
  return {
 
77
 
78
  def update_custom_endpoint_visibility(checked):
79
  return {
 
80
  custom_api_endpoint: gr.update(visible=checked),
81
  custom_api_key: gr.update(visible=checked),
82
  }
 
85
  outputs=[serpapi_key, custom_search_url, search_api_key])
86
 
87
  use_custom_endpoint.change(fn=update_custom_endpoint_visibility, inputs=use_custom_endpoint,
88
+ outputs=[api_endpoint, openai_api_key, custom_api_endpoint, custom_api_key])
89
 
90
  submit_btn.click(fn=setup_agent,
91
  inputs=[question, model_id, hf_token, openai_api_key, serpapi_key, api_endpoint,