
ChatGPT 수업 중 실습에서 오류가 났습니다
import gradio as gr
import openai
openai.api_key = "sk-SMEjfQhaGTtXItEnFxRPUbF3WlY832SLRwJkyXYLZQT3BlbkFJKJeEwoabqpI4jSbs5IREGp8apHZw7cncLkovKzah0A"
def predict(message, history):
histoty_oepnai_format = []
for human, assistant in history:
histoty_oepnai_format.append({"role": "user", "content": human})
histoty_oepnai_fromat.append({"role": "assistant", "content": assistant})
history_openai_format.append({"role": "user", "content": message})
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=history_openai_format,
temperature=0.8,
stream=True
)
print(response)
partial_message = ""
for chunk in response:
if len(chunk['choices'][0]['delta']) != 0:
partial_message += chunk['choices'][0]['delta']['content']
yield partial_message
gr.ChatInterface(
fn=predict,
textbox=gr.Textbox(placeholder="말 걸어 주실래요?", container=False, scale=7)
).queue().launch(share=True, debug=True)
여기까지 작성한 코드 이구요
실행했을 때 나타나는 오류는
NameError: name 'history_openai_format' is not defined
입니다 ㅠㅠ
뭐가 문제인지 모르겠네요....
