CMDCRAGArcana.Config (cmdc_rag_arcana v0.2.0)

Copy Markdown View Source

cmdc_rag_arcana 运行配置。

配置来源按优先级合并:

  1. Tool 调用参数
  2. ctx.user_data[:cmdc_rag_arcana]ctx.user_data[:rag]
  3. config :cmdc_rag_arcana, :default, ...

企业集成推荐把 repollm、租户身份与 collection 策略放在 user_data 中,这样 SubAgent 自动继承同一业务上下文。

Summary

Functions

返回当前用户/租户身份 map,供 Plugin 审计使用。

校验当前配置是否允许访问所有 collection。

从 CMDC Context 与 tool args 合并配置。

构建配置,非法选项抛出 NimbleOptions.ValidationError

返回传给 Arcana backend 的 keyword opts。

Types

mode()

@type mode() :: :vector | :keyword | :hybrid

t()

@type t() :: %CMDCRAGArcana.Config{
  allowed_collections: [String.t()],
  backend: module(),
  collection_policies: [CMDCRAGArcana.CollectionPolicy.t()],
  collections: [String.t()],
  default_allow?: boolean(),
  department: String.t() | nil,
  extra_arcana_opts: keyword(),
  filters: map(),
  llm: term(),
  maintenance_backend: module(),
  maintenance_opts: keyword(),
  mode: mode(),
  repo: module() | nil,
  require_citations?: boolean(),
  roles: [String.t()],
  source_id: String.t() | nil,
  status_backend: module(),
  status_opts: keyword(),
  tenant_id: String.t() | nil,
  threshold: float(),
  top_k: pos_integer(),
  user_id: String.t() | nil
}

Functions

actor(config)

@spec actor(t()) :: map()

返回当前用户/租户身份 map,供 Plugin 审计使用。

authorize(config)

@spec authorize(t()) :: :ok | {:error, {:unauthorized_collections, [String.t()]}}

校验当前配置是否允许访问所有 collection。

from_context(ctx, args \\ %{})

@spec from_context(CMDC.Context.t(), map()) :: t()

从 CMDC Context 与 tool args 合并配置。

new!(config)

@spec new!(keyword() | map() | t()) :: t()

构建配置,非法选项抛出 NimbleOptions.ValidationError

to_backend_opts(config)

@spec to_backend_opts(t()) :: keyword()

返回传给 Arcana backend 的 keyword opts。