EasyYI / app.py
Tonic's picture
Create app.py
c2ca11f
raw
history blame
2.24 kB
import gradio as gr
import gradio_client
from gradio_client import Client
def chat_api_interface(messages, model, frequency_penalty=0, logit_bias=None, max_tokens=None, n=1, presence_penalty=0, response_format="text", seed=None, stop=None, stream=False, temperature=1, top_p=1, tools=None, tool_choice="none", user=None):
# PASS
# PASS
return "API response here"
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
messages = gr.Textbox(label="Messages (JSON format)", placeholder="Enter messages as a JSON array")
model = gr.Textbox(label="Model ID", placeholder="Enter the model ID")
frequency_penalty = gr.Number(label="Frequency Penalty", value=0)
logit_bias = gr.Textbox(label="Logit Bias (JSON format)", placeholder="Enter logit bias as JSON")
max_tokens = gr.Number(label="Max Tokens", optional=True)
n = gr.Number(label="N", value=1)
presence_penalty = gr.Number(label="Presence Penalty", value=0)
response_format = gr.Radio(label="Response Format", choices=["text", "json_object"], value="text")
seed = gr.Number(label="Seed", optional=True)
stop = gr.Textbox(label="Stop Sequence(s)", placeholder="Enter stop sequences")
stream = gr.Checkbox(label="Stream", value=False)
temperature = gr.Slider(label="Temperature", minimum=0, maximum=2, value=1)
top_p = gr.Slider(label="Top P", minimum=0, maximum=1, value=1)
tools = gr.Textbox(label="Tools (JSON format)", optional=True, placeholder="Enter tools as JSON")
tool_choice = gr.Textbox(label="Tool Choice", value="none", placeholder="Enter tool choice")
user = gr.Textbox(label="User", optional=True, placeholder="Enter user identifier")
with gr.Column():
submit_btn = gr.Button("Submit")
output = gr.Textbox(label="API Response", readonly=True)
submit_btn.click(
chat_api_interface,
inputs=[messages, model, frequency_penalty, logit_bias, max_tokens, n, presence_penalty, response_format, seed, stop, stream, temperature, top_p, tools, tool_choice, user],
outputs=output
)
demo.launch()