파인튜닝을 하여 챗봇 만들어보기
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. 파인튜닝할 데이터 준비
'AI > ChatGPT' 카테고리의 다른 글
[AI] ChatGPT API 기초 [번역기 만들기] (1) | 2023.05.05 |
---|---|
[AI] ChatGPT 기초 (0) | 2023.05.05 |