Spaces:
Runtime error
Runtime error
import gradio as gr | |
import openai | |
def generate_plantuml(api_key, text): | |
openai.api_key = api_key | |
response = openai.ChatCompletion.create( | |
model="gpt-3.5-turbo", | |
messages=[ | |
{ | |
"role": "system", | |
"content": "You are ChatGPT, a large language model trained by OpenAI. Generate PlantUML code for the following use case or code in natural language.", | |
}, | |
{"role": "user", "content": text}, | |
], | |
) | |
return response["messages"][-1]["content"] | |
iface = gr.Interface( | |
fn=generate_plantuml, | |
inputs=[ | |
gr.inputs.Textbox(label="OpenAI API Key"), | |
gr.inputs.Textbox(label="Enter use case or code in natural language") | |
], | |
outputs=gr.outputs.Code(label="Generated PlantUML Code"), | |
title="PlantUML Code Generator", | |
description="Generate PlantUML code using OpenAI's GPT-3.5-Turbo", | |
) | |
iface.launch() |