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

fi.evolver.ai.spring.chat.FunctionCall Maven / Gradle / Ivy

package fi.evolver.ai.spring.chat;

import fi.evolver.ai.spring.chat.function.FunctionSpec;
import fi.evolver.ai.spring.json.JsonSpecException;

public interface FunctionCall {

	public String getFunctionName();


	/**
	 * Parse the function call response in accordance to the specification.
	 * Blocks until the end of the API response.
	 * Fails if the requested function's name doesn't match to the actual function name.
	 *
	 * @param  The result type.
	 * @param spec The function specification.
	 * @return The parsed result.
	 */
	public default  T toResult(FunctionSpec spec) {
		if (!spec.getFunctionName().equals(getFunctionName()))
			throw new JsonSpecException("Expected function %s, got %s", spec.getFunctionName(), getFunctionName());

		return spec.parse(getArgumentData());
	}


	/**
	 * Return the unparsed argument data.
	 * Blocks until the end of the API response.
	 *
	 * @return The function argument data.
	 */
	public String getArgumentData();

	public String getToolCallId();

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy