Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,6 @@ from smolagents import CodeAgent, HfApiModel, tool
|
|
| 11 |
|
| 12 |
load_dotenv()
|
| 13 |
|
| 14 |
-
# 🛠️ Инструменты
|
| 15 |
@tool
|
| 16 |
def get_timezone_by_city(city: str) -> str:
|
| 17 |
"""Get timezone for a city.
|
|
@@ -192,14 +191,12 @@ def final_answer(answer: str) -> str:
|
|
| 192 |
"""
|
| 193 |
return answer
|
| 194 |
|
| 195 |
-
# 🤖 Model setup
|
| 196 |
model = HfApiModel(
|
| 197 |
max_tokens=1000,
|
| 198 |
temperature=0.5,
|
| 199 |
model_id="mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 200 |
)
|
| 201 |
|
| 202 |
-
# 📜 System Prompt
|
| 203 |
system_prompt = (
|
| 204 |
"Ты помощник. Используй только функции: "
|
| 205 |
"`get_timezone_by_city`, `get_current_time_in_timezone`, `get_air_quality`, "
|
|
@@ -209,7 +206,6 @@ system_prompt = (
|
|
| 209 |
"❌ Без пояснений, markdown, JSON."
|
| 210 |
)
|
| 211 |
|
| 212 |
-
# 🎯 Prompt templates
|
| 213 |
prompt_templates = {
|
| 214 |
"system_prompt": system_prompt,
|
| 215 |
"default": "Response: {{question}}",
|
|
@@ -238,7 +234,6 @@ agent = CodeAgent(
|
|
| 238 |
verbosity_level=2
|
| 239 |
)
|
| 240 |
|
| 241 |
-
# 💬 Обработка запроса
|
| 242 |
def process_input(user_input):
|
| 243 |
try:
|
| 244 |
lang = detect(user_input)
|
|
@@ -248,7 +243,7 @@ def process_input(user_input):
|
|
| 248 |
except Exception as e:
|
| 249 |
return f"❌ Ошибка: {str(e)}"
|
| 250 |
|
| 251 |
-
|
| 252 |
if __name__ == "__main__":
|
| 253 |
gr.Interface(
|
| 254 |
fn=process_input,
|
|
|
|
| 11 |
|
| 12 |
load_dotenv()
|
| 13 |
|
|
|
|
| 14 |
@tool
|
| 15 |
def get_timezone_by_city(city: str) -> str:
|
| 16 |
"""Get timezone for a city.
|
|
|
|
| 191 |
"""
|
| 192 |
return answer
|
| 193 |
|
|
|
|
| 194 |
model = HfApiModel(
|
| 195 |
max_tokens=1000,
|
| 196 |
temperature=0.5,
|
| 197 |
model_id="mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 198 |
)
|
| 199 |
|
|
|
|
| 200 |
system_prompt = (
|
| 201 |
"Ты помощник. Используй только функции: "
|
| 202 |
"`get_timezone_by_city`, `get_current_time_in_timezone`, `get_air_quality`, "
|
|
|
|
| 206 |
"❌ Без пояснений, markdown, JSON."
|
| 207 |
)
|
| 208 |
|
|
|
|
| 209 |
prompt_templates = {
|
| 210 |
"system_prompt": system_prompt,
|
| 211 |
"default": "Response: {{question}}",
|
|
|
|
| 234 |
verbosity_level=2
|
| 235 |
)
|
| 236 |
|
|
|
|
| 237 |
def process_input(user_input):
|
| 238 |
try:
|
| 239 |
lang = detect(user_input)
|
|
|
|
| 243 |
except Exception as e:
|
| 244 |
return f"❌ Ошибка: {str(e)}"
|
| 245 |
|
| 246 |
+
|
| 247 |
if __name__ == "__main__":
|
| 248 |
gr.Interface(
|
| 249 |
fn=process_input,
|