gopenai/chat

Types

pub type ChatError {
  DynamicError(dynamic.Dynamic)
  JsonDecodeError(json.DecodeError)
}

Constructors

  • DynamicError(dynamic.Dynamic)
  • JsonDecodeError(json.DecodeError)
pub type Choice {
  Choice(
    finish_reason: FinishReason,
    index: Int,
    message: ModelMessage,
  )
}

Constructors

  • Choice(
      finish_reason: FinishReason,
      index: Int,
      message: ModelMessage,
    )
pub type CompletionResponse {
  CompletionResponse(
    id: String,
    choices: List(Choice),
    created: Int,
    model: String,
    system_fingerprint: String,
    object: String,
    usage: Usage,
  )
}

Constructors

  • CompletionResponse(
      id: String,
      choices: List(Choice),
      created: Int,
      model: String,
      system_fingerprint: String,
      object: String,
      usage: Usage,
    )
pub type FinishReason {
  Stop
  Length
  ContentFilter
  ToolCalls
  FunctionCall
}

Constructors

  • Stop
  • Length
  • ContentFilter
  • ToolCalls
  • FunctionCall
pub type Message {
  Message(role: Role, content: String)
}

Constructors

  • Message(role: Role, content: String)
pub type ModelMessage {
  ModelMessage(
    role: Role,
    content: Option(String),
    tool_calls: Option(List(tool.ToolCall)),
  )
}

Constructors

  • ModelMessage(
      role: Role,
      content: Option(String),
      tool_calls: Option(List(tool.ToolCall)),
    )
pub type Request {
  Request(
    model: Model,
    messages: List(Message),
    temperature: Float,
    tools: Option(List(tool.Tool)),
  )
}

Constructors

  • Request(
      model: Model,
      messages: List(Message),
      temperature: Float,
      tools: Option(List(tool.Tool)),
    )
pub type Role {
  System
  Assistant
  User
  Function
}

Constructors

  • System
  • Assistant
  • User
  • Function
pub type Usage {
  Usage(
    completion_tokens: Int,
    prompt_tokens: Int,
    total_tokens: Int,
  )
}

Constructors

  • Usage(
      completion_tokens: Int,
      prompt_tokens: Int,
      total_tokens: Int,
    )

Functions

pub fn completion(
  client: Client,
  req: Request,
) -> Result(CompletionResponse, ChatError)
pub fn completion_from_json(
  data: String,
) -> Result(CompletionResponse, DecodeError)
pub fn request_to_json(req: Request) -> String
Search Document