Spaces:
Build error
Build error
Download app.py from Rishabh12j/CourseWork: direct link, hf CLI and curl.
- Browser
- Download file 959 Bytes
-
https://huggingface.co/spaces/Rishabh12j/CourseWork/resolve/main/app.py
- Command line
-
hf download hf://spaces/Rishabh12j/CourseWork/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Rishabh12j/CourseWork/resolve/main/app.py
959 Bytes
| import requests | |
| import os | |
| import gradio as gr | |
| import json | |
| # Replace the empty string with your model id below | |
| model_id = "7qrmoo93" | |
| api_key =os.getenv("API_Key") | |
| token="Api-Key "+api_key | |
| def res(data): | |
| print(data) | |
| resp = requests.post("https://model-7qrmoo93.api.baseten.co/production/predict",headers={"Authorization": token},json={'top_p': 0.75, 'prompt': data, 'num_beams': 4, 'temperature': 0.4},) | |
| print(resp.json()) | |
| return resp.json() | |
| def main(): | |
| with gr.Blocks() as demo: | |
| with gr.Row(): | |
| with gr.Column(scale=3): | |
| text_input = gr.Textbox(lines=4, placeholder="Input prompt") | |
| with gr.Row(): | |
| with gr.Column(scale=1): | |
| text_output = gr.Textbox(lines=4, placeholder="Output prompt") | |
| with gr.Row(): | |
| text_button = gr.Button("Send") | |
| text_button.click(res, text_input, text_output) | |
| demo.launch() | |
| if __name__ == "__main__": | |
| main() |