AI/ChatGPT
[AI] ChatGPT API 기초 [파인튜닝]
SeungyubLee
2023. 5. 30. 22:50
파인튜닝을 하여 챗봇 만들어보기
1. 챗봇 모양 만들기
import gradio as gr
import random
import time
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
msg = gr.Textbox()
clear = gr.Button("Clear")
def respond(message, chat_history):
bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"]) # 3가지 답변만 랜덤하게 대답하는 챗봇
chat_history.append((message, bot_message))
time.sleep(1)
return "", chat_history
msg.submit(respond, [msg, chatbot], [msg, chatbot])
clear.click(lambda: None, None, chatbot, queue=False)
if __name__ == "__main__":
demo.launch()
2. 파인튜닝할 데이터 준비