Spaces:
Runtime error
Runtime error
Update app.py
Browse files50 unmodified lines515253545556575859606162636465666768697071727350 unmodified linesopenai.api_key = api_keydef generate_statement(api_key, use_gpt):try:# Set the OpenAI API key using the provided inputset_openai_key(api_key)if use_gpt:# Generate a statement using OpenAI's GPT 3.5 Turbo modelresponse = openai.Completion.create(engine="gpt-3.5-turbo",prompt="Provide a short and intriguing dialogue that can be incorporated into an improvisation scene to provoke unexpected reactions and drive the narrative in interesting directions.",max_tokens=15)return response.choices[0].text.strip()else:# Return a random dialogue from the provided listreturn random.choice(DIALOGUES)except Exception as e:return str(e)def main():# Define the UI components using gr.Interface50 unmodified lines5152535455565758596061626364656667686970717250 unmodified linesopenai.api_key = api_keydef generate_statement(api_key, use_gpt):# Set the OpenAI API keyset_openai_key(api_key)if use_gpt:# Generate a statement using OpenAI's davinci modelresponse = openai.Completion.create(engine="davinci",prompt="Provide a short and intriguing dialogue that can be incorporated into an improvisation scene to provoke unexpected reactions and drive the narrative in interesting directions.",max_tokens=15)return response.choices[0].text.strip()else:# Return a random dialogue from the provided listreturn random.choice(DIALOGUES)def main():# Define the UI components using gr.Interface
app.py+15-16