mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-21 00:21:19 +00:00
refac
This commit is contained in:
parent
e69236bccb
commit
b6cf23f332
3 changed files with 30 additions and 28 deletions
|
|
@ -2808,8 +2808,12 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||
import aiohttp
|
||||
from open_webui.env import AIOHTTP_CLIENT_SESSION_TOOL_SERVER_SSL, AIOHTTP_CLIENT_TIMEOUT_TOOL_SERVER_DATA
|
||||
from open_webui.models.skills import Skills as SkillsModel
|
||||
from open_webui.utils.skills import format_terminal_skill_context, format_terminal_skill_manifest_entry
|
||||
from open_webui.utils.terminals import get_terminal_request_info, get_terminal_skill
|
||||
from open_webui.utils.terminals import (
|
||||
format_terminal_skill_context,
|
||||
format_terminal_skill_manifest_entry,
|
||||
get_terminal_request_info,
|
||||
get_terminal_skill,
|
||||
)
|
||||
|
||||
terminal_skill_prefix = 'terminal:'
|
||||
db_skill_ids = [sid for sid in skill_ids if not sid.startswith(terminal_skill_prefix)]
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
"""Shared helpers for model-facing skill prompts."""
|
||||
|
||||
|
||||
def format_terminal_skill_context(skill: dict) -> str:
|
||||
resources = skill.get('resources') if isinstance(skill.get('resources'), list) else []
|
||||
parts = [f'<skill name="{skill.get("name") or ""}">', skill.get('content') or '']
|
||||
if skill.get('directory'):
|
||||
parts.append(f'<directory>{skill["directory"]}</directory>')
|
||||
if resources:
|
||||
parts.append('<resources>')
|
||||
parts.extend(f'<file>{resource}</file>' for resource in resources)
|
||||
parts.append('</resources>')
|
||||
parts.append('</skill>')
|
||||
return '\n'.join(parts)
|
||||
|
||||
|
||||
def format_terminal_skill_manifest_entry(skill: dict) -> str:
|
||||
location = skill.get('location') or skill.get('path') or ''
|
||||
location_tag = f'<location>{location}</location>\n' if location else ''
|
||||
return (
|
||||
f'<skill>\n<id>{skill["id"]}</id>\n<name>{skill["name"]}</name>\n'
|
||||
f'<description>{skill.get("description") or ""}</description>\n'
|
||||
f'<source>terminal</source>\n'
|
||||
f'{location_tag}'
|
||||
f'</skill>\n'
|
||||
)
|
||||
|
|
@ -206,3 +206,27 @@ async def get_terminal_skill(request, user, metadata: dict, skill_name: str, ext
|
|||
'resources': resources,
|
||||
}
|
||||
|
||||
|
||||
def format_terminal_skill_context(skill: dict) -> str:
|
||||
resources = skill.get('resources') if isinstance(skill.get('resources'), list) else []
|
||||
parts = [f'<skill name="{skill.get("name") or ""}">', skill.get('content') or '']
|
||||
if skill.get('directory'):
|
||||
parts.append(f'<directory>{skill["directory"]}</directory>')
|
||||
if resources:
|
||||
parts.append('<resources>')
|
||||
parts.extend(f'<file>{resource}</file>' for resource in resources)
|
||||
parts.append('</resources>')
|
||||
parts.append('</skill>')
|
||||
return '\n'.join(parts)
|
||||
|
||||
|
||||
def format_terminal_skill_manifest_entry(skill: dict) -> str:
|
||||
location = skill.get('location') or skill.get('path') or ''
|
||||
location_tag = f'<location>{location}</location>\n' if location else ''
|
||||
return (
|
||||
f'<skill>\n<id>{skill["id"]}</id>\n<name>{skill["name"]}</name>\n'
|
||||
f'<description>{skill.get("description") or ""}</description>\n'
|
||||
f'<source>terminal</source>\n'
|
||||
f'{location_tag}'
|
||||
f'</skill>\n'
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue