class

LLM::General

Inherits Reference < Object

General OpenAI-compatible LLM client

Constructors

new(url : String, model : String, api_key : String | Nil)
Source

Class methods

extract_agent_action(response_json : JSON::Any) : String

Parse provider response into normalized JSON action payload. If the model returns tool_calls, convert them to: {"action":"<function_name>","args":{...}} Otherwise, return cleaned textual content as-is.

Source
parse_tools_cached(tools : String) : JSON::Any
Source

Instance methods

request(prompt : String, format : String = "json")

Make a simple request with a single prompt

Source
request_messages(messages : Array(Hash(String, String)), format : String = "json")

Make a request with chat-style messages

Source
request_messages_with_tools(messages : Array(Hash(String, String)), tools : String)

Request next action with provider-native tool-calling. tools must be a JSON array string compatible with OpenAI-style chat completions API.

Source