File size: 959 Bytes
173b1ea
2121d66
 
173b1ea
2121d66
173b1ea
 
5b32125
 
005a9a5
061f7d3
5b32125
173b1ea
 
0f7f5e4
173b1ea
 
2121d66
 
173b1ea
2121d66
173b1ea
900a270
173b1ea
 
900a270
173b1ea
 
 
2121d66
 
 
173b1ea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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()