Spaces:
Sleeping
Sleeping
File size: 1,092 Bytes
8977e54 b2348b3 8977e54 b2348b3 8977e54 b2348b3 8977e54 b2348b3 07b3a0e 8977e54 b2348b3 |
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 |
import gradio as gr
import requests
# Define the function to interact with the API
def generate_content(text):
url = 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=AIzaSyAflU5a8T3dCuIrkql737ZQtqWdrPmo0ts'
headers = {'Content-Type': 'application/json'}
data = {
"contents": [
{
"parts": [
{
"text": text
}
]
}
]
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
return response.json() # You can customize this to return specific parts of the response
else:
return f"Error: {response.status_code} - {response.text}"
# Create a Gradio interface
iface = gr.Interface(
fn=generate_content,
inputs="text",
outputs="json",
title="AI Content Generator",
description="Enter a prompt to generate content using the CITIBANK DEMO BUSINESS INC CHAT BOT"
)
# Launch the Gradio app
iface.launch()
|