File size: 950 Bytes
d0113a2
 
 
7562228
0d3dedc
77aa961
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from huggingface_hub import InferenceClient

themes=["Pick a Genre", "thriller", "fantasy", "romance", "sci-fi", "mystery", "fiction"]

def reaction(text, theme):
  modelName= 'HuggingFaceH4/zephyr-7b-beta'
  thiscontent=f'Give only one {theme} response to this statement: {text}?'
  messages=[{'role': 'user', 'content': thiscontent}]
  client=InferenceClient(model=modelName)
  output=client.chat_completion(messages, max_tokens=100)
  reaction=output.choices[0].message.content
  return reaction
with gr.Blocks(theme=gr.themes.Citrus()) as demo:
  with gr.Row():
    with gr.Column():
       text = gr.Textbox(label="What\'s your idea",scale=1)
       theme=gr.Dropdown(themes, label="genre")
       react_btn = gr.Button("Generate",scale=1)
       output = gr.Textbox(label="Reaction",scale=1)
    with gr.Column():
        react_btn.click(fn=reaction, inputs=[text, theme], outputs=output)
demo.launch(debug=True, share=True)