Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,12 +11,14 @@ if not hf_token:
|
|
11 |
|
12 |
# ๋ชจ๋ธ ์ ๋ณด ํ์ธ
|
13 |
api = HfApi(token=hf_token)
|
|
|
14 |
try:
|
15 |
-
|
16 |
-
print(f"๋ชจ๋ธ ์ ๋ณด: {model_info}")
|
17 |
except Exception as e:
|
18 |
-
print(f"
|
19 |
# ๋์ฒด ๋ชจ๋ธ์ ์ฌ์ฉํ๊ฑฐ๋ ์ค๋ฅ ์ฒ๋ฆฌ๋ฅผ ์ํํ์ธ์.
|
|
|
|
|
20 |
|
21 |
# InferenceClient ์ด๊ธฐํ
|
22 |
client = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct", token=hf_token)
|
@@ -70,14 +72,17 @@ def respond(
|
|
70 |
temperature=temperature,
|
71 |
top_p=top_p,
|
72 |
):
|
73 |
-
if message is not None
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
79 |
else:
|
80 |
-
print("Received
|
81 |
except Exception as e:
|
82 |
print(f"Error during chat completion: {e}")
|
83 |
yield f"์ฃ์กํฉ๋๋ค. ์๋ต ์์ฑ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}"
|
|
|
11 |
|
12 |
# ๋ชจ๋ธ ์ ๋ณด ํ์ธ
|
13 |
api = HfApi(token=hf_token)
|
14 |
+
|
15 |
try:
|
16 |
+
client = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct", token=hf_token)
|
|
|
17 |
except Exception as e:
|
18 |
+
print(f"Error initializing InferenceClient: {e}")
|
19 |
# ๋์ฒด ๋ชจ๋ธ์ ์ฌ์ฉํ๊ฑฐ๋ ์ค๋ฅ ์ฒ๋ฆฌ๋ฅผ ์ํํ์ธ์.
|
20 |
+
# ์: client = InferenceClient("gpt2", token=hf_token)
|
21 |
+
|
22 |
|
23 |
# InferenceClient ์ด๊ธฐํ
|
24 |
client = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct", token=hf_token)
|
|
|
72 |
temperature=temperature,
|
73 |
top_p=top_p,
|
74 |
):
|
75 |
+
if message is not None:
|
76 |
+
if hasattr(message, 'choices') and len(message.choices) > 0:
|
77 |
+
delta = message.choices[0].delta
|
78 |
+
if hasattr(delta, 'content') and delta.content is not None:
|
79 |
+
token = delta.content.strip("<|END_OF_TURN_TOKEN|>")
|
80 |
+
response += token
|
81 |
+
yield response
|
82 |
+
else:
|
83 |
+
print("Received message without choices:", message)
|
84 |
else:
|
85 |
+
print("Received None message")
|
86 |
except Exception as e:
|
87 |
print(f"Error during chat completion: {e}")
|
88 |
yield f"์ฃ์กํฉ๋๋ค. ์๋ต ์์ฑ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}"
|