Spaces:
Runtime error
Runtime error
File size: 3,803 Bytes
c2ca11f f7e6046 abf0eee a1f4499 f7e6046 abf0eee c2ca11f 8892df0 0006e9b 8892df0 c2ca11f 0006e9b 8892df0 c2ca11f 8892df0 0006e9b 8892df0 728d1fa c2ca11f eca4b42 c2ca11f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import gradio as gr
import gradio_client
from gradio_client import Client
title = """# Welcome To Tonic's Easy YI-6B-200K"""
description = """This is a [connector that looks like open ai](https://huggingface.co/spaces/Tonic1/TonicsYI-6B-200k) on the inputs , then ignores all that and connects to my [YI-6B-200K endpoint](https://huggingface.co/01-ai/Yi-6B-200K). This helps using [Yi for AGI here](https://huggingface.co/spaces/Tonic/AGYIntelligence)
Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community on 👻Discord: [Discord](https://discord.gg/nXx5wbX9) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [PolyGPT](https://github.com/tonic-ai/polygpt-alpha)
"""
client = Client("https://tonic1-tonicsyi-6b-200k.hf.space/--replicas/b42d8/")
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=0.9, top_p=1, tools=None, tool_choice="none", user=None):
try:
result = client.predict(
your_message=messages,
system_prompt="",
max_new_tokens=16000,
temperature=temperature,
top_p=top_p,
top_k=presence_penalty,
disable_for_faster_inference=False,
api_name="/predict"
)
return result
except Exception as e:
return f"An error occurred: {str(e)}"
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", value="[{\"role\": \"user\", \"content\": \"Hello, how can I help you today?\"}, {\"role\": \"assistant\", \"content\": \"I'm looking for information on renewable energy sources.\"}]")
model = gr.Textbox(label="Model ID", placeholder="Enter the model ID", value="text-davinci-003")
frequency_penalty = gr.Number(label="Frequency Penalty", value=0.5)
logit_bias = gr.Textbox(label="Logit Bias (JSON format)", placeholder="Enter logit bias as JSON", value="{\"50256\": -100, \"50257\": 100}")
max_tokens = gr.Number(label="Max Tokens", value=150)
n = gr.Number(label="N", value=3)
presence_penalty = gr.Number(label="Presence Penalty", value=0.6)
response_format = gr.Radio(label="Response Format", choices=["text", "json_object"], value="text")
seed = gr.Number(label="Seed", value=42)
stop = gr.Textbox(label="Stop Sequence(s)", placeholder="Enter stop sequences", value="[\"\\n\", \" end\"]")
stream = gr.Checkbox(label="Stream", value=False)
temperature = gr.Slider(label="Temperature", minimum=0, maximum=2, value=0.7)
top_p = gr.Slider(label="Top P", minimum=0, maximum=1, value=0.9)
tools = gr.Textbox(label="Tools (JSON format)", placeholder="Enter tools as JSON", value="{\"spellcheck\": true, \"grammar_check\": false}")
tool_choice = gr.Textbox(label="Tool Choice", value="spellcheck", placeholder="Enter tool choice")
user = gr.Textbox(label="User", placeholder="Enter user identifier", value="user123")
with gr.Column():
submit_btn = gr.Button("Submit")
output = gr.Textbox(label="API Response")
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() |