perf(news): scope first-stage Skill prompts to each task
This commit is contained in:
1 parent
f2ef39e99a
commit
1397a076e1
8 files changed
+131
-30
No files matched your search
@@ -4,30 +4,32 @@ from types import SimpleNamespace as N
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize('stage', ['index', 'research'])
|
||||
@pytest.mark.parametrize('stage', ['index', 'assign', 'research'])
|
||||
@pytest.mark.parametrize('selected', [None, 'low', 'medium', 'high', 'xhigh', 'max'])
|
||||
@pytest.mark.parametrize('inherited', [None, 'medium'])
|
||||
def test_stage_effort_isolated(trading, stage, selected, inherited):
|
||||
from alphapulse.models import AiProvider, SkillNode
|
||||
from alphapulse.news_research.service import model_config
|
||||
from alphapulse.news_research.contracts import task_skill
|
||||
config_stage = "index" if stage == "assign" else stage
|
||||
shared = N(id=1, model='shared', reasoning_effort=inherited, max_tokens=8192, context_window=200000)
|
||||
node = N(id=1, scope='news', kind='skill', enabled=True, parent_id=None, published_version_id=1)
|
||||
version = N(version_no=1, content='Synthetic rules')
|
||||
version = N(version_no=1, content='## 索引规则\nSynthetic index\n## 归属规则\nSynthetic assignment')
|
||||
class Session:
|
||||
async def get(self, model, identifier):
|
||||
if model is AiProvider: return N(**vars(shared))
|
||||
return node if model is SkillNode else version
|
||||
def expunge(self, obj): pass
|
||||
config = {key: {'provider_id': 1, 'model': key+'-model', 'skill_id': 1,
|
||||
'reasoning_effort': selected if key == stage else None} for key in ['index', 'research']}
|
||||
'reasoning_effort': selected if key == config_stage else None} for key in ['index', 'research']}
|
||||
async def check():
|
||||
actual, skill, rules = await model_config(Session(), config, stage)
|
||||
assert actual.model == stage+'-model'
|
||||
assert actual.model == config_stage+'-model'
|
||||
assert actual.reasoning_effort == (selected if selected is not None else inherited)
|
||||
assert rules['model_config']['selected_reasoning_effort'] == selected
|
||||
assert rules['model_config']['reasoning_effort'] == actual.reasoning_effort
|
||||
assert rules['content'] == version.content and skill.endswith(version.content)
|
||||
other = 'research' if stage == 'index' else 'index'
|
||||
assert rules['content'] == version.content and skill.endswith(task_skill(version.content, stage))
|
||||
other = 'research' if config_stage == 'index' else 'index'
|
||||
assert (await model_config(Session(), config, other))[0].reasoning_effort == inherited
|
||||
assert shared.model == 'shared' and shared.reasoning_effort == inherited
|
||||
asyncio.run(check())
|
||||
|
||||
Reference in new issue
Block a user