code.oscarkilo.com/klex-git/api/funcs.go

..
api.go
datasets.go
embed.go
f.go
fake.go
fake_test.go
funcs.go
funcs_test.go
klex.go
messages.go
messages_test.go
pipelines.go
stream.go
worker.go
package api

type NewFuncRequest struct {
  Name string `json:"name"`  // no need to be unique
  JsCode string `json:"js_code,omitempty"`  // LLM2 must be nil
  LLM2 *LLMFunc `json:"llm2,omitempty"`  // JSCode must be ""
}

type NewFuncResponse struct {
  Name string `json:"name"`
  DateCreated string `json:"date_created"`  // RFC8601 with millis
}

type DeleteFuncRequest struct {
  Name string `json:"name"`
}

type DeleteFuncResponse struct {
}

type FuncVersion struct {
  // Hash is the globally unique ID of this immutable object.
  Hash string `json:"hash"`

  // Date is the time of creation, according to the server's clock.
  Date string `json:"date"`

  // JS is JavaScript code that implements this function.
  JS string `json:"js,omitempty"`

  // LLM is the old "provider:model" string. Deprecated.
  LLM string `json:"llm,omitempty"`

  // LLM2 confugures where an how the LLM is run.
  LLM2 *LLMFunc `json:"llm2,omitempty"`
}

type LLMFunc struct {
  // Provider is "openai", "anthropic", "fireworks", etc.
  Provider string `json:"provider"`

  // Model is the provider-assigned name of the LLM.
  Model string `json:"model"`

  // CanSeeImages is true iff the model accepts image attachments
  // (PNG/JPEG/GIF/WEBP). Production func versions already use
  // this flag — do not rename.
  CanSeeImages bool `json:"can_see_images"`

  // CanSeePDFs is true iff the model accepts PDF attachments.
  // Independent from CanSeeImages because some providers (e.g.
  // Fireworks, Ollama) support images but not PDFs. Defaults to
  // false; stored func versions without the key get false on
  // unmarshal.
  CanSeePDFs bool `json:"can_see_pdfs"`

  CanHaveSystemPromps bool `json:"can_have_system_prompts"`
  CanUseTools bool `json:"can_use_tools"`
  CanStream bool `json:"can_stream"`
}

type Func struct {
  Name string `json:"name"`
  Versions []FuncVersion `json:"versions"`
}

type ListFuncsResponse struct {
  Funcs []Func `json:"funcs"`
}