MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _extract_user_prompt_text

Function _extract_user_prompt_text

uncommon_route/proxy.py:428–452  ·  view source on GitHub ↗
(value: Any)

Source from the content-addressed store, hash-verified

426
427
428def _extract_user_prompt_text(value: Any) -> str:
429 if isinstance(value, str):
430 current = _extract_current_message(value)
431 if current:
432 return current
433 cleaned = _strip_wrapper_prefix(value)
434 if cleaned:
435 return cleaned
436 return "" if _looks_like_wrapper_text(value) else value.strip()
437 if isinstance(value, list):
438 parts: list[str] = []
439 for item in value:
440 if not isinstance(item, dict) or item.get("type") not in {"text", "input_text"}:
441 continue
442 raw = str(item.get("text", ""))
443 current = _extract_current_message(raw)
444 if current:
445 parts.append(current)
446 continue
447 cleaned = _strip_wrapper_prefix(raw)
448 if cleaned:
449 parts.append(cleaned)
450 if parts:
451 return "\n".join(parts)
452 return _content_text(value).strip()
453
454
455def _extract_prompt(body: dict) -> tuple[str, str | None, int]:

Callers 2

_extract_promptFunction · 0.85

Calls 6

_extract_current_messageFunction · 0.85
_strip_wrapper_prefixFunction · 0.85
_looks_like_wrapper_textFunction · 0.85
_content_textFunction · 0.85
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected