public static Map<String, ChatGPTJavaFunction> extractFunctions(Class<?> clazz) throws Exception {
		Map<String, ChatGPTJavaFunction> functionDeclares = new HashMap<>();
		Set<Class<?>> classesToSearchForFunctions = getAllClassesInType(clazz);
		log.debug("starting to look for functions in " + clazz.getName() + ". found " + classesToSearchForFunctions);

		Set<Method> methods = classesToSearchForFunctions.stream()
			.flatMap(cc -> Stream.of(cc.getDeclaredMethods()))
			.filter(m -> m.getAnnotation(GPTFunction.class) != null)
			.collect(Collectors.toSet());

		log.debug("found " + methods.size() + " methods.");

		if (log.isDebugEnabled() && !methods.isEmpty()) {
			log.debug("found " + methods.size() + " methods");
			log.debug("======================================================================");
			log.debug("class " + clazz.getName());
			for (Method m : methods) {
				log.debug("\t " + m.getReturnType().getName() + " " + m.getName() + "("
						+ Arrays.toString(m.getParameterTypes()) + ")");
			}
		}

		for (Method method : methods) {
			GPTFunction gptFunctionAnnotation = method.getAnnotation(GPTFunction.class);
			if (gptFunctionAnnotation != null) {
				String functionName = gptFunctionAnnotation.name();
				if (functionName.isEmpty()) {
					functionName = method.getName();
				}
				ChatGPTJavaFunction gptJavaFunction = new ChatGPTJavaFunction();
				gptJavaFunction.setJavaMethod(method);
				gptJavaFunction.setName(functionName);
				gptJavaFunction.setDescription(gptFunctionAnnotation.value());
				Class<?> requestClazz = method.getParameterTypes()[0];
				gptJavaFunction.setParameterType(requestClazz);
				gptJavaFunction.setParameters(extractParameters(requestClazz));
				functionDeclares.put(functionName, gptJavaFunction);
			}
		}
		return functionDeclares;
	}
Extract GPT functions from class (and all parent classes/interfaces) by scanning
methods with {@code @GPTFunction}.
@param clazz the Java class whose hierarchy we need to search
@return all functions annotated with
{@code @GPTFunction the @GPTFunction annotation}
src/main/java/org/mvnsearch/chatgpt/model/function/GPTFunctionUtils.java