File size: 417 Bytes
0e2e50c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import openai
import gradio as gr
import json

openai.api_key = "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"

def main(user_messages: list):
    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=user_messages
    )

    reply = response["choices"][0]["message"]["content"]

    return reply

iface = gr.Interface(fn=main, inputs="json", outputs="text")

iface.launch()