File size: 598 Bytes
0fc01f9
46e677e
0fc01f9
a45d4d2
5cb0881
0fc01f9
a45d4d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from transformers import pipeline

# モデルの読み込み
generator = pipeline("text-generation", model="keita-origin/Da-1.1b")

# チャット履歴を保持する関数
def chatbot(message, history):
    history.append((message, ""))
    response = generator(message, max_length=100)[0]["generated_text"]
    history[-1] = (message, response)
    return history

# ChatGPT 風のインターフェース
chatbot_ui = gr.ChatInterface(
    chatbot,
    title="AI Chatbot",
    description="Hugging Face のモデルを使った対話型 AI",
)

# 実行
chatbot_ui.launch()