Skip to content

Commit aa3ad46

Browse files
committed
refactor(llamabot/components/tools.py)♻️: Refactor summarize_web_results to use environment variable for default model name
- Replace hardcoded default model name with environment variable LMB_INTERNET_SUMMARIZER_MODEL_NAME fallback.
1 parent 0d566f9 commit aa3ad46

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

llamabot/components/tools.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@
99
that is attached as an attribute.
1010
"""
1111

12-
from typing import Any, Callable, Dict, Optional, Tuple
13-
from litellm.utils import function_to_dict
14-
from llamabot.bot.simplebot import SimpleBot
15-
from llamabot.components.messages import user
16-
from bs4 import BeautifulSoup
12+
import os
13+
import random
1714
from concurrent.futures import ThreadPoolExecutor, as_completed
1815
from datetime import datetime
16+
from functools import wraps
17+
from typing import Any, Callable, Dict, Optional, Tuple
1918
from uuid import uuid4
19+
2020
import requests
21-
from llamabot.components.sandbox import ScriptExecutor, ScriptMetadata
22-
import random
21+
from bs4 import BeautifulSoup
2322
from duckduckgo_search.exceptions import DuckDuckGoSearchException
24-
from llamabot.prompt_manager import prompt
23+
from litellm.utils import function_to_dict
2524
from loguru import logger
26-
from functools import wraps
25+
26+
from llamabot.bot.simplebot import SimpleBot
27+
from llamabot.components.messages import user
28+
from llamabot.components.sandbox import ScriptExecutor, ScriptMetadata
29+
from llamabot.prompt_manager import prompt
2730

2831

2932
def tool(func: Callable) -> Callable:
@@ -241,7 +244,10 @@ def summarize_web_results(
241244
:param webpage_contents: The content of the webpage
242245
:return: The summarized content
243246
"""
244-
model_name = bot_kwargs.pop("model_name", "gpt-4.1-mini")
247+
default_model_name = os.getenv(
248+
"LMB_INTERNET_SUMMARIZER_MODEL_NAME", "ollama_chat/llama3.1:latest"
249+
)
250+
model_name = bot_kwargs.pop("model_name", default_model_name)
245251
stream_target = bot_kwargs.pop("stream_target", "none")
246252
system_prompt = bot_kwargs.pop("system_prompt", summarization_bot_system_prompt())
247253
bot = SimpleBot(

0 commit comments

Comments
 (0)