Interface LlmReference

  • All Implemented Interfaces:
    com.embabel.common.ai.prompt.PromptContributor , com.embabel.common.ai.prompt.PromptElement , com.embabel.common.core.types.Described , com.embabel.common.core.types.Named , com.embabel.common.core.types.NamedAndDescribed

    
    public interface LlmReference
     implements NamedAndDescribed, PromptContributor
                        

    An LLmReference exposes tools and is a prompt contributor. The prompt contribution might describe how to use the tools or can include relevant information directly. Consider, for example, a reference to an API which is so small it's included in the prompt, versus a large API which must be accessed via tools. The reference name is used in a strategy for tool naming, so should be fairly short. Description may be more verbose. If you want a custom naming strategy, use a ToolObject directly, and add the PromptContributor separately.

    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      String toolPrefix() A safe prefix for LLM tools associated with this reference.
      ToolObject toolObject() Create a tool object for this reference.
      List<Object> toolInstances() Return the instances of tool object.
      String contribution()
      abstract String notes() Notes about this reference, such as usage guidance.
      List<Tool> tools() Return framework-agnostic tools provided by this reference.
      LlmReference asMatryoshka() Convert this reference to a MatryoshkaReference, exposing a single tool object that supports nesting.
      LlmReference withUnfolding() Convert this reference to a reference exposing a single unfolding tool.
      StringTransformer getNamingStrategy()
      • Methods inherited from class com.embabel.common.ai.prompt.PromptContributor

        promptContribution
      • Methods inherited from class com.embabel.common.core.types.Described

        getDescription
      • Methods inherited from class com.embabel.common.core.types.Named

        getName
      • Methods inherited from class com.embabel.common.ai.prompt.PromptElement

        getPromptContributionLocation, getRole
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • toolPrefix

         String toolPrefix()

        A safe prefix for LLM tools associated with this reference. Defaults to the name lowercased with spaces replaced by underscores. Subclasses can override it

      • notes

         abstract String notes()

        Notes about this reference, such as usage guidance. Does not need to consider prompt prefix, name or description as they will be added automatically.

      • tools

         List<Tool> tools()

        Return framework-agnostic tools provided by this reference. These tools will be added to the PromptRunner when the reference is added.

        The default implementation bridges from the deprecated toolInstances method by converting any @LlmTool annotated objects to Tool instances. New implementations should override this method directly.

      • asMatryoshka

        @Deprecated(replaceWith = @ReplaceWith(imports = {}, expression = "withUnfoldingTool()"), message = "Use withUnfoldingTool()", level = DeprecationLevel.WARNING) LlmReference asMatryoshka()

        Convert this reference to a MatryoshkaReference, exposing a single tool object that supports nesting. Do not rewrap a MatryoshkaReference. Thus repeated calls to this method are safe.

      • withUnfolding

         LlmReference withUnfolding()

        Convert this reference to a reference exposing a single unfolding tool. Does not rewrap an unfolding reference. Thus repeated calls to this method are safe.