All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fi.evolver.ai.spring.skill.SkillPrompt Maven / Gradle / Ivy

package fi.evolver.ai.spring.skill;

import java.time.Duration;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;

import fi.evolver.ai.spring.chat.function.FunctionSpec;
import fi.evolver.ai.spring.prompt.Prompt;

public record SkillPrompt(
		String skillName,
		FunctionSpec functionSpec,
		Optional timeout,
		boolean mandatory,
		Map parameters) implements Prompt {


	public static Builder builder(Skill skill) {
		return new Builder(skill);
	}


	public static class Builder {
		private final String skillName;
		private final FunctionSpec functionSpec;
		private final Map parameters = new LinkedHashMap<>();
		private Optional timeout = Optional.empty();
		private boolean mandatory = false;


		private Builder(Skill skill) {
			this.skillName = skill.getName();
			this.functionSpec = skill.getFunctionSpec();
		}


		public Builder setTimeout(Duration timeout) {
			this.timeout = Optional.ofNullable(timeout);
			return this;
		}


		public Builder setMandatory(boolean value) {
			this.mandatory = value;
			return this;
		}


		public Builder setParameter(String key, Object value) {
			this.parameters.put(key, value);
			return this;
		}


		public SkillPrompt build() {
			return new SkillPrompt(
					skillName,
					functionSpec,
					timeout,
					mandatory,
					parameters);
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy