Spaces:
Build error
Build error
Download app.py from Aksh1t/create_a_form_101: direct link, hf CLI and curl.
- Browser
- Download file 931 Bytes
-
https://huggingface.co/spaces/Aksh1t/create_a_form_101/resolve/main/app.py
- Command line
-
hf download hf://spaces/Aksh1t/create_a_form_101/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Aksh1t/create_a_form_101/resolve/main/app.py
931 Bytes
| import gradio as gr | |
| from huggingface_hub import InferenceClient | |
| import asyncio | |
| # Define the model ID | |
| model_id = 'meta-llama/Meta-Llama-3-8B-Instruct' | |
| # Initialize the Hugging Face inference client | |
| client = InferenceClient(model=model_id) | |
| async def generate_text(prompt): | |
| # Use the Hugging Face client to generate text asynchronously | |
| response = await client.text_generation(prompt) | |
| return response['generated_text'] | |
| # Create Gradio interface | |
| inputs = gr.Textbox(label="Enter a prompt", lines=2) | |
| outputs = gr.Textbox(label="Generated Text", placeholder="Generated text will appear here") | |
| def predict(prompt): | |
| output_text = asyncio.run(generate_text(prompt)) | |
| return output_text | |
| iface = gr.Interface(fn=predict, inputs=inputs, outputs=outputs, title="Hugging Face Text Generation Model", description=f"Generate text based on a prompt using model '{model_id}'") | |
| if __name__ == "__main__": | |
| iface.launch() | |