Class ModifyPageReadTool
- java.lang.Object
 - 
- com.composum.ai.backend.slingbase.experimential.impl.ModifyPageReadTool
 
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classModifyPageReadTool.ComponentDescriptionprotected static classModifyPageReadTool.ComponentPropertystatic interfaceModifyPageReadTool.Configprotected static classModifyPageReadTool.PageProperties 
- 
Field Summary
Fields Modifier and Type Field Description static PatternPATTERN_TWO_SEPARATE_WHITESPACEHeuristic to detect text attributes. 
- 
Constructor Summary
Constructors Constructor Description ModifyPageReadTool() 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidactivate(ModifyPageReadTool.Config config)protected voiddeactivate()static Stream<org.apache.sling.api.resource.Resource>descendantsStream(org.apache.sling.api.resource.Resource resource)Returns a stream that goes through all descendants of a resource, parents come before their children.Stringexecute(String arguments, org.apache.sling.api.resource.Resource resource, GPTCompletionCallback.GPTToolExecutionContext context)Executes the tool call and returns the result to present to the AI.StringgetDescription(Locale locale)Human readable description.StringgetName(Locale locale)Human readable name.StringgetToolDeclaration()The description to use for the OpenAI tool call.StringgetToolName()Name for the purpose of calling - must matchAITool.getToolDeclaration().booleanisAllowedFor(org.apache.sling.api.resource.Resource resource)Whether the tool is enabled for the given resource.- 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
- 
Methods inherited from interface com.composum.ai.backend.slingbase.experimential.AITool
makeGPTTool 
 - 
 
 - 
 
- 
- 
Field Detail
- 
PATTERN_TWO_SEPARATE_WHITESPACE
public static final Pattern PATTERN_TWO_SEPARATE_WHITESPACE
Heuristic to detect text attributes. 
 - 
 
- 
Method Detail
- 
getName
@Nonnull public String getName(@Nullable Locale locale)
Description copied from interface:AIToolHuman readable name. 
- 
getDescription
@Nonnull public String getDescription(@Nullable Locale locale)
Description copied from interface:AIToolHuman readable description.- Specified by:
 getDescriptionin interfaceAITool
 
- 
getToolName
@Nonnull public String getToolName()
Description copied from interface:AIToolName for the purpose of calling - must matchAITool.getToolDeclaration().- Specified by:
 getToolNamein interfaceAITool
 
- 
getToolDeclaration
@Nonnull public String getToolDeclaration()
Description copied from interface:AIToolThe 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:
 getToolDeclarationin interfaceAITool- See Also:
 - "https://platform.openai.com/docs/api-reference/chat/create"
 
 
- 
isAllowedFor
public boolean isAllowedFor(@Nullable org.apache.sling.api.resource.Resource resource)
Description copied from interface:AIToolWhether the tool is enabled for the given resource.- Specified by:
 isAllowedForin interfaceAITool
 
- 
execute
@Nonnull public String execute(@Nullable String arguments, @Nonnull org.apache.sling.api.resource.Resource resource, @Nullable GPTCompletionCallback.GPTToolExecutionContext context)
Description copied from interface:AIToolExecutes the tool call and returns the result to present to the AI. Must only be called ifAITool.isAllowedFor(Resource)returned true. 
- 
descendantsStream
@Nonnull public static Stream<org.apache.sling.api.resource.Resource> descendantsStream(@Nullable org.apache.sling.api.resource.Resource resource)
Returns a stream that goes through all descendants of a resource, parents come before their children.- Parameters:
 resource- a resource or null- Returns:
 - a stream running through the resource and it's the descendants, not null
 
 
- 
activate
protected void activate(ModifyPageReadTool.Config config)
 
- 
deactivate
protected void deactivate()
 
 - 
 
 -