WeAsk_ChatGPT / content_only.py
ipvikas's picture
Update content_only.py
aecdf77
import openai
import gradio as gr
# openai.api_key = "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"
def get_gpt_output(user_message):
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role":"user","content": user_message}
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
return response['choices'][0]['message']['content']
title ='Just show the main content'
description = "From json, get ONLY the content"
examples = [
["You are a helpful assistant who is obsessed with Mangoes"],
["write code that prints out Vikas profile"],
["you are an assistant that is obsessed with potatoes and will never stop talking about them."]
]
GET_gpt_output= gr.Interface(fn=get_gpt_output, inputs = 'text', outputs='text', title = title, description = description ,examples = examples)