Spaces:
Runtime error
Runtime error
import gradio as gr | |
from openai import api_request | |
import openai | |
def openai_response(input_string): | |
response = api_request( | |
"engines/chatbot/run", | |
{ | |
"text": input_string, | |
"engine": "chatgpt", | |
"temperature": 0.5, | |
"max_tokens": 100 | |
}, | |
headers={"Authorization": "Bearer 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"} | |
) | |
return response['choices'][0]['text'] | |
# μ¬μ©μ μ λ ₯μ λ°μμ openaiμ μμ² | |
input_text = gr.inputs.Textbox(lines=3, label="λν μ λ ₯") | |
# openaiμ μλ΅μ μΆλ ₯νκΈ° μν μΈν°νμ΄μ€ | |
output_text = gr.outputs.Textbox(label="openAI λλ΅") | |
# openai_response ν¨μμ μ¬μ©μμ μ λ ₯μ μ λ¬ | |
interaction = gr.Interaction(input_text, output_text, openai_response) | |
interaction.launch() |