Class: Legate::LLM::Adapter
- Inherits:
-
Object
- Object
- Legate::LLM::Adapter
- Defined in:
- lib/legate/llm/adapter.rb
Overview
Abstract base for LLM provider adapters.
Instance Method Summary collapse
-
#available? ⇒ Boolean
Whether the adapter can make calls (e.g. an API key is present and the client constructed successfully).
-
#generate(prompt, json: false, schema: nil) ⇒ String?
Generates a text completion for a single user prompt.
-
#generate_with_tools(prompt, tools:) ⇒ Hash
Chooses the next action with the given tool schemas available to the model, using native function calling.
-
#model_name ⇒ String?
The resolved model identifier, or nil if the adapter is unavailable.
-
#supports_function_calling? ⇒ Boolean
Whether this adapter can use the provider’s native function/tool-calling API.
-
#supports_structured_output? ⇒ Boolean
Whether this adapter can constrain output to a schema (structured output) via the ‘schema:` argument to #generate.
Instance Method Details
#available? ⇒ Boolean
Returns whether the adapter can make calls (e.g. an API key is present and the client constructed successfully).
14 15 16 |
# File 'lib/legate/llm/adapter.rb', line 14 def available? false end |
#generate(prompt, json: false, schema: nil) ⇒ String?
Generates a text completion for a single user prompt.
32 33 34 |
# File 'lib/legate/llm/adapter.rb', line 32 def generate(prompt, json: false, schema: nil) raise NotImplementedError, "#{self.class} must implement #generate" end |
#generate_with_tools(prompt, tools:) ⇒ Hash
Chooses the next action with the given tool schemas available to the model, using native function calling. Only meaningful when #supports_function_calling? is true.
64 65 66 |
# File 'lib/legate/llm/adapter.rb', line 64 def generate_with_tools(prompt, tools:) raise NotImplementedError, "#{self.class} must implement #generate_with_tools" end |
#model_name ⇒ String?
The resolved model identifier, or nil if the adapter is unavailable.
20 21 22 |
# File 'lib/legate/llm/adapter.rb', line 20 def model_name nil end |
#supports_function_calling? ⇒ Boolean
Whether this adapter can use the provider’s native function/tool-calling API. When true, the agentic loop selects its next action via #generate_with_tools (structured, reliable) instead of parsing JSON out of prose; when false it falls back to the JSON-prompt path. Default false.
50 51 52 |
# File 'lib/legate/llm/adapter.rb', line 50 def supports_function_calling? false end |
#supports_structured_output? ⇒ Boolean
Whether this adapter can constrain output to a schema (structured output) via the ‘schema:` argument to #generate. When true, the planner uses it to guarantee valid plan JSON instead of parsing it out of prose. Default false (the prompt-and-parse path).
41 42 43 |
# File 'lib/legate/llm/adapter.rb', line 41 def supports_structured_output? false end |