File size: 1,086 Bytes
801981e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42ea2d2
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
34
35
36
37
38
39
40
41
import gradio as gr
import requests

"""
    Get your API key from https://makersuite.google.com/app/apikey 
"""

API_KEY = "AIzaSyApI6-GxkTMrpAc4P4wdy37jn_6SwHTTtw" #Enter your API key
API_URL = "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key={API_KEY}".format(API_KEY=API_KEY)


def processor(input):

    payload = {
        "contents":[
            {
                "parts":[
                    {
                        "text": "Make a joke from the following statement," + input
                    }
                ]
            }
        ]
    }

    response = requests.post(API_URL,json=payload)

    return response.json()['candidates'][0]['content']['parts'][0]['text']

"""
    We have used the gradio framework,
    Full documentation visit https://www.gradio.app/
"""

inputs = gr.Textbox(lines=2, placeholder="Eg: Tell me a coffee shop joke",label="Input Text")
outputs = gr.Textbox(label="Joke(s) Generated")
title = "Joke Generator App"

app = gr.Interface(fn=processor,inputs=inputs,outputs="text",title=title)
app.launch()