public void functionCallOpenAIAPIGeminiWithGRPC()

in ai-patterns/langchain4j-function-calling-openai-api/src/main/java/services/gemini/Langchain4JFunctionCallingApplication.java [125:153]


	public void functionCallOpenAIAPIGeminiWithGRPC(String userMessage) throws IOException {
			long start = System.currentTimeMillis();

			String token = getToken(openAIVertexUrl);

			ChatLanguageModel model = OpenAiChatModel.builder()
					.apiKey(token)
					.baseUrl(openAIVertexUrl)
					.modelName(openAIVertexChatModel)
					.maxTokens(4096)
					.temperature(0.2)
					.logRequests(true)
					.logResponses(true)
					.maxRetries(1)
					.build();

		FunctionCallingService service = new FunctionCallingService();

		Assistant assistant = AiServices.builder(Assistant.class)
				.chatLanguageModel(model)
				.chatMemory(MessageWindowChatMemory.withMaxMessages(10))
				.tools(service)
				.build();

		System.out.printf("Calling model %s in project %s in location %s at URL %s\n", openAIVertexChatModel, project, location, openAIVertexUrl);
		System.out.println("User message: " + userMessage);
		System.out.println(assistant.chat(userMessage));
		System.out.println("VertexAI Gemini call using OPenAI API and GRPC took " + (System.currentTimeMillis() - start) + " ms");
	}