import gradio as gr import openai from openai import OpenAI import os def query(prompt): client = client = OpenAI(api_key = os.getenv('OPENAPI_KEY')) # your own key system_prompt = """ You are a helpful text sentiment classifier. Answer ONLY using these three options: ['Positive', 'Negative', 'Neutral'] """ user_prompt = f""" Classify the text into neutral, negative or positive. Text: {prompt} Sentiment: """ message = [{"role": "system", "content": f"{system_prompt}"},{"role": "user", "content": f"{user_prompt}"}] response = client.chat.completions.create( model="gpt-3.5-turbo-1106", messages=message, temperature=0.5 ) return response.choices[0].message.content gr.Interface(fn=query, inputs="textbox", outputs="textbox").launch()