类 ModelCreationContext

java.lang.Object
io.agentscope.core.model.ModelCreationContext

public final class ModelCreationContext extends Object
Provider-neutral model creation context used by ModelRegistry and model provider SPI implementations.

This type has two layers:

  • Standard fields such as apiKey, baseUrl, endpointPath, stream, and enableThinking. These are common enough to be understood by multiple providers and can safely participate in automatic cache identity when CachePolicy.ENABLED is selected.
  • Provider-specific options and typed components. These allow extension modules to consume advanced builder settings such as formatters, HTTP transports, credentials, proxies, and default generation options without adding provider types to core.

Options and components are intentionally opaque to core. ModelRegistry never deep hashes them or uses their hashCode() values for cache identity. When they are present and caching is enabled, callers must provide an explicit ModelCreationContext.Builder.cacheId(String).

  • 方法详细资料

    • empty

      public static ModelCreationContext empty()
    • builder

      public static ModelCreationContext.Builder builder()
    • toBuilder

      public ModelCreationContext.Builder toBuilder()
      Returns a mutable builder initialized from this context.

      This is useful when a caller wants to derive a tenant- or request-specific context from a shared baseline without mutating the original instance.

    • getApiKey

      public String getApiKey()
      API key or token to pass to a provider. Providers may fall back to environment variables.
    • getBaseUrl

      public String getBaseUrl()
      Provider base URL override, for self-hosted or compatible API endpoints.
    • getEndpointPath

      public String getEndpointPath()
      Provider endpoint path override, mainly for OpenAI-compatible APIs.
    • getStream

      public Boolean getStream()
      Whether the created model should use streaming by default. null means provider default.
    • getEnableThinking

      public Boolean getEnableThinking()
      Whether provider thinking/reasoning mode should be enabled.
    • getCachePolicy

      public CachePolicy getCachePolicy()
    • getCacheId

      public String getCacheId()
      Explicit cache identity used when getCachePolicy() is CachePolicy.ENABLED.
    • getOptions

      public Map<String,Object> getOptions()
      Provider-specific scalar or value options keyed by extension-defined names.
    • option

      public Object option(String key)
      Returns a provider-specific option value, or null.
    • option

      public <T> T option(String key, Class<T> type)
      Returns a provider-specific option cast to the requested type, or null.
    • getComponents

      public Map<Class<?>,Object> getComponents()
      Provider-specific component objects keyed by type.
    • component

      public <T> T component(Class<T> type)
      Returns a provider-specific component by type, or null.
    • isEmpty

      public boolean isEmpty()
      Returns whether this context has no effective settings.

      The empty context preserves legacy ModelRegistry.resolve(String) caching behavior.

    • hasOpaqueCacheInputs

      public boolean hasOpaqueCacheInputs()
      Returns whether the context contains values that core cannot fingerprint safely.
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object