mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-05-15 20:07:10 +02:00
Adds Javadoc for new classes and annotations
This commit is contained in:
parent
5e6971cc4a
commit
26ec00dab8
@ -8,6 +8,9 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specification of a {@link ToolFunction} that provides the implementation via java reflection calling.
|
||||||
|
*/
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -1,13 +1,23 @@
|
|||||||
package io.github.ollama4j.tools.annotations;
|
package io.github.ollama4j.tools.annotations;
|
||||||
|
|
||||||
|
import io.github.ollama4j.OllamaAPI;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
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)
|
@Target(ElementType.TYPE)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface OllamaToolService {
|
public @interface OllamaToolService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Classes with no-arg constructor that will be used for tool-registration.
|
||||||
|
*/
|
||||||
Class<?>[] providers();
|
Class<?>[] providers();
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,28 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
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)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.PARAMETER)
|
@Target(ElementType.PARAMETER)
|
||||||
public @interface ToolProperty {
|
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();
|
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();
|
String desc();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return tells the llm that it has to set a value for this property.
|
||||||
|
*/
|
||||||
boolean required() default true;
|
boolean required() default true;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,28 @@
|
|||||||
package io.github.ollama4j.tools.annotations;
|
package io.github.ollama4j.tools.annotations;
|
||||||
|
|
||||||
|
import io.github.ollama4j.OllamaAPI;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotates Methods of classes that should be registered as tools by {@link OllamaAPI#registerAnnotatedTools()}
|
||||||
|
* automatically.
|
||||||
|
*/
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface ToolSpec {
|
public @interface ToolSpec {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return tool-name that the method should be used as. Defaults to the methods name.
|
||||||
|
*/
|
||||||
String name() default "";
|
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();
|
String desc();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user