diff --git a/meshai/backends/openai_backend.py b/meshai/backends/openai_backend.py index 6f3d76f..66f3e51 100644 --- a/meshai/backends/openai_backend.py +++ b/meshai/backends/openai_backend.py @@ -89,12 +89,19 @@ class OpenAIBackend(LLMBackend): full_messages.extend(messages) try: - response = await self._client.chat.completions.create( - model=self.config.model, - messages=full_messages, - max_tokens=max_tokens, - temperature=0.7, - ) + # Build request kwargs + request_kwargs = { + "model": self.config.model, + "messages": full_messages, + "max_tokens": max_tokens, + "temperature": 0.7, + } + + # Enable web search if configured (Open WebUI feature) + if getattr(self.config, 'web_search', False): + request_kwargs["extra_body"] = {"web_search": True} + + response = await self._client.chat.completions.create(**request_kwargs) content = response.choices[0].message.content return content.strip() if content else "" diff --git a/meshai/cli/configurator.py b/meshai/cli/configurator.py index 050d4e8..fcd56b1 100644 --- a/meshai/cli/configurator.py +++ b/meshai/cli/configurator.py @@ -258,6 +258,8 @@ class Configurator: table.add_row("5", "System Prompt", f"[dim]{len(self.config.llm.system_prompt)} chars[/dim]") use_prompt = getattr(self.config.llm, 'use_system_prompt', True) table.add_row("6", "Use System Prompt", self._status_icon(use_prompt)) + web_search = getattr(self.config.llm, 'web_search', False) + table.add_row("7", "Web Search", self._status_icon(web_search)) table.add_row("0", "Back", "") console.print(table) @@ -306,6 +308,10 @@ class Configurator: current = getattr(self.config.llm, 'use_system_prompt', True) self.config.llm.use_system_prompt = not current self.modified = True + elif choice == 7: + current = getattr(self.config.llm, 'web_search', False) + self.config.llm.web_search = not current + self.modified = True def _weather_settings(self) -> None: """Weather settings submenu.""" diff --git a/meshai/config.py b/meshai/config.py index 199d321..e732efc 100644 --- a/meshai/config.py +++ b/meshai/config.py @@ -212,6 +212,7 @@ class LLMConfig: "Be concise but friendly. No markdown formatting." ) use_system_prompt: bool = True # Toggle to disable sending system prompt + web_search: bool = False # Enable web search (Open WebUI feature) # Fallback settings fallback: Optional[LLMBackendConfig] = None