mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-05-21 23:24:44 +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)
|
full_messages.extend(messages)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = await self._client.chat.completions.create(
|
# Build request kwargs
|
||||||
model=self.config.model,
|
request_kwargs = {
|
||||||
messages=full_messages,
|
"model": self.config.model,
|
||||||
max_tokens=max_tokens,
|
"messages": full_messages,
|
||||||
temperature=0.7,
|
"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
|
content = response.choices[0].message.content
|
||||||
return content.strip() if content else ""
|
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]")
|
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)
|
use_prompt = getattr(self.config.llm, 'use_system_prompt', True)
|
||||||
table.add_row("6", "Use System Prompt", self._status_icon(use_prompt))
|
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", "")
|
table.add_row("0", "Back", "")
|
||||||
|
|
||||||
console.print(table)
|
console.print(table)
|
||||||
|
|
@ -306,6 +308,10 @@ class Configurator:
|
||||||
current = getattr(self.config.llm, 'use_system_prompt', True)
|
current = getattr(self.config.llm, 'use_system_prompt', True)
|
||||||
self.config.llm.use_system_prompt = not current
|
self.config.llm.use_system_prompt = not current
|
||||||
self.modified = True
|
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:
|
def _weather_settings(self) -> None:
|
||||||
"""Weather settings submenu."""
|
"""Weather settings submenu."""
|
||||||
|
|
|
||||||
|
|
@ -212,6 +212,7 @@ class LLMConfig:
|
||||||
"Be concise but friendly. No markdown formatting."
|
"Be concise but friendly. No markdown formatting."
|
||||||
)
|
)
|
||||||
use_system_prompt: bool = True # Toggle to disable sending system prompt
|
use_system_prompt: bool = True # Toggle to disable sending system prompt
|
||||||
|
web_search: bool = False # Enable web search (Open WebUI feature)
|
||||||
|
|
||||||
# Fallback settings
|
# Fallback settings
|
||||||
fallback: Optional[LLMBackendConfig] = None
|
fallback: Optional[LLMBackendConfig] = None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue