forked from Mirror/ollama4j
		
	Adds Javadoc for new classes and annotations
This commit is contained in:
		@@ -8,6 +8,9 @@ import java.lang.reflect.Method;
 | 
			
		||||
import java.util.LinkedHashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Specification of a {@link ToolFunction} that provides the implementation via java reflection calling.
 | 
			
		||||
 */
 | 
			
		||||
@Setter
 | 
			
		||||
@Getter
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,23 @@
 | 
			
		||||
package io.github.ollama4j.tools.annotations;
 | 
			
		||||
 | 
			
		||||
import io.github.ollama4j.OllamaAPI;
 | 
			
		||||
 | 
			
		||||
import java.lang.annotation.ElementType;
 | 
			
		||||
import java.lang.annotation.Retention;
 | 
			
		||||
import java.lang.annotation.RetentionPolicy;
 | 
			
		||||
import java.lang.annotation.Target;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Annotates a class that calls {@link io.github.ollama4j.OllamaAPI} such that the Method
 | 
			
		||||
 * {@link OllamaAPI#registerAnnotatedTools()} can be used to auto-register all provided classes (resp. all
 | 
			
		||||
 * contained Methods of the provider classes annotated with {@link ToolSpec}).
 | 
			
		||||
 */
 | 
			
		||||
@Target(ElementType.TYPE)
 | 
			
		||||
@Retention(RetentionPolicy.RUNTIME)
 | 
			
		||||
public @interface OllamaToolService {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return Classes with no-arg constructor that will be used for tool-registration.
 | 
			
		||||
     */
 | 
			
		||||
    Class<?>[] providers();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -5,13 +5,28 @@ import java.lang.annotation.Retention;
 | 
			
		||||
import java.lang.annotation.RetentionPolicy;
 | 
			
		||||
import java.lang.annotation.Target;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Annotates a Method Parameter in a {@link ToolSpec} annotated Method. A parameter annotated with this annotation will
 | 
			
		||||
 * be part of the tool description that is sent to the llm for tool-calling.
 | 
			
		||||
 */
 | 
			
		||||
@Retention(RetentionPolicy.RUNTIME)
 | 
			
		||||
@Target(ElementType.PARAMETER)
 | 
			
		||||
public @interface ToolProperty {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return name of the parameter that is used for the tool description. Has to be set as depending on the caller,
 | 
			
		||||
     * method name backtracking is not possible with reflection.
 | 
			
		||||
     */
 | 
			
		||||
    String name();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return a detailed description of the parameter. This is used by the llm called to specify, which property has
 | 
			
		||||
     * to be set by the llm and how this should be filled.
 | 
			
		||||
     */
 | 
			
		||||
    String desc();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return tells the llm that it has to set a value for this property.
 | 
			
		||||
     */
 | 
			
		||||
    boolean required() default true;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,28 @@
 | 
			
		||||
package io.github.ollama4j.tools.annotations;
 | 
			
		||||
 | 
			
		||||
import io.github.ollama4j.OllamaAPI;
 | 
			
		||||
 | 
			
		||||
import java.lang.annotation.ElementType;
 | 
			
		||||
import java.lang.annotation.Retention;
 | 
			
		||||
import java.lang.annotation.RetentionPolicy;
 | 
			
		||||
import java.lang.annotation.Target;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Annotates Methods of classes that should be registered as tools by {@link OllamaAPI#registerAnnotatedTools()}
 | 
			
		||||
 * automatically.
 | 
			
		||||
 */
 | 
			
		||||
@Target(ElementType.METHOD)
 | 
			
		||||
@Retention(RetentionPolicy.RUNTIME)
 | 
			
		||||
public @interface ToolSpec {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return tool-name that the method should be used as. Defaults to the methods name.
 | 
			
		||||
     */
 | 
			
		||||
    String name() default "";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return a detailed description of the method that can be interpreted by the llm, whether it should call the tool
 | 
			
		||||
     * or not.
 | 
			
		||||
     */
 | 
			
		||||
    String desc();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user