Class OpenAiUtils
java.lang.Object
dev.langchain4j.model.openai.internal.OpenAiUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic dev.langchain4j.data.message.AiMessage
aiMessageFrom
(ChatCompletionResponse response) static dev.langchain4j.model.output.Response
<dev.langchain4j.data.message.AiMessage> convertResponse
(dev.langchain4j.model.chat.response.ChatResponse chatResponse) static dev.langchain4j.model.output.FinishReason
finishReasonFrom
(String openAiFinishReason) static dev.langchain4j.model.chat.request.ResponseFormat
fromOpenAiResponseFormat
(String responseFormat) toFunctions
(Collection<dev.langchain4j.agent.tool.ToolSpecification> toolSpecifications) Deprecated.static OpenAiTokenUsage
tokenUsageFrom
(Usage openAiUsage) toOpenAiChatRequest
(dev.langchain4j.model.chat.request.ChatRequest chatRequest, OpenAiChatRequestParameters parameters, Boolean strictTools, Boolean strictJsonSchema) static Message
toOpenAiMessage
(dev.langchain4j.data.message.ChatMessage message) toOpenAiMessages
(List<dev.langchain4j.data.message.ChatMessage> messages) static ToolChoiceMode
toOpenAiToolChoice
(dev.langchain4j.model.chat.request.ToolChoice toolChoice) toTools
(Collection<dev.langchain4j.agent.tool.ToolSpecification> toolSpecifications, boolean strict) static void
validate
(dev.langchain4j.model.chat.request.ChatRequestParameters parameters)
-
Field Details
-
DEFAULT_OPENAI_URL
- See Also:
-
DEFAULT_USER_AGENT
- See Also:
-
-
Constructor Details
-
OpenAiUtils
public OpenAiUtils()
-
-
Method Details
-
toOpenAiMessages
-
toOpenAiMessage
-
toTools
public static List<Tool> toTools(Collection<dev.langchain4j.agent.tool.ToolSpecification> toolSpecifications, boolean strict) -
toFunctions
@Deprecated public static List<Function> toFunctions(Collection<dev.langchain4j.agent.tool.ToolSpecification> toolSpecifications) Deprecated.Functions are deprecated by OpenAI, usetoTools(Collection, boolean)
instead -
aiMessageFrom
-
finishReasonFrom
-
toOpenAiToolChoice
public static ToolChoiceMode toOpenAiToolChoice(dev.langchain4j.model.chat.request.ToolChoice toolChoice) -
convertResponse
public static dev.langchain4j.model.output.Response<dev.langchain4j.data.message.AiMessage> convertResponse(dev.langchain4j.model.chat.response.ChatResponse chatResponse) -
validate
public static void validate(dev.langchain4j.model.chat.request.ChatRequestParameters parameters) -
fromOpenAiResponseFormat
public static dev.langchain4j.model.chat.request.ResponseFormat fromOpenAiResponseFormat(String responseFormat) -
toOpenAiChatRequest
public static ChatCompletionRequest.Builder toOpenAiChatRequest(dev.langchain4j.model.chat.request.ChatRequest chatRequest, OpenAiChatRequestParameters parameters, Boolean strictTools, Boolean strictJsonSchema)
-
toTools(Collection, boolean)
instead