Description
Now , i known how to invoke chat with a imgage ,the code below
OpenAIClient client = OpenAIOkHttpClient.builder() .apiKey(apiKey) .baseUrl(baseUrl) .build(); // ClassLoader classloader = Thread.currentThread().getContextClassLoader(); // byte[] logoBytes = classloader.getResource("1.png").openStream().readAllBytes(); String logoBase64Url = "data:image/jpeg;base64," + Base64.getEncoder().encodeToString(bytes); ChatCompletionContentPart logoContentPart = ChatCompletionContentPart.ofImageUrl(ChatCompletionContentPartImage.builder() .imageUrl(ChatCompletionContentPartImage.ImageUrl.builder() .url(logoBase64Url) .build()) .build()); ChatCompletionContentPart questionContentPart = ChatCompletionContentPart.ofText(ChatCompletionContentPartText.builder() .text(msg) .build()); ChatCompletionCreateParams createParams = ChatCompletionCreateParams.builder() .model(model) // .maxCompletionTokens(2048) .addUserMessageOfArrayOfContentParts(List.of(questionContentPart, logoContentPart)) .build();
But How to invoke chat with a file sush as pdf or docx?
I find the api is
ChatCompletionContentPart logoContentPart = ChatCompletionContentPart.ofFile(ChatCompletionContentPart.File.builder());
but i do not known how to complete it,could you give a example? thank you