LangChain.FileUploader.FileOpenAI (LangChain v0.8.4)

Copy Markdown View Source

Uploads files to OpenAI's Files API.

Usage

{:ok, uploader} = LangChain.FileUploader.FileOpenAI.new(%{api_key: "sk-..."})

{:ok, result} = LangChain.FileUploader.upload(uploader, file_bytes, %{
  filename: "document.pdf",
  mime_type: "application/pdf"
})

result.file_id
#=> "file-abc123"

The purpose field defaults to "user_data" and can be overridden per-call via the file_meta map or globally via the default_purpose schema field.

Summary

Functions

Setup an OpenAI file uploader configuration.

Setup an OpenAI file uploader configuration and return it or raise an error if invalid.

Types

t()

@type t() :: %LangChain.FileUploader.FileOpenAI{
  api_key: term(),
  default_purpose: term(),
  endpoint: term(),
  receive_timeout: term(),
  req_opts: term()
}

Functions

new(attrs \\ %{})

@spec new(attrs :: map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}

Setup an OpenAI file uploader configuration.

new!(attrs \\ %{})

@spec new!(attrs :: map()) :: t() | no_return()

Setup an OpenAI file uploader configuration and return it or raise an error if invalid.