Spaces:
Sleeping
Sleeping
Download app.py from odavis1/Theme_Generator: direct link, hf CLI and curl.
- Browser
- Download file 950 Bytes
-
https://huggingface.co/spaces/odavis1/Theme_Generator/resolve/main/app.py
- Command line
-
hf download hf://spaces/odavis1/Theme_Generator/app.py
-
curl -L -o app.py https://huggingface.co/spaces/odavis1/Theme_Generator/resolve/main/app.py
950 Bytes
| 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) |