MCPcopy Create free account
hub / github.com/LLMQuant/quant-mind / resolve_magic_input

Function resolve_magic_input

quantmind/magic.py:62–98  ·  view source on GitHub ↗

Parse ``natural_language`` into ``(input_obj, cfg_obj)`` for ``target_flow``. Args: natural_language: User-supplied free-form description of intent. target_flow: The flow function to resolve for. Must accept ``input`` (positional) and ``cfg`` (keyword) parameters.

(
    natural_language: str,
    *,
    target_flow: Callable[..., Awaitable[Any]],
    resolver_model: str = "gpt-4o-mini",
    resolver_instructions: str | None = None,
)

Source from the content-addressed store, hash-verified

60 with the description's content.
61
62Input schema:
63{input_schema}
64
65Cfg schema:
66{cfg_schema}
67"""
68
69
70async def resolve_magic_input(
71 natural_language: str,
72 *,
73 target_flow: Callable[..., Awaitable[Any]],
74 resolver_model: str = "gpt-5.6-luna",
75 resolver_instructions: str | None = None,
76) -> tuple[Any, Any]:
77 """Parse ``natural_language`` into ``(input_obj, cfg_obj)`` for ``target_flow``.
78
79 Args:
80 natural_language: User-supplied free-form description of intent.
81 target_flow: The flow function to resolve for. Must accept
82 ``input`` (positional) and ``cfg`` (keyword) parameters.
83 resolver_model: LLM used by the resolver agent.
84 resolver_instructions: Optional override for the resolver's
85 system prompt template. Receives ``flow_name``,
86 ``input_schema``, and ``cfg_schema`` via ``str.format``.
87
88 Returns:
89 Tuple of ``(input_obj, cfg_obj)`` populated by the resolver.
90 """
91 input_type, cfg_type = _introspect_flow_signature(target_flow)
92 template = resolver_instructions or _RESOLVER_INSTRUCTIONS
93 instructions = template.format(
94 flow_name=target_flow.__name__,
95 input_schema=_pydantic_schema_str(input_type),
96 cfg_schema=_pydantic_schema_str(cfg_type),
97 )
98 resolver: Agent[Any] = Agent(
99 name=f"magic_resolver_{target_flow.__name__}",
100 instructions=instructions,
101 model=resolver_model,

Calls 3

_pydantic_schema_strFunction · 0.85
formatMethod · 0.80