MCPcopy Create free account
hub / github.com/cocoindex-io/cocoindex-code / lookup_defaults

Function lookup_defaults

src/cocoindex_code/embedder_defaults.py:105–124  ·  view source on GitHub ↗

Look up recommended (indexing_params, query_params) for *model*. Walks :data:`_DEFAULT_PARAMS` in order; an exact-name entry matches iff ``entry.model == model``; a compiled-regex entry matches via ``entry.model.fullmatch(model)``. First match wins. Returns the pair of dicts (each

(
    provider: str, model: str
)

Source from the content-addressed store, hash-verified

103
104
105def lookup_defaults(
106 provider: str, model: str
107) -> tuple[dict[str, Any] | None, dict[str, Any] | None]:
108 """Look up recommended (indexing_params, query_params) for *model*.
109
110 Walks :data:`_DEFAULT_PARAMS` in order; an exact-name entry matches iff
111 ``entry.model == model``; a compiled-regex entry matches via
112 ``entry.model.fullmatch(model)``. First match wins. Returns the pair of
113 dicts (each possibly empty) or ``(None, None)`` when no entry matches.
114 """
115 for entry in _DEFAULT_PARAMS:
116 if entry.provider != provider:
117 continue
118 if isinstance(entry.model, str):
119 matched = entry.model == model
120 else:
121 matched = entry.model.fullmatch(model) is not None
122 if matched:
123 return dict(entry.indexing_params), dict(entry.query_params)
124 return None, None
125
126
127def _assert_legacy_bridge_invariant() -> None:

Calls

no outgoing calls