Spaces:
Sleeping
Sleeping
zasharepw77
commited on
Commit
·
63f4142
1
Parent(s):
af04004
На русском не отработал корректно, запустил на английском тест 10
Browse files- _003_rus_app.py → _004_app.py +9 -18
- app.py +18 -9
_003_rus_app.py → _004_app.py
RENAMED
|
@@ -6,32 +6,24 @@ from smolagents import CodeAgent, DuckDuckGoSearchTool, FinalAnswerTool, HfApiMo
|
|
| 6 |
from huggingface_hub import login
|
| 7 |
import os
|
| 8 |
import openai
|
| 9 |
-
#import litellm
|
| 10 |
-
#litellm._turn_on_debug()
|
| 11 |
-
|
| 12 |
-
# Создание модели
|
| 13 |
-
#model_id = "Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 14 |
-
#hf_token = os.getenv('hf_token')
|
| 15 |
-
#model = HfApiModel(model_id, token=hf_token)
|
| 16 |
|
| 17 |
os.environ['SAMBANOVA_API_KEY'] = os.getenv('sambanova_token')
|
| 18 |
model = LiteLLMModel(
|
| 19 |
-
model_id="sambanova/
|
| 20 |
max_tokens=2096,
|
| 21 |
temperature=0.1,
|
| 22 |
-
# api_base="https://api.sambanova.ai/v1",
|
| 23 |
num_ctx=8192
|
| 24 |
)
|
| 25 |
|
| 26 |
-
#
|
| 27 |
class WebpageVisitorTool(Tool):
|
| 28 |
name = "webpage_visitor"
|
| 29 |
-
description = "
|
| 30 |
|
| 31 |
inputs = {
|
| 32 |
"url": {
|
| 33 |
"type": "string",
|
| 34 |
-
"description": "URL
|
| 35 |
}
|
| 36 |
}
|
| 37 |
|
|
@@ -56,17 +48,16 @@ class WebpageVisitorTool(Tool):
|
|
| 56 |
except Exception as e:
|
| 57 |
return f"An unexpected error occurred: {str(e)}"
|
| 58 |
|
| 59 |
-
#
|
| 60 |
-
#web_agent = ToolCallingAgent(
|
| 61 |
web_agent = CodeAgent(
|
| 62 |
tools=[DuckDuckGoSearchTool(), WebpageVisitorTool()],
|
| 63 |
model=model,
|
| 64 |
max_steps=10,
|
| 65 |
name="web_search_agent",
|
| 66 |
-
description="
|
| 67 |
)
|
| 68 |
|
| 69 |
-
#
|
| 70 |
manager_agent = CodeAgent(
|
| 71 |
tools=[],
|
| 72 |
model=model,
|
|
@@ -74,6 +65,6 @@ manager_agent = CodeAgent(
|
|
| 74 |
additional_authorized_imports=["time", "numpy", "pandas"]
|
| 75 |
)
|
| 76 |
|
| 77 |
-
#
|
| 78 |
-
answer = manager_agent.run("
|
| 79 |
print(answer)
|
|
|
|
| 6 |
from huggingface_hub import login
|
| 7 |
import os
|
| 8 |
import openai
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
os.environ['SAMBANOVA_API_KEY'] = os.getenv('sambanova_token')
|
| 11 |
model = LiteLLMModel(
|
| 12 |
+
model_id="sambanova/Qwen2.5-Coder-32B-Instruct",
|
| 13 |
max_tokens=2096,
|
| 14 |
temperature=0.1,
|
|
|
|
| 15 |
num_ctx=8192
|
| 16 |
)
|
| 17 |
|
| 18 |
+
# Creating a tool for visiting web pages
|
| 19 |
class WebpageVisitorTool(Tool):
|
| 20 |
name = "webpage_visitor"
|
| 21 |
+
description = "This tool visits a web page and returns its content in Markdown format."
|
| 22 |
|
| 23 |
inputs = {
|
| 24 |
"url": {
|
| 25 |
"type": "string",
|
| 26 |
+
"description": "URL of the web page to visit.",
|
| 27 |
}
|
| 28 |
}
|
| 29 |
|
|
|
|
| 48 |
except Exception as e:
|
| 49 |
return f"An unexpected error occurred: {str(e)}"
|
| 50 |
|
| 51 |
+
# Creating a web agent
|
|
|
|
| 52 |
web_agent = CodeAgent(
|
| 53 |
tools=[DuckDuckGoSearchTool(), WebpageVisitorTool()],
|
| 54 |
model=model,
|
| 55 |
max_steps=10,
|
| 56 |
name="web_search_agent",
|
| 57 |
+
description="Performs web search"
|
| 58 |
)
|
| 59 |
|
| 60 |
+
# Creating a manager agent
|
| 61 |
manager_agent = CodeAgent(
|
| 62 |
tools=[],
|
| 63 |
model=model,
|
|
|
|
| 65 |
additional_authorized_imports=["time", "numpy", "pandas"]
|
| 66 |
)
|
| 67 |
|
| 68 |
+
# Running the system
|
| 69 |
+
answer = manager_agent.run("If language model training continues to scale at the current pace until 2030, what will be the electrical power consumption in GW required to power the largest training runs by 2030? What would this correspond to, compared to some countries? Please provide a source for any numbers used.")
|
| 70 |
print(answer)
|
app.py
CHANGED
|
@@ -6,24 +6,32 @@ from smolagents import CodeAgent, DuckDuckGoSearchTool, FinalAnswerTool, HfApiMo
|
|
| 6 |
from huggingface_hub import login
|
| 7 |
import os
|
| 8 |
import openai
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
os.environ['SAMBANOVA_API_KEY'] = os.getenv('sambanova_token')
|
| 11 |
model = LiteLLMModel(
|
| 12 |
-
model_id="sambanova/
|
| 13 |
max_tokens=2096,
|
| 14 |
temperature=0.1,
|
|
|
|
| 15 |
num_ctx=8192
|
| 16 |
)
|
| 17 |
|
| 18 |
-
#
|
| 19 |
class WebpageVisitorTool(Tool):
|
| 20 |
name = "webpage_visitor"
|
| 21 |
-
description = "
|
| 22 |
|
| 23 |
inputs = {
|
| 24 |
"url": {
|
| 25 |
"type": "string",
|
| 26 |
-
"description": "URL
|
| 27 |
}
|
| 28 |
}
|
| 29 |
|
|
@@ -48,16 +56,17 @@ class WebpageVisitorTool(Tool):
|
|
| 48 |
except Exception as e:
|
| 49 |
return f"An unexpected error occurred: {str(e)}"
|
| 50 |
|
| 51 |
-
#
|
|
|
|
| 52 |
web_agent = CodeAgent(
|
| 53 |
tools=[DuckDuckGoSearchTool(), WebpageVisitorTool()],
|
| 54 |
model=model,
|
| 55 |
max_steps=10,
|
| 56 |
name="web_search_agent",
|
| 57 |
-
description="
|
| 58 |
)
|
| 59 |
|
| 60 |
-
#
|
| 61 |
manager_agent = CodeAgent(
|
| 62 |
tools=[],
|
| 63 |
model=model,
|
|
@@ -65,6 +74,6 @@ manager_agent = CodeAgent(
|
|
| 65 |
additional_authorized_imports=["time", "numpy", "pandas"]
|
| 66 |
)
|
| 67 |
|
| 68 |
-
#
|
| 69 |
-
answer = manager_agent.run("
|
| 70 |
print(answer)
|
|
|
|
| 6 |
from huggingface_hub import login
|
| 7 |
import os
|
| 8 |
import openai
|
| 9 |
+
#import litellm
|
| 10 |
+
#litellm._turn_on_debug()
|
| 11 |
+
|
| 12 |
+
# Создание модели
|
| 13 |
+
#model_id = "Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 14 |
+
#hf_token = os.getenv('hf_token')
|
| 15 |
+
#model = HfApiModel(model_id, token=hf_token)
|
| 16 |
|
| 17 |
os.environ['SAMBANOVA_API_KEY'] = os.getenv('sambanova_token')
|
| 18 |
model = LiteLLMModel(
|
| 19 |
+
model_id="sambanova/Meta-Llama-3.1-405B-Instruct",
|
| 20 |
max_tokens=2096,
|
| 21 |
temperature=0.1,
|
| 22 |
+
# api_base="https://api.sambanova.ai/v1",
|
| 23 |
num_ctx=8192
|
| 24 |
)
|
| 25 |
|
| 26 |
+
# Создание инструмента для посещения веб-страниц
|
| 27 |
class WebpageVisitorTool(Tool):
|
| 28 |
name = "webpage_visitor"
|
| 29 |
+
description = "Этот инструмент посещает веб-страницу и возвращает ее содержимое в формате Markdown."
|
| 30 |
|
| 31 |
inputs = {
|
| 32 |
"url": {
|
| 33 |
"type": "string",
|
| 34 |
+
"description": "URL веб-страницы, которую нужно посетить.",
|
| 35 |
}
|
| 36 |
}
|
| 37 |
|
|
|
|
| 56 |
except Exception as e:
|
| 57 |
return f"An unexpected error occurred: {str(e)}"
|
| 58 |
|
| 59 |
+
# Создание веб-агента
|
| 60 |
+
#web_agent = ToolCallingAgent(
|
| 61 |
web_agent = CodeAgent(
|
| 62 |
tools=[DuckDuckGoSearchTool(), WebpageVisitorTool()],
|
| 63 |
model=model,
|
| 64 |
max_steps=10,
|
| 65 |
name="web_search_agent",
|
| 66 |
+
description="Выполняет поиск в интернете"
|
| 67 |
)
|
| 68 |
|
| 69 |
+
# Создание менеджера-агента
|
| 70 |
manager_agent = CodeAgent(
|
| 71 |
tools=[],
|
| 72 |
model=model,
|
|
|
|
| 74 |
additional_authorized_imports=["time", "numpy", "pandas"]
|
| 75 |
)
|
| 76 |
|
| 77 |
+
# Запуск системы
|
| 78 |
+
answer = manager_agent.run("Если обучение моделей языка продолжит масштабироваться с текущим темпом до 2030 года, какова будет потребляемая электрическая мощность в ГВт, необходимая для питания крупнейших тренировочных запусков к 2030 году? Что это будет соответствовать, по сравнению с некоторыми странами? Пожалуйста, предоставьте источник для любых использованных чисел.")
|
| 79 |
print(answer)
|