LlmEx.ClientBehaviour 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

Invoked when a module uses LlmEx.ClientBehaviour. Implements default functionality for the client.

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

__using__(opts)

(macro)

Invoked when a module uses LlmEx.ClientBehaviour. Implements default functionality for the client.