Spaces:
Sleeping
Sleeping
import gradio as gr | |
import requests | |
import os | |
import json | |
import boto3 | |
import uuid | |
def send_story(vacation_spot, story): | |
guid = str(uuid.uuid4()) | |
s3_client = boto3.client( | |
's3', | |
region_name='us-east-1', | |
aws_access_key_id=os.environ['AWS_ACCESS_KEY'], | |
aws_secret_access_key=os.environ['AWS_SECRET_KEY'] | |
) | |
# content = "String content to write to a new S3 file" | |
# story = f"This is a vaction story about {vacation_spot}\n" + story | |
story = f"This is about {vacation_spot}\n" + story | |
data = {"content":story, "vacation_spot":vacation_spot} | |
bucket = 'david-radford-story-telling-bot' | |
object_key = f'raw_input/{guid}.json' | |
s3_client.put_object(Bucket=bucket, Key=object_key, Body=json.dumps(data)) | |
return 'thanks for the review' | |
# Create a dropdown menu | |
dropdown = gr.Dropdown(choices=['Pirate ship in Neverland', 'Mermaid Lagoon in Neverland', 'Skull Rock in Neverland','The Shire','Hogwarts','Jurassic Park'], label="Select Destination") | |
# Create a text box | |
text_box = gr.Textbox(lines=2, placeholder="Describe the place you visited...", label="Vacation Review") | |
iface = gr.Interface( | |
fn=send_story, # the function to call | |
inputs=[dropdown, text_box], # the input components | |
outputs="text", # the type of output | |
title="Vacation Reviews To Magical Places", # Title of the web page | |
description="Select a destination, write a review, and then press Submit." # Description on the web page | |
) | |
# Launch the application | |
iface.launch() | |
# send_story("tell me a story about woodworking") | |
# demo = gr.Interface( | |
# fn=send_story, | |
# inputs=gr.Textbox(lines=2, placeholder="Tell me a story...."), | |
# outputs="text", | |
# ) | |
# demo.launch() | |