Spaces:
Sleeping
Sleeping
Auto commit at 07-2025-08 1:24:19
Browse files
app.py
CHANGED
|
@@ -10,6 +10,11 @@ from PIL import Image
|
|
| 10 |
import io
|
| 11 |
import base64
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# .env ํ์ผ์์ ํ๊ฒฝ ๋ณ์ ๋ก๋
|
| 14 |
try:
|
| 15 |
from dotenv import load_dotenv
|
|
@@ -182,6 +187,26 @@ def chat_with_model(message, history, file=None):
|
|
| 182 |
print(f"๐ DEBUG: ์ ์ฒด ๋ฉ์์ง: {full_message[:200]}...")
|
| 183 |
|
| 184 |
print("๐ค DEBUG: ํ ํฌ๋์ด์ ์ฒ๋ฆฌ ์์")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
inputs = tokenizer(full_message, return_tensors="pt")
|
| 186 |
print(f" ์
๋ ฅ shape: {inputs['input_ids'].shape}")
|
| 187 |
print(f" attention_mask shape: {inputs['attention_mask'].shape}")
|
|
@@ -342,6 +367,26 @@ def solve_math_problem(problem, file=None):
|
|
| 342 |
print(f"๐ DEBUG: ์ ์ฒด ํ๋กฌํํธ: {full_prompt[:200]}...")
|
| 343 |
|
| 344 |
print("๐ค DEBUG: ํ ํฌ๋์ด์ ์ฒ๋ฆฌ ์์")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
inputs = tokenizer(full_prompt, return_tensors="pt")
|
| 346 |
print(f" ์
๋ ฅ shape: {inputs['input_ids'].shape}")
|
| 347 |
print(f" attention_mask shape: {inputs['attention_mask'].shape}")
|
|
|
|
| 10 |
import io
|
| 11 |
import base64
|
| 12 |
|
| 13 |
+
# ์ ์ญ ๋ณ์๋ก ์ ์ธ
|
| 14 |
+
tokenizer = None
|
| 15 |
+
model = None
|
| 16 |
+
MODEL_LOADED = False
|
| 17 |
+
|
| 18 |
# .env ํ์ผ์์ ํ๊ฒฝ ๋ณ์ ๋ก๋
|
| 19 |
try:
|
| 20 |
from dotenv import load_dotenv
|
|
|
|
| 187 |
print(f"๐ DEBUG: ์ ์ฒด ๋ฉ์์ง: {full_message[:200]}...")
|
| 188 |
|
| 189 |
print("๐ค DEBUG: ํ ํฌ๋์ด์ ์ฒ๋ฆฌ ์์")
|
| 190 |
+
print(f" tokenizer ํ์
: {type(tokenizer)}")
|
| 191 |
+
print(f" tokenizer ๊ฐ: {tokenizer}")
|
| 192 |
+
|
| 193 |
+
# tokenizer๊ฐ ์ฌ๋ฐ๋ฅธ์ง ํ์ธ
|
| 194 |
+
if not hasattr(tokenizer, 'encode'):
|
| 195 |
+
print("โ DEBUG: tokenizer๊ฐ ์ฌ๋ฐ๋ฅด์ง ์์")
|
| 196 |
+
# tokenizer๋ฅผ ๋ค์ ๋ก๋
|
| 197 |
+
print("๐ DEBUG: tokenizer ์ฌ๋ก๋ ์๋")
|
| 198 |
+
try:
|
| 199 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 200 |
+
MODEL_NAME,
|
| 201 |
+
token=HF_TOKEN,
|
| 202 |
+
trust_remote_code=True,
|
| 203 |
+
use_fast=False
|
| 204 |
+
)
|
| 205 |
+
print("โ
DEBUG: tokenizer ์ฌ๋ก๋ ์ฑ๊ณต")
|
| 206 |
+
except Exception as reload_error:
|
| 207 |
+
print(f"โ DEBUG: tokenizer ์ฌ๋ก๋ ์คํจ: {reload_error}")
|
| 208 |
+
return f"ํ ํฌ๋์ด์ ์ค๋ฅ: {str(reload_error)}"
|
| 209 |
+
|
| 210 |
inputs = tokenizer(full_message, return_tensors="pt")
|
| 211 |
print(f" ์
๋ ฅ shape: {inputs['input_ids'].shape}")
|
| 212 |
print(f" attention_mask shape: {inputs['attention_mask'].shape}")
|
|
|
|
| 367 |
print(f"๐ DEBUG: ์ ์ฒด ํ๋กฌํํธ: {full_prompt[:200]}...")
|
| 368 |
|
| 369 |
print("๐ค DEBUG: ํ ํฌ๋์ด์ ์ฒ๋ฆฌ ์์")
|
| 370 |
+
print(f" tokenizer ํ์
: {type(tokenizer)}")
|
| 371 |
+
print(f" tokenizer ๊ฐ: {tokenizer}")
|
| 372 |
+
|
| 373 |
+
# tokenizer๊ฐ ์ฌ๋ฐ๋ฅธ์ง ํ์ธ
|
| 374 |
+
if not hasattr(tokenizer, 'encode'):
|
| 375 |
+
print("โ DEBUG: tokenizer๊ฐ ์ฌ๋ฐ๋ฅด์ง ์์")
|
| 376 |
+
# tokenizer๋ฅผ ๋ค์ ๋ก๋
|
| 377 |
+
print("๐ DEBUG: tokenizer ์ฌ๋ก๋ ์๋")
|
| 378 |
+
try:
|
| 379 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 380 |
+
MODEL_NAME,
|
| 381 |
+
token=HF_TOKEN,
|
| 382 |
+
trust_remote_code=True,
|
| 383 |
+
use_fast=False
|
| 384 |
+
)
|
| 385 |
+
print("โ
DEBUG: tokenizer ์ฌ๋ก๋ ์ฑ๊ณต")
|
| 386 |
+
except Exception as reload_error:
|
| 387 |
+
print(f"โ DEBUG: tokenizer ์ฌ๋ก๋ ์คํจ: {reload_error}")
|
| 388 |
+
return f"ํ ํฌ๋์ด์ ์ค๋ฅ: {str(reload_error)}"
|
| 389 |
+
|
| 390 |
inputs = tokenizer(full_prompt, return_tensors="pt")
|
| 391 |
print(f" ์
๋ ฅ shape: {inputs['input_ids'].shape}")
|
| 392 |
print(f" attention_mask shape: {inputs['attention_mask'].shape}")
|