Class OpenAiUtils
java.lang.Object
dev.langchain4j.model.openai.internal.OpenAiUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AiMessageaiMessageFrom(ChatCompletionResponse response) static AiMessageaiMessageFrom(ChatCompletionResponse response, boolean returnThinking) convertResponse(ChatResponse chatResponse) static FinishReasonfinishReasonFrom(String openAiFinishReason) static ResponseFormatfromOpenAiResponseFormat(String responseFormat) toFunctions(Collection<ToolSpecification> toolSpecifications) Deprecated.static OpenAiTokenUsagetokenUsageFrom(Usage openAiUsage) toOpenAiChatRequest(ChatRequest chatRequest, OpenAiChatRequestParameters parameters, boolean sendThinking, String thinkingFieldName, Boolean strictTools, Boolean strictJsonSchema) toOpenAiChatRequest(ChatRequest chatRequest, OpenAiChatRequestParameters parameters, Boolean strictTools, Boolean strictJsonSchema) static MessagetoOpenAiMessage(ChatMessage message) static MessagetoOpenAiMessage(ChatMessage message, boolean sendThinking, String thinkingFieldName) toOpenAiMessages(List<ChatMessage> messages) toOpenAiMessages(List<ChatMessage> messages, boolean sendThinking, String thinkingFieldName) static ToolChoiceModetoOpenAiToolChoice(ToolChoice toolChoice) toTools(Collection<ToolSpecification> toolSpecifications, boolean strict) static voidvalidate(ChatRequestParameters parameters)
-
Field Details
-
DEFAULT_OPENAI_URL
- See Also:
-
DEFAULT_USER_AGENT
- See Also:
-
-
Constructor Details
-
OpenAiUtils
public OpenAiUtils()
-
-
Method Details
-
toOpenAiMessages
-
toOpenAiMessages
public static List<Message> toOpenAiMessages(List<ChatMessage> messages, boolean sendThinking, String thinkingFieldName) -
toOpenAiMessage
-
toOpenAiMessage
public static Message toOpenAiMessage(ChatMessage message, boolean sendThinking, String thinkingFieldName) -
toTools
-
toFunctions
@Deprecated public static List<Function> toFunctions(Collection<ToolSpecification> toolSpecifications) Deprecated.Functions are deprecated by OpenAI, usetoTools(Collection, boolean)instead -
aiMessageFrom
-
aiMessageFrom
-
finishReasonFrom
-
toOpenAiToolChoice
-
convertResponse
-
validate
-
fromOpenAiResponseFormat
-
toOpenAiChatRequest
public static ChatCompletionRequest.Builder toOpenAiChatRequest(ChatRequest chatRequest, OpenAiChatRequestParameters parameters, Boolean strictTools, Boolean strictJsonSchema) -
toOpenAiChatRequest
public static ChatCompletionRequest.Builder toOpenAiChatRequest(ChatRequest chatRequest, OpenAiChatRequestParameters parameters, boolean sendThinking, String thinkingFieldName, Boolean strictTools, Boolean strictJsonSchema)
-
toTools(Collection, boolean)instead