VibeCluster.Llm.BaseLLMClient behaviour (LlmEx v0.1.0)

View Source

Defines a common behaviour interface for all LLM clients. This module establishes a contract that all LLM client implementations must fulfill.

Summary

Callbacks

Converts a Message struct to the provider-specific format.

Streams a chat response from the LLM to the given process.

Converts a Tool struct to the provider-specific format.

Functions

Helper function to make HTTP requests to LLM providers with proper error handling

Helper function to make streaming HTTP requests to LLM providers with proper error handling

Callbacks

message_to_provider_format(struct)

@callback message_to_provider_format(struct()) :: map()

Converts a Message struct to the provider-specific format.

Parameters

  • message - The Message struct to convert

stream_chat(list, t, pid, keyword)

@callback stream_chat(list(), String.t(), pid(), keyword()) :: any()

Streams a chat response from the LLM to the given process.

Parameters

  • messages - List of Message structs representing the conversation history
  • message_id - ID for the response message
  • pid - The process ID to stream the response to
  • opts - Options for the request (model, temperature, etc.)

tool_to_provider_format(struct)

@callback tool_to_provider_format(struct()) :: map()

Converts a Tool struct to the provider-specific format.

Parameters

  • tool - The Tool struct to convert

Functions

make_llm_request(url, body, headers, opts \\ [])

Helper function to make HTTP requests to LLM providers with proper error handling

make_streaming_request(url, body, headers, stream_handler, opts \\ [])

Helper function to make streaming HTTP requests to LLM providers with proper error handling