API Reference

Note

For detailed usage guides, see the REPL Interface, Tools, Configuration, and Ollama Integration pages.

Bilge.BilgeAgentType
BilgeAgent

AI-powered coding copilot agent. Supports both OpenAI-compatible and Ollama backends.

source
Bilge.BilgeAgentMethod
BilgeAgent(config, working_dir)

Create a BilgeAgent with the given configuration and working directory.

source
Bilge.OllamaConfigType
OllamaConfig

Configuration for Ollama API calls.

Supports both the native Ollama API (/api/chat) and the OpenAI-compatible endpoint (/v1/chat/completions).

  • model::String - Model name (e.g., "llama3.1", "qwen2.5", "mistral")
  • host::String - Ollama server address (default: "http://localhost:11434")
  • max_tokens::Int - Maximum tokens in response (default: 32768)
  • temperature::Float64 - Sampling temperature (default: 0.1)
  • use_openai_compat::Bool - Use OpenAI-compatible endpoint (default: false)
source
Bilge.ToolType
Tool

Represents a callable tool that the LLM can invoke.

source
Bilge._extract_tool_calls_from_textMethod
_extract_tool_calls_from_text(content)

Fallback parser: extract tool calls from text content when models embed them in their output instead of using the native tool calling API. Handles common patterns like <toolcall>...</toolcall> and json {"name":...} blocks.

Returns (cleanedcontent, toolcalls) where tool_calls may be nothing.

source
Bilge._glob_to_regexMethod
_glob_to_regex(pattern)

Convert a glob pattern to a Regex. Supports: * (any non-/ chars), ** (any chars including /), ? (single char).

source
Bilge._read_inputMethod
_read_input(state)

Read user input with history navigation and multi-line support. Returns nothing on EOF or Ctrl-C.

source
Bilge._read_line_rawMethod
_read_line_raw(prompt, color, history) -> Union{String, Nothing}

Read a single line from a TTY with arrow key history navigation. Supports: Up/Down (history), Left/Right (cursor), Home/End, Backspace, Delete, Ctrl-A/E/K/U/W/L, and UTF-8 input. Returns nothing on Ctrl-C or Ctrl-D.

source
Bilge._resolve_pathMethod
_resolve_path(state, path)

Resolve a path relative to the working directory. Absolute paths pass through.

source
Bilge.bilgeMethod
bilge(; api_key, model, base_url, ollama, host, use_openai_compat, working_dir)

Start the Bilge interactive coding copilot.

  • api_key::String - OpenAI API key (default: ENV["OPENAIAPIKEY"])
  • model::String - Model name (default: "gpt-4o" or "llama3.1" for Ollama)
  • base_url::String - API base URL (default: "https://api.openai.com/v1")
  • ollama::Bool - Use Ollama backend (default: false)
  • host::String - Ollama host (default: "http://localhost:11434")
  • use_openai_compat::Bool - Use Ollama's OpenAI-compatible endpoint (default: false)
  • working_dir::String - Working directory (default: pwd())
using Bilge

bilge(ollama=true, model="qwen3")

bilge(api_key="sk-...")

bilge(api_key="key", base_url="https://api.example.com/v1", model="my-model")
source
Bilge.call_ollamaMethod
call_ollama(config, messages, tools)

Make an API call to Ollama using the native /api/chat endpoint.

source
Bilge.check_ollama_connectionMethod
check_ollama_connection(; host="http://localhost:11434")

Check if Ollama server is running and accessible.

  • Bool - true if server is reachable
source
Bilge.list_ollama_modelsMethod
list_ollama_models(; host="http://localhost:11434")

List available models on the Ollama server.

  • Vector{String} of model names
source
Bilge.parse_ollama_responseMethod
parse_ollama_response(config, response)

Parse Ollama response into Message and tool calls. Handles both native and OpenAI-compatible formats. Falls back to text parsing if the model embeds tool calls in content.

source
Bilge.process_turnMethod
process_turn(agent, user_input; on_event=nothing) -> TurnResult

Process a single conversation turn. Sends the user message to the LLM, executes any tool calls, and returns the final response.

The optional on_event callback receives status updates:

  • (:thinking,) — LLM is generating a response
  • (:tool_start, name, args) — a tool is about to execute
  • (:tool_done, exec) — a tool finished (ToolExecution)
source