Class SearchPageAITool

  • All Implemented Interfaces:
    AITool

    public class SearchPageAITool
    extends Object
    implements AITool
    • Constructor Detail

      • SearchPageAITool

        public SearchPageAITool()
    • Method Detail

      • getToolDeclaration

        @Nonnull
        public String getToolDeclaration()
        Description copied from interface: AITool
        The description to use for the OpenAI tool call. Will be inserted into the OpenAI tools array. E.g.:
               {
                 "type": "function",
                 "function": {
                   "name": "get_delivery_date",
                   "description": "Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'",
                   "parameters": {
                     "type": "object",
                     "properties": {
                       "order_id": {
                         "type": "string",
                         "description": "The customer's order ID."
                       }
                     },
                     "required": ["order_id"],
                     "additionalProperties": false
                   }
                 },
                 "strict": true
               }
         
        Specified by:
        getToolDeclaration in interface AITool
        See Also:
        "https://platform.openai.com/docs/api-reference/chat/create"
      • isAllowedFor

        public boolean isAllowedFor​(@Nonnull
                                    org.apache.sling.api.resource.Resource resource)
        Description copied from interface: AITool
        Whether the tool is enabled for the given resource.
        Specified by:
        isAllowedFor in interface AITool
      • execute

        @Nonnull
        public String execute​(@Nullable
                              String arguments,
                              @Nonnull
                              org.apache.sling.api.resource.Resource resource,
                              @Nullable
                              com.composum.ai.backend.base.service.chat.GPTCompletionCallback.GPTToolExecutionContext context)
        Does a query with lucene and then rates the results with the embedding.
        Specified by:
        execute in interface AITool
      • deactivate

        protected void deactivate()