MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / wiki_ask

Function wiki_ask

deployments/desktop/shared/agents.py:4685–4781  ·  view source on GitHub ↗
(
    user_id: str,
    question: str,
    limit: int = 8,
    scope: str = "all",
    mentions: Any = None,
    session_id: str = "",
    persist_chat: bool = False,
    response_language: str = "zh",
)

Source from the content-addressed store, hash-verified

4683 return {
4684 "text": text,
4685 "citations": [],
4686 "sources": [],
4687 "elapsed_ms": int((time.time() - started) * 1000),
4688 "response_language": language,
4689 "token_usage": {
4690 "provider": getattr(llm, "name", "unknown"),
4691 "model": getattr(llm, "model", "unknown"),
4692 "prompt_tokens": response.prompt_tokens if response else 0,
4693 "completion_tokens": response.completion_tokens if response else 0,
4694 "llm_error": llm_error,
4695 },
4696 }
4697
4698
4699def _text_chunks(text: str, size: int = 24) -> Iterator[str]:
4700 content = str(text or "")
4701 for index in range(0, len(content), max(1, int(size))):
4702 yield content[index : index + size]
4703
4704
4705def _selection_required_answer(message: str, response_language: str = "zh") -> Dict[str, Any]:
4706 return {
4707 "text": message,
4708 "citations": [],
4709 "sources": [],
4710 "elapsed_ms": 0,
4711 "response_language": _normalize_response_language(response_language),
4712 "token_usage": {},
4713 "streaming": {"provider": False, "transport": "json"},
4714 }
4715
4716
4717def _selection_required_answer_stream(message: str, response_language: str = "zh") -> Iterator[Dict[str, Any]]:
4718 result = _selection_required_answer(message, response_language=response_language)
4719 yield {"event": "meta", "data": {key: value for key, value in result.items() if key != "text"}}
4720 for chunk in _text_chunks(message):
4721 yield {"event": "chunk", "data": {"text": chunk}}
4722 yield {"event": "done", "data": result}
4723
4724
4725def _apply_chat_metadata(
4726 result: Dict[str, Any],
4727 *,
4728 mode: str,
4729 retrieval_required: bool,
4730 routing_reason: str,
4731 mentions: List[Dict[str, Any]],
4732 unresolved_mentions: List[Dict[str, str]],
4733 scope: str,
4734 response_language: str = "zh",
4735) -> Dict[str, Any]:
4736 citations = result.get("citations") or []
4737 result["sources"] = [_citation_source_payload(citation) for citation in citations]
4738 result.update(
4739 {
4740 "mode": mode,
4741 "retrieval_required": retrieval_required,
4742 "routing_reason": routing_reason,

Callers

nothing calls this directly

Calls 12

_wiki_scope_hintFunction · 0.85
_resolve_wiki_mentionsFunction · 0.85
_question_routeFunction · 0.85
_apply_chat_metadataFunction · 0.85
_attach_chat_sessionFunction · 0.85
_direct_answerFunction · 0.85
_chat_pinned_nodesFunction · 0.85
_visible_wiki_node_idsFunction · 0.85

Tested by

no test coverage detected