Spaces:
Runtime error
Runtime error
xlr8harder
commited on
Commit
•
450c82c
1
Parent(s):
2160f30
move buttons, set default
Browse files
app.py
CHANGED
@@ -2,8 +2,10 @@ import gradio as gr
|
|
2 |
from openai import OpenAI
|
3 |
import os
|
4 |
|
|
|
|
|
5 |
# Initialize the OpenAI client
|
6 |
-
api_key = os.environ.get('HYPERBOLIC_API_KEY'
|
7 |
client = OpenAI(
|
8 |
base_url="https://api.hyperbolic.xyz/v1",
|
9 |
api_key=api_key,
|
@@ -27,23 +29,28 @@ def append_completion(prompt, completion):
|
|
27 |
new_prompt = f"{prompt}\n{completion}".strip()
|
28 |
return new_prompt, "" # Return new prompt and empty completion
|
29 |
|
|
|
|
|
|
|
30 |
with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
31 |
gr.Markdown("# Llama 3.1 405B Completion Interface")
|
32 |
|
33 |
with gr.Row():
|
34 |
with gr.Column(scale=2):
|
35 |
-
prompt_input = gr.Textbox(label="Prompt", lines=5,
|
36 |
with gr.Column(scale=1):
|
37 |
temperature_slider = gr.Slider(minimum=0, maximum=1, value=0.7, step=0.1, label="Temperature")
|
38 |
repetition_penalty_slider = gr.Slider(minimum=0, maximum=2, value=1.1, step=0.1, label="Repetition Penalty")
|
39 |
stop_phrase_input = gr.Textbox(label="Stop Phrase", placeholder="Enter stop phrase (optional)")
|
40 |
|
41 |
-
|
|
|
|
|
|
|
|
|
42 |
|
43 |
output_text = gr.Textbox(label="Generated Completion", lines=10)
|
44 |
|
45 |
-
append_button = gr.Button("Append Completion to Prompt")
|
46 |
-
|
47 |
generate_button.click(
|
48 |
generate_completion,
|
49 |
inputs=[prompt_input, temperature_slider, repetition_penalty_slider, stop_phrase_input],
|
@@ -55,6 +62,11 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
|
55 |
inputs=[prompt_input, output_text],
|
56 |
outputs=[prompt_input, output_text]
|
57 |
)
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
gr.Markdown("""
|
60 |
---
|
|
|
2 |
from openai import OpenAI
|
3 |
import os
|
4 |
|
5 |
+
default_prompt = "The best thing about being a cat is"
|
6 |
+
|
7 |
# Initialize the OpenAI client
|
8 |
+
api_key = os.environ.get('HYPERBOLIC_API_KEY')
|
9 |
client = OpenAI(
|
10 |
base_url="https://api.hyperbolic.xyz/v1",
|
11 |
api_key=api_key,
|
|
|
29 |
new_prompt = f"{prompt}\n{completion}".strip()
|
30 |
return new_prompt, "" # Return new prompt and empty completion
|
31 |
|
32 |
+
def clear_fields():
|
33 |
+
return "", ""
|
34 |
+
|
35 |
with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
36 |
gr.Markdown("# Llama 3.1 405B Completion Interface")
|
37 |
|
38 |
with gr.Row():
|
39 |
with gr.Column(scale=2):
|
40 |
+
prompt_input = gr.Textbox(label="Prompt", lines=5, value="The best thing about being a cat is")
|
41 |
with gr.Column(scale=1):
|
42 |
temperature_slider = gr.Slider(minimum=0, maximum=1, value=0.7, step=0.1, label="Temperature")
|
43 |
repetition_penalty_slider = gr.Slider(minimum=0, maximum=2, value=1.1, step=0.1, label="Repetition Penalty")
|
44 |
stop_phrase_input = gr.Textbox(label="Stop Phrase", placeholder="Enter stop phrase (optional)")
|
45 |
|
46 |
+
with gr.Row():
|
47 |
+
generate_button = gr.Button("Generate Completion")
|
48 |
+
append_button = gr.Button("Append Completion to Prompt")
|
49 |
+
clear_button = gr.Button("Clear All Fields")
|
50 |
+
|
51 |
|
52 |
output_text = gr.Textbox(label="Generated Completion", lines=10)
|
53 |
|
|
|
|
|
54 |
generate_button.click(
|
55 |
generate_completion,
|
56 |
inputs=[prompt_input, temperature_slider, repetition_penalty_slider, stop_phrase_input],
|
|
|
62 |
inputs=[prompt_input, output_text],
|
63 |
outputs=[prompt_input, output_text]
|
64 |
)
|
65 |
+
|
66 |
+
clear_button.click(
|
67 |
+
clear_fields,
|
68 |
+
outputs=[prompt_input, output_text]
|
69 |
+
)
|
70 |
|
71 |
gr.Markdown("""
|
72 |
---
|