Sakalti commited on
Commit
291dc46
·
verified ·
1 Parent(s): 536a1fa

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from llama_cpp import Llama
2
+ import gradio as gr
3
+
4
+ # モデルを読み込む
5
+ llm = Llama.from_pretrained(
6
+ repo_id="mradermacher/ultiima-78B-i1-GGUF",
7
+ filename="ultiima-78B.i1-IQ3_M.gguf",
8
+ )
9
+
10
+ # モデルからのレスポンスを生成する関数
11
+ def generate_response(prompt):
12
+ response = llm(prompt, max_tokens=150)
13
+ return response['choices'][0]['text'].strip()
14
+
15
+ # Gradio インターフェースを作成
16
+ def chat_with_model(input_text, history=[]):
17
+ history.append(("You", input_text))
18
+ response = generate_response(input_text)
19
+ history.append(("Model", response))
20
+ return history, history
21
+
22
+ # Gradio インターフェースの設定
23
+ iface = gr.Interface(
24
+ fn=chat_with_model,
25
+ inputs=["text", "state"],
26
+ outputs=["chatbot", "state"],
27
+ title="ULTIIMA-78B Chat Interface",
28
+ description="ULTIIMA-78B モデルを使用したチャットインターフェースです。",
29
+ )
30
+
31
+ # インターフェースを起動
32
+ iface.launch()