File size: 1,185 Bytes
037d2bb a977d3c 037d2bb a977d3c 037d2bb a977d3c 037d2bb a977d3c | 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 39 40 41 | import openai
import gradio as gr
import os
def get_completion(prompt, api_key, model="text-davinci-002"):
openai.api_key = api_key
response = openai.Completion.create(
engine=model,
prompt=prompt,
temperature=0,
max_tokens=1024,
)
return response.choices[0].text.strip()
def extract_colors(fact_sheet_chair, api_key):
prompt = f"""
List character following content:
1 - List 4 popular props
2 - List 4 popular accessories
3 - List 4 popular clothes
Use the following format:
props:<4 popular props>
accessories:<4 popular accessories>
clothes:<4 popular clothes>
character: {fact_sheet_chair}
"""
response = get_completion(prompt, api_key)
return response
fact_sheet_chair_input = gr.inputs.Textbox(label="character")
api_key_input = gr.inputs.Textbox(label="OpenAI API")
output_text = gr.outputs.Textbox(label="Output")
title = "Character design inspiration"
description = "basis info"
inputs = [fact_sheet_chair_input, api_key_input]
outputs = [output_text]
gr.Interface(fn=extract_colors, inputs=inputs, outputs=outputs, title=title, description=description).launch() |