Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
import random
|
|
|
|
|
|
|
| 4 |
models=[
|
| 5 |
"google/gemma-7b",
|
| 6 |
"google/gemma-7b-it",
|
|
@@ -13,6 +16,8 @@ InferenceClient(models[1]),
|
|
| 13 |
InferenceClient(models[2]),
|
| 14 |
InferenceClient(models[3]),
|
| 15 |
]
|
|
|
|
|
|
|
| 16 |
def format_prompt(message, history):
|
| 17 |
prompt = ""
|
| 18 |
if history:
|
|
@@ -55,6 +60,18 @@ def chat_inf(system_prompt,prompt,history,client_choice,seed,temp,tokens,top_p,r
|
|
| 55 |
history.append((prompt,output))
|
| 56 |
yield history
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
def clear_fn():
|
| 59 |
return None,None,None
|
| 60 |
rand_val=random.randint(1,1111111111111111)
|
|
@@ -91,8 +108,22 @@ with gr.Blocks() as app:
|
|
| 91 |
temp=gr.Slider(label="Temperature",step=0.01, minimum=0.01, maximum=1.0, value=0.9)
|
| 92 |
top_p=gr.Slider(label="Top-P",step=0.01, minimum=0.01, maximum=1.0, value=0.9)
|
| 93 |
rep_p=gr.Slider(label="Repetition Penalty",step=0.1, minimum=0.1, maximum=2.0, value=1.0)
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
|
|
|
| 96 |
|
| 97 |
go=btn.click(check_rand,[rand,seed],seed).then(chat_inf,[sys_inp,inp,chat_b,client_choice,seed,temp,tokens,top_p,rep_p],chat_b)
|
| 98 |
stop_btn.click(None,None,None,cancels=go)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from gradio_client import Client
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
import random
|
| 5 |
+
ss_client = Client("https://omnibus-html-image-current-tab.hf.space/")
|
| 6 |
+
|
| 7 |
models=[
|
| 8 |
"google/gemma-7b",
|
| 9 |
"google/gemma-7b-it",
|
|
|
|
| 16 |
InferenceClient(models[2]),
|
| 17 |
InferenceClient(models[3]),
|
| 18 |
]
|
| 19 |
+
|
| 20 |
+
|
| 21 |
def format_prompt(message, history):
|
| 22 |
prompt = ""
|
| 23 |
if history:
|
|
|
|
| 60 |
history.append((prompt,output))
|
| 61 |
yield history
|
| 62 |
|
| 63 |
+
def get_screenshot(chat: list,height=5000,width=600,chatblock=[],theme="light",wait=3000,header=True):
|
| 64 |
+
print(chatblock)
|
| 65 |
+
tog = 0
|
| 66 |
+
if chatblock:
|
| 67 |
+
tog = 3
|
| 68 |
+
result = ss_client.predict(str(chat),height,width,chatblock,header,theme,wait,api_name="/run_script")
|
| 69 |
+
out = f'https://omnibus-html-image-current-tab.hf.space/file={result[tog]}'
|
| 70 |
+
print(out)
|
| 71 |
+
return out
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
|
| 75 |
def clear_fn():
|
| 76 |
return None,None,None
|
| 77 |
rand_val=random.randint(1,1111111111111111)
|
|
|
|
| 108 |
temp=gr.Slider(label="Temperature",step=0.01, minimum=0.01, maximum=1.0, value=0.9)
|
| 109 |
top_p=gr.Slider(label="Top-P",step=0.01, minimum=0.01, maximum=1.0, value=0.9)
|
| 110 |
rep_p=gr.Slider(label="Repetition Penalty",step=0.1, minimum=0.1, maximum=2.0, value=1.0)
|
| 111 |
+
with gr.Accordion(label="Screenshot",open=False):
|
| 112 |
+
with gr.Row():
|
| 113 |
+
with gr.Column(scale=3):
|
| 114 |
+
im_btn=gr.Button("Screenshot")
|
| 115 |
+
img=gr.Image(type='filepath')
|
| 116 |
+
with gr.Column(scale=1):
|
| 117 |
+
with gr.Row():
|
| 118 |
+
im_height=gr.Number(label="Height",value=5000)
|
| 119 |
+
im_width=gr.Number(label="Width",value=500)
|
| 120 |
+
wait_time=gr.Number(label="Wait Time",value=3000)
|
| 121 |
+
theme=gr.Radio(label="Theme", choices=["light","dark"],value="light")
|
| 122 |
+
chatblock=gr.Dropdown(label="Chatblocks",info="Choose specific blocks of chat",choices=[c for c in range(1,40)],multiselect=True)
|
| 123 |
+
|
| 124 |
+
|
| 125 |
|
| 126 |
+
im_btn.click(get_screenshot,[chat_b,im_height,im_width,chatblock,theme,wait_time],img)
|
| 127 |
|
| 128 |
go=btn.click(check_rand,[rand,seed],seed).then(chat_inf,[sys_inp,inp,chat_b,client_choice,seed,temp,tokens,top_p,rep_p],chat_b)
|
| 129 |
stop_btn.click(None,None,None,cancels=go)
|