timsmykov commited on
Commit
adc610d
·
verified ·
1 Parent(s): 401e74a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -15
app.py CHANGED
@@ -25,14 +25,30 @@ def DuckDuckGoSearchTool(query: str) -> str:
25
 
26
  final_answer = FinalAnswerTool()
27
 
28
- model = HfApiModel(
29
- max_tokens=10000,
30
- temperature=1,
31
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
32
- custom_role_conversions=None,
33
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- # Import tool from Hub
36
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
37
 
38
  # Загрузка prompt_templates из prompts.yaml
@@ -46,14 +62,7 @@ with open("prompts.yaml", 'r') as stream:
46
  if isinstance(prompt_templates, dict) and 'system_prompt' in prompt_templates:
47
  # Если все ок, используем загруженный шаблон
48
  system_prompt = prompt_templates['system_prompt']
49
- else:
50
- # Иначе, создаем новый словарь с system_prompt
51
- system_prompt = """
52
- Ты — Perplexity: профессиональный поисковый ассистент.
53
- Твоя задача — предоставлять исчерпывающие и точные ответы на запросы пользователей, основываясь на информации из нескольких источников в интернете.
54
- #... (остальной текст вашего промпта)...
55
- Начни!
56
- """
57
  prompt_templates = {'system_prompt': system_prompt}
58
 
59
  agent = CodeAgent(
 
25
 
26
  final_answer = FinalAnswerTool()
27
 
28
+ # Define both model IDs
29
+ primary_model_id = 'Qwen/Qwen2.5-Coder-32B-Instruct'
30
+ fallback_model_id = 'https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
31
+
32
+ # Try to initialize the primary model
33
+ try:
34
+ model = HfApiModel(
35
+ max_tokens=2096,
36
+ temperature=0.5,
37
+ model_id=primary_model_id,
38
+ custom_role_conversions=None,
39
+ )
40
+ print(f"Using primary model: {primary_model_id}")
41
+ except Exception as e:
42
+ print(f"Error initializing primary model: {e}")
43
+ print(f"Falling back to secondary model: {fallback_model_id}")
44
+ # If the primary model fails, use the fallback model
45
+ model = HfApiModel(
46
+ max_tokens=2096,
47
+ temperature=0.5,
48
+ model_id=fallback_model_id,
49
+ custom_role_conversions=None,
50
+ )
51
 
 
52
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
53
 
54
  # Загрузка prompt_templates из prompts.yaml
 
62
  if isinstance(prompt_templates, dict) and 'system_prompt' in prompt_templates:
63
  # Если все ок, используем загруженный шаблон
64
  system_prompt = prompt_templates['system_prompt']
65
+
 
 
 
 
 
 
 
66
  prompt_templates = {'system_prompt': system_prompt}
67
 
68
  agent = CodeAgent(