unchained

Types

pub type Chain {
  Chain(steps: List(ChainStep), memory: Memory)
}

Constructors

  • Chain(steps: List(ChainStep), memory: Memory)
pub type ChainStep {
  LLMStep(llm_config: LLMConfig)
  ToolStep(tool: Tool)
  PromptTemplate(
    template: handles.Template,
    tools: List(TooSelector),
  )
  ChainBreaker(should_stop: fn(String) -> Option(String))
}

Constructors

  • LLMStep(llm_config: LLMConfig)
  • ToolStep(tool: Tool)
  • PromptTemplate(
      template: handles.Template,
      tools: List(TooSelector),
    )
  • ChainBreaker(should_stop: fn(String) -> Option(String))
pub type Error {
  ChainError(String)
  LLMError(String)
  HTTPError(String)
}

Constructors

  • ChainError(String)
  • LLMError(String)
  • HTTPError(String)
pub type HistoryEntry {
  HistoryEntry(input: String, output: String, timestamp: Time)
}

Constructors

  • HistoryEntry(input: String, output: String, timestamp: Time)
pub type LLMConfig {
  LLMConfig(host: String, model: String, temperature: Float)
}

Constructors

  • LLMConfig(host: String, model: String, temperature: Float)
pub type LLMResponse {
  Response(response: String)
}

Constructors

  • Response(response: String)
pub type Memory {
  Memory(
    variables: Dict(String, String),
    history: List(HistoryEntry),
  )
}

Constructors

  • Memory(
      variables: Dict(String, String),
      history: List(HistoryEntry),
    )
pub type TooSelector {
  ToolSelector(select: fn(String) -> Option(String), tool: Tool)
}

Constructors

  • ToolSelector(select: fn(String) -> Option(String), tool: Tool)
pub type Tool {
  Tool(
    name: String,
    description: String,
    function: fn(String) -> Result(String, Error),
  )
}

Constructors

  • Tool(
      name: String,
      description: String,
      function: fn(String) -> Result(String, Error),
    )

Functions

pub fn add_llm(chain: Chain, llm_config: LLMConfig) -> Chain
pub fn add_prompt_template(
  chain: Chain,
  template_str: String,
  tools: List(TooSelector),
) -> Result(Chain, TokenizerError)
pub fn add_tool(chain: Chain, tool: Tool) -> Chain
pub fn new() -> Chain
pub fn run(chain: Chain, input: String) -> Result(String, Error)
pub fn run_with(
  chain: Chain,
  input: String,
  llm_engine: fn(String, LLMConfig) -> Result(LLMResponse, Error),
) -> Result(String, Error)
pub fn set_variable(
  chain: Chain,
  key: String,
  value: String,
) -> Chain
Search Document