Spaces:
Build error
Build error
import openai | |
import gradio as gr | |
openai.api_key = "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" | |
def chatgpt(content, temperature=0.8): | |
response = openai.ChatCompletion.create( | |
model="gpt-3.5-turbo", | |
messages=[ | |
{"role": "user", "content": content} | |
], | |
temperature=temperature, | |
max_tokens=1000, | |
top_p=1, | |
frequency_penalty=0, | |
presence_penalty=0, | |
) | |
# print(response) | |
return response.choices[0].message.content | |
if __name__ == "__main__": | |
def send_chatgpt(text): | |
output = chatgpt(text,0.8) | |
return output | |
interface = gr.Interface(fn=send_chatgpt, | |
inputs=gr.Textbox(lines=2, placeholder="Name Here..."), | |
outputs="text") | |
interface.launch() | |