class LLM::General

Overview

General OpenAI-compatible LLM client

Defined in:

llm/general/client.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(url : String, model : String, api_key : String | Nil) #

[View source]

Class Method Detail

def self.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.


[View source]
def self.parse_tools_cached(tools : String) : JSON::Any #

[View source]

Instance Method Detail

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

Make a simple request with a single prompt


[View source]
def request_messages(messages : Array(Hash(String, String)), format : String = "json") #

Make a request with chat-style messages


[View source]
def 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.


[View source]