noppodev commited on
Commit
16fdb26
·
verified ·
1 Parent(s): fb6d22d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -17
app.py CHANGED
@@ -10,24 +10,24 @@ def prepare_model():
10
  token = os.getenv("HF_TOKEN")
11
 
12
  if not os.path.exists(model_path):
13
- print("🚀 NI-v1 マージ開始:Llama 4 Scout x Gemma 4 E2E")
14
  env = os.environ.copy()
15
  if token:
16
  env["HF_TOKEN"] = token
17
 
18
  try:
19
- # mergekitで本物の次世代機をマージ
20
  subprocess.run(
21
  ["mergekit-yaml", "config.yaml", model_path, "--allow-crimes"],
22
  check=True,
23
  env=env
24
  )
25
- print("✨ マージ成功のっぽ、Gemma 4の力、手に入れたぜ。")
26
  except subprocess.CalledProcessError as e:
27
- print(f"❌ マージエラー。モデル名かゲート設定を確認だ:{e}")
28
  raise e
29
 
30
- print("🧠 NI-v1 意識を同期中...")
31
  tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
32
  model = AutoModelForCausalLM.from_pretrained(
33
  model_path,
@@ -45,22 +45,18 @@ except Exception as e:
45
  pipe = None
46
 
47
  def chat_fn(message, history):
48
- if pipe is None: return "知能がまだ眠ってるみたいだ(起動失敗。"
49
-
50
- # Gemma 4 / Scout 向けのプロンプト形式
51
  prompt = f"<|im_start|>user\n{message}<|im_end|>\n<|im_start|>assistant\n"
52
  outputs = pipe(prompt, max_new_tokens=512, do_sample=True, temperature=0.7)
53
- response = outputs[0]['generated_text'].split("assistant\n")[-1].replace("<|im_end|>", "")
54
- return response
55
 
56
- # --- UI (Noppo Style) ---
57
  with gr.Blocks(title="NI-v1.0") as demo:
58
  gr.Markdown("# 🤖 Noppo-Intelligence v1.0")
59
- gr.Markdown("Llama 4 Scout と Gemma 4 E2E の融合。これぞ NoppoStudio の真骨頂。")
60
 
61
  with gr.Tab("チャット"):
62
- chatbot = gr.Chatbot(label="NI-v1 Session")
63
- msg = gr.Textbox(label="問いかけ", placeholder="Gemma 4知能試しみるか?")
64
  with gr.Row():
65
  send = gr.Button("送信", variant="primary")
66
  clear = gr.Button("クリア")
@@ -75,10 +71,9 @@ with gr.Blocks(title="NI-v1.0") as demo:
75
  clear.click(lambda: None, None, chatbot, queue=False)
76
 
77
  with gr.Tab("公開"):
78
- gr.Markdown("### 完成した知能を世界に公開するぜ")
79
  repo_id = gr.Textbox(label="Repo ID", placeholder="noppodev/NoppoIntelligence")
80
  user_token = gr.Textbox(label="Write Token", type="password")
81
- pub_btn = gr.Button("Hugging Faceへアップロード")
82
  status = gr.Textbox(label="Status")
83
 
84
  def upload(r, t):
@@ -86,7 +81,7 @@ with gr.Blocks(title="NI-v1.0") as demo:
86
  api = HfApi()
87
  api.create_repo(repo_id=r, repo_type="model", exist_ok=True)
88
  api.upload_folder(folder_path="./ni_v1_model", repo_id=r, token=t)
89
- return "✅ 成功!のっぽ、やっな!"
90
  except Exception as e: return f"❌ エラー: {e}"
91
 
92
  pub_btn.click(upload, [repo_id, user_token], status)
 
10
  token = os.getenv("HF_TOKEN")
11
 
12
  if not os.path.exists(model_path):
13
+ print("🚀 NI-v1 マージ開始:Llama-4-Maverick-17B-128E-Instruct x gemma-4-E4B-it")
14
  env = os.environ.copy()
15
  if token:
16
  env["HF_TOKEN"] = token
17
 
18
  try:
19
+ # スクショにある正確なモデル名。ミスは許されない。
20
  subprocess.run(
21
  ["mergekit-yaml", "config.yaml", model_path, "--allow-crimes"],
22
  check=True,
23
  env=env
24
  )
25
+ print("✨ マージ成功のっぽ、今度は本物だ。")
26
  except subprocess.CalledProcessError as e:
27
+ print(f"❌ マージエラー。モデル名かゲート設定を確認")
28
  raise e
29
 
30
+ print("🧠 NI-v1 ロード中...")
31
  tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
32
  model = AutoModelForCausalLM.from_pretrained(
33
  model_path,
 
45
  pipe = None
46
 
47
  def chat_fn(message, history):
48
+ if pipe is None: return "知能ユニット起動失敗。ログを見てくれ。"
 
 
49
  prompt = f"<|im_start|>user\n{message}<|im_end|>\n<|im_start|>assistant\n"
50
  outputs = pipe(prompt, max_new_tokens=512, do_sample=True, temperature=0.7)
51
+ return outputs[0]['generated_text'].split("assistant\n")[-1].replace("<|im_end|>", "")
 
52
 
 
53
  with gr.Blocks(title="NI-v1.0") as demo:
54
  gr.Markdown("# 🤖 Noppo-Intelligence v1.0")
55
+ gr.Markdown("Maverick-17B と Gemma-4-E4B 融合した、っぽ指定ののマージAIだ。")
56
 
57
  with gr.Tab("チャット"):
58
+ chatbot = gr.Chatbot()
59
+ msg = gr.Textbox(placeholder="最新モデル見せくれ。")
60
  with gr.Row():
61
  send = gr.Button("送信", variant="primary")
62
  clear = gr.Button("クリア")
 
71
  clear.click(lambda: None, None, chatbot, queue=False)
72
 
73
  with gr.Tab("公開"):
 
74
  repo_id = gr.Textbox(label="Repo ID", placeholder="noppodev/NoppoIntelligence")
75
  user_token = gr.Textbox(label="Write Token", type="password")
76
+ pub_btn = gr.Button("アップロード")
77
  status = gr.Textbox(label="Status")
78
 
79
  def upload(r, t):
 
81
  api = HfApi()
82
  api.create_repo(repo_id=r, repo_type="model", exist_ok=True)
83
  api.upload_folder(folder_path="./ni_v1_model", repo_id=r, token=t)
84
+ return "✅ 完了しぜ。"
85
  except Exception as e: return f"❌ エラー: {e}"
86
 
87
  pub_btn.click(upload, [repo_id, user_token], status)