Spaces:
Runtime error
Runtime error
File size: 924 Bytes
eae9a22 45e82dd eae9a22 d7ac493 45e82dd eae9a22 45e82dd d7ac493 45e82dd d7ac493 45e82dd |
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 |
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() |