Роутер работает нормально в process v2

This commit is contained in:
2026-04-07 14:09:51 +03:00
parent 5d77ab1a88
commit 6b74d410cd
1748 changed files with 216679 additions and 14208 deletions
+34 -7
View File
@@ -1,11 +1,12 @@
from __future__ import annotations
from app.modules.agent.intent_router_v2 import IntentRouterV2
from app.modules.agent.llm.prompt_loader import PromptLoader
from app.modules.agent.runtime.docs_qa_pipeline import DocsQAPipelineRunner
from app.modules.agent.runtime.docs_qa_pipeline.openapi_postprocessor import OpenAPIPostprocessor
from app.modules.agent.runtime.docs_qa_pipeline.prompt_payload_builder import DocsPromptPayloadBuilder
from app.modules.agent.runtime.steps.generation import RuntimePromptSelector
from app.core.agent.intent_router import IntentRouterV2
from app.core.agent.llm.prompt_loader import PromptLoader
from app.core.agent.runtime.docs_qa_pipeline import DocsQAPipelineRunner
from app.core.agent.runtime.docs_qa_pipeline.openapi_postprocessor import OpenAPIPostprocessor
from app.core.agent.runtime.docs_qa_pipeline.prompt_payload_builder import DocsPromptPayloadBuilder
from app.core.agent.orchestration.processes.v2.prompt_payload_builder import V2PromptPayloadBuilder
from app.core.agent.runtime.steps.generation import RuntimePromptSelector
from tests.docs_qa_eval.fixture_adapter import InMemoryDocsRetrievalAdapter
from tests.unit_tests.rag.intent_router_testkit import repo_context
@@ -43,7 +44,7 @@ def test_prompt_selector_uses_docs_prompts_only() -> None:
def test_docs_prompt_payload_contains_required_contract() -> None:
builder = DocsPromptPayloadBuilder()
from app.modules.agent.runtime.docs_qa_pipeline.models import DocsEvidenceBundle, OpenAPIResult
from app.core.agent.runtime.docs_qa_pipeline.models import DocsEvidenceBundle, OpenAPIResult
payload = builder.build(
question="Объясни billing",
@@ -52,6 +53,8 @@ def test_docs_prompt_payload_contains_required_contract() -> None:
evidence_bundle=DocsEvidenceBundle(
intent="DOCUMENTATION_EXPLAIN",
sub_intent="COMPONENT_EXPLAIN",
primary_documents=[{"title": "Billing"}],
secondary_documents=[{"title": "Billing relation"}],
documents=[{"title": "Billing"}],
facts=[{"content": "Handles payments"}],
relations=[{"title": "Billing -> Orders"}],
@@ -62,12 +65,36 @@ def test_docs_prompt_payload_contains_required_contract() -> None:
assert '"question": "Объясни billing"' in payload
assert '"intent": "DOCUMENTATION_EXPLAIN"' in payload
assert '"sub_intent": "COMPONENT_EXPLAIN"' in payload
assert '"primary_documents"' in payload
assert '"secondary_documents"' in payload
assert '"documents"' in payload
assert '"facts"' in payload
assert '"relations"' in payload
assert '"api_contract"' in payload
def test_v2_prompt_payload_accepts_api_method_mode_fields() -> None:
from app.core.agent.runtime.docs_qa_pipeline.models import DocsEvidenceBundle
payload = V2PromptPayloadBuilder().build(
question="Как работает метод health?",
intent="DOCUMENTATION_EXPLAIN",
sub_intent="API_METHOD_EXPLAIN",
evidence_bundle=DocsEvidenceBundle(intent="DOCUMENTATION_EXPLAIN", sub_intent="API_METHOD_EXPLAIN"),
api_method_answer_mode="indirect",
target_endpoint_identity={
"anchor": "health",
"normalized_path": "/health",
"normalized_doc_id": "api.health_endpoint",
},
direct_api_spec_found=False,
)
assert '"api_method_answer_mode": "indirect"' in payload
assert '"normalized_doc_id": "api.health_endpoint"' in payload
assert '"direct_api_spec_found": false' in payload
def test_openapi_postprocessor_requires_paths_for_full_spec() -> None:
validator = OpenAPIPostprocessor()