mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-05-21 15:14:45 +02:00
Add web search toggle for Open WebUI
- Add web_search config option to LLMConfig - Pass web_search: true in extra_body when enabled - Add toggle in configurator LLM submenu (option 7)
This commit is contained in:
parent
0d29ad49c2
commit
e7c44a5f1c
3 changed files with 20 additions and 6 deletions
|
|
@ -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 ""
|
||||
|
|
|
|||
|
|
@ -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."""
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue