Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from huggingface_hub import InferenceClient
|
| 3 |
-
# Use a pipeline as a high-level helper
|
| 4 |
from transformers import pipeline
|
| 5 |
|
| 6 |
-
|
| 7 |
-
"""
|
| 8 |
-
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 9 |
-
"""
|
| 10 |
-
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# モデルの読み込み
|
| 5 |
+
generator = pipeline("text-generation", model="keita-origin/Da-1.0b")
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# チャット履歴を保持する関数
|
| 8 |
+
def chatbot(message, history):
|
| 9 |
+
history.append((message, ""))
|
| 10 |
+
response = generator(message, max_length=100)[0]["generated_text"]
|
| 11 |
+
history[-1] = (message, response)
|
| 12 |
+
return history
|
| 13 |
+
|
| 14 |
+
# ChatGPT 風のインターフェース
|
| 15 |
+
chatbot_ui = gr.ChatInterface(
|
| 16 |
+
chatbot,
|
| 17 |
+
title="AI Chatbot",
|
| 18 |
+
description="Hugging Face のモデルを使った対話型 AI",
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
# 実行
|
| 22 |
+
chatbot_ui.launch()
|