CoolFace
Apppublic

NehaTahalani/Text_Completion_Bot

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
app.py26 linesDownload Raw Back to root
1import gradio as gr2import openai3 4openai.api_key = open('key.txt', "r").read().strip('\n')5 6def complete_text(prompt):7    response = openai.chat.completions.create(8        model="gpt-3.5-turbo",9        messages=[{"role": "system", "content": prompt}],10        max_tokens=5011    )12    13    completion = response.choices[0].message.content14    return completion15 16iface = gr.Interface(17    fn=complete_text,18    inputs="text",19    outputs="text",20    title="Text Completion with GPT-3.5-Turbo",21    description="Enter some text to complete.",22    analytics_enabled=False23)24 25iface.launch()26