MCPcopy
hub / github.com/langroid/langroid / model_copy

Method model_copy

langroid/language_models/openai_gpt.py:326–338  ·  view source on GitHub ↗

Copy config while preserving nested model instances and subclasses. Important: Avoid reconstructing via `model_dump` as that coerces nested models to their annotated base types (dropping subclass-only fields). Instead, defer to Pydantic's native `model_copy`, which

(
        self, *, update: Mapping[str, Any] | None = None, deep: bool = False
    )

Source from the content-addressed store, hash-verified

324 model_config = SettingsConfigDict(env_prefix="OPENAI_")
325
326 def model_copy(
327 self, *, update: Mapping[str, Any] | None = None, deep: bool = False
328 ) -> "OpenAIGPTConfig":
329 """
330 Copy config while preserving nested model instances and subclasses.
331
332 Important: Avoid reconstructing via `model_dump` as that coerces nested
333 models to their annotated base types (dropping subclass-only fields).
334 Instead, defer to Pydantic's native `model_copy`, which keeps nested
335 `BaseModel` instances (and their concrete subclasses) intact.
336 """
337 # Delegate to BaseSettings/BaseModel implementation to preserve types
338 return super().model_copy(update=update, deep=deep) # type: ignore[return-value]
339
340 def _validate_litellm(self) -> None:
341 """

Callers 15

__init__Method · 0.80
cloneMethod · 0.80
split_simpleMethod · 0.80
split_chunk_tokensMethod · 0.80
cloneMethod · 0.80
set_output_formatMethod · 0.80
ingest_doc_pathsMethod · 0.80
ingest_docsMethod · 0.80
enrich_chunksMethod · 0.80

Calls

no outgoing calls