Spaces:
Runtime error
Runtime error
Download app.py from andyski/prototype-1: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/andyski/prototype-1/resolve/main/app.py
- Command line
-
hf download hf://spaces/andyski/prototype-1/app.py
-
curl -L -o app.py https://huggingface.co/spaces/andyski/prototype-1/resolve/main/app.py
1.03 kB
| from transformers import pipeline | |
| import gradio, requests | |
| #DEFINE MODEL TRHU PIPELINE | |
| pipeline = pipeline(task="translation", model="meta-llama/Meta-Llama-3-70B") | |
| #MAKING THE FUNCION FOR API IMPLE | |
| # def generate_translation(text_req, parameters=None,API_URL="https://api-inference.huggingface.co/models/Helsinki-NLP/opus-mt-zh-en"): | |
| # http_header = {"Authorization": f"Bearer {{dlaitoken1}}"} | |
| # data_input = {"inputs": text_req, "parameters": parameters} | |
| # http_response_handler = requests.request("POST", API_URL, headers=http_header, data=data_input) | |
| # http_response_formatted = http_response_handler.json() | |
| # return http_response_formatted | |
| #MAKING THE FUNCTION FOR PIPELINE IMPLE | |
| def generate(text_req): | |
| return pipeline(text_req) | |
| #GRADIO INTERFACE | |
| gradio_interface = gradio.Interface(fn=generate, inputs=[gradio.Textbox(label="WHAT DO YOU WANT TO TRANSLATE", lines=2)], outputs=[gradio.Textbox(label="TRANSLATION")], title="TRANSLATION APP") | |
| if __name__ == "__main__": | |
| gradio_interface.launch() |