Class OpenAiUtils

java.lang.Object
dev.langchain4j.model.openai.internal.OpenAiUtils

public class OpenAiUtils extends Object
  • Field Details

  • Constructor Details

    • OpenAiUtils

      public OpenAiUtils()
  • Method Details

    • toOpenAiMessages

      public static List<Message> toOpenAiMessages(List<dev.langchain4j.data.message.ChatMessage> messages)
    • toOpenAiMessage

      public static Message toOpenAiMessage(dev.langchain4j.data.message.ChatMessage message)
    • 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, use toTools(Collection, boolean) instead
    • aiMessageFrom

      public static dev.langchain4j.data.message.AiMessage aiMessageFrom(ChatCompletionResponse response)
    • tokenUsageFrom

      public static OpenAiTokenUsage tokenUsageFrom(Usage openAiUsage)
    • finishReasonFrom

      public static dev.langchain4j.model.output.FinishReason finishReasonFrom(String openAiFinishReason)
    • 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)