org.llm4s.capability

Members list

Type members

Classlikes

@Experimental
enum Capability(val supportsKey: String)

A capability as a value: the name of one marker, such as Capability.Vision for Vision, and the key of ModelMetadata.supports that says a model has it. Capable.capabilities and CapabilityCheck.missing list these, in the order of Capability.values.

A capability as a value: the name of one marker, such as Capability.Vision for Vision, and the key of ModelMetadata.supports that says a model has it. Capable.capabilities and CapabilityCheck.missing list these, in the order of Capability.values.

Value parameters

supportsKey

the key of ModelMetadata.supports for this capability

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final class CapabilityCheck[C]

The capabilities of a capability set C, such as Vision & Tools, and how to check them against a model's metadata.

The capabilities of a capability set C, such as Vision & Tools, and how to check them against a model's metadata.

There is one given for every set: the compiler takes C apart at its &s, and refuses at compile time any part that is not one of the markers Vision, Tools, ParallelTools, StructuredOutput, Reasoning, PromptCaching and SystemMessages. A set is never written as a value; it is summoned by org.llm4s.capability.requireCapabilities and Capable.assume.

Type parameters

C

the capability set

Value parameters

capabilities

the set's capabilities, each once, in the order of Capability.values (the compiler may reorder an intersection, so the order it is written in is not kept)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
final class Capable[+C]

A client whose model has the capabilities C, a set such as Vision & Tools.

A client whose model has the capabilities C, a set such as Vision & Tools.

One is made at the application's edge, by org.llm4s.capability.requireCapabilities, which checks the model's metadata, or by Capable.assume, which does not. From then on the compiler tracks the set: an operation that needs vision takes a Capable[Vision], and since Capable is covariant a Capable[Vision & Tools] is one, while a Capable[Tools] is a compile error.

Type parameters

C

the capability set

Value parameters

capabilities

the capabilities this value was checked (or assumed) for, which may be more than its static type shows

client

the client, unchanged

metadata

the model metadata the capabilities were checked against; None when they were assumed

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object Capable

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Capable.type
@Experimental
sealed trait ParallelTools

The model calls several tools in one reply (ModelMetadata.supports("parallel_function_calling")).

The model calls several tools in one reply (ModelMetadata.supports("parallel_function_calling")).

Attributes

Supertypes
class Object
trait Matchable
class Any
@Experimental
sealed trait PromptCaching

The provider caches the prompt for this model (ModelMetadata.supports("prompt_caching")).

The provider caches the prompt for this model (ModelMetadata.supports("prompt_caching")).

Attributes

Supertypes
class Object
trait Matchable
class Any
@Experimental
sealed trait Reasoning

The model reasons before it answers (ModelMetadata.supports("reasoning")).

The model reasons before it answers (ModelMetadata.supports("reasoning")).

Attributes

Supertypes
class Object
trait Matchable
class Any
@Experimental
sealed trait StructuredOutput

The model answers in a given JSON schema (ModelMetadata.supports("response_schema")).

The model answers in a given JSON schema (ModelMetadata.supports("response_schema")).

Attributes

Supertypes
class Object
trait Matchable
class Any
@Experimental
sealed trait SystemMessages

The model takes system messages (ModelMetadata.supports("system_messages")).

The model takes system messages (ModelMetadata.supports("system_messages")).

Attributes

Supertypes
class Object
trait Matchable
class Any
@Experimental
sealed trait Tools

The model calls tools (ModelMetadata.supports("function_calling")).

The model calls tools (ModelMetadata.supports("function_calling")).

Attributes

Supertypes
class Object
trait Matchable
class Any
@Experimental
sealed trait Vision

The model reads images (ModelMetadata.supports("vision")).

The model reads images (ModelMetadata.supports("vision")).

Attributes

Supertypes
class Object
trait Matchable
class Any

Extensions

Extensions

extension (client: LLMClient)
def requireCapabilities[C](provider: String, model: String)(using registry: ModelRegistryService, check: CapabilityCheck[C]): Result[Capable[C]]

Checks once, here, that provider's model has the capabilities C, by the registry's metadata, and returns the client typed with them: client.requireCapabilities[Vision & Tools]("openai", "gpt-4o").

Checks once, here, that provider's model has the capabilities C, by the registry's metadata, and returns the client typed with them: client.requireCapabilities[Vision & Tools]("openai", "gpt-4o").

Fails with the registry's error when it does not know the model (see Capable.assume for that case), and with a org.llm4s.error.ValidationError on the field capabilities that names every capability the model lacks.

Attributes