Files
Athena-Deck/integrations/openwebui-thinking/verify_installed.py
T

29 lines
1.9 KiB
Python

import asyncio,sqlite3,json
from fastapi import FastAPI
from starlette.requests import Request
from open_webui.models.models import Models
from open_webui.utils.filter import get_filter_context,get_filter_functions,process_filter_functions
from open_webui.utils.payload import apply_model_params_to_body_openai
async def main():
c=sqlite3.connect('/app/backend/data/webui.db');uid=c.execute("select id from user where role='admin' limit 1").fetchone()[0]
app=FastAPI()
for ident in ['qwen3-8-27b-medium','qwen3-8-27b-fast','qwen3-8-27b-unzensiert','qwen3-8-27b-large','qwen3-8-27b-ultra','qwen3-8-27b-lukes-devlab','gemma4-31b-32k']:
m=(await Models.get_model_by_id(ident)).model_dump();model={'id':ident,'info':m}
for enabled in [False,True]:
selected=['athena_thinking'] if enabled else []
req=Request({'type':'http','app':app,'headers':[]})
fs=await get_filter_functions(req,model,selected)
if not ident.startswith('qwen'):
assert not any(f.id.startswith('athena_thinking') for f in fs);continue
assert 'athena_thinking_control' in [f.id for f in fs]
for hop in [0,1]:
body={'model':ident,'messages':[{'role':'user','content':'Test'}],'reasoning_effort':'high','chat_template_kwargs':{'preserve_thinking':True}}
body,_=await process_filter_functions(req,get_filter_context(req),fs,'request',body,{'__metadata__':{'filter_ids':selected},'__user__':{'id':uid}})
body=apply_model_params_to_body_openai(dict(m.get('params') or {}),body)
assert body['chat_template_kwargs']['enable_thinking'] is enabled,(ident,enabled,body.get('chat_template_kwargs'))
assert body['chat_template_kwargs']['preserve_thinking'] is True
assert not body.get('reasoning_effort'),(ident,'Contradicting model reasoning effort')
print(ident,'ON' if enabled else 'OFF','initial + tool follow-up verified')
print('Registered filter dispatch and provider payload passed; no generation triggered')
asyncio.run(main())