Package dev.langchain4j.model.openai
Class OpenAiChatModel
java.lang.Object
dev.langchain4j.model.openai.OpenAiChatModel
- All Implemented Interfaces:
dev.langchain4j.model.chat.ChatLanguageModel
,dev.langchain4j.model.chat.TokenCountEstimator
public class OpenAiChatModel
extends Object
implements dev.langchain4j.model.chat.ChatLanguageModel, dev.langchain4j.model.chat.TokenCountEstimator
Represents an OpenAI language model with a chat completion interface, such as gpt-3.5-turbo and gpt-4.
You can find description of parameters here.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionOpenAiChatModel
(String baseUrl, String apiKey, String organizationId, String modelName, Double temperature, Double topP, List<String> stop, Integer maxTokens, Integer maxCompletionTokens, Double presencePenalty, Double frequencyPenalty, Map<String, Integer> logitBias, String responseFormat, Boolean strictJsonSchema, Integer seed, String user, Boolean strictTools, Boolean parallelToolCalls, Duration timeout, Integer maxRetries, Proxy proxy, Boolean logRequests, Boolean logResponses, dev.langchain4j.model.Tokenizer tokenizer, Map<String, String> customHeaders, List<dev.langchain4j.model.chat.listener.ChatModelListener> listeners) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
dev.langchain4j.model.chat.response.ChatResponse
chat
(dev.langchain4j.model.chat.request.ChatRequest request) int
estimateTokenCount
(List<dev.langchain4j.data.message.ChatMessage> messages) dev.langchain4j.model.output.Response
<dev.langchain4j.data.message.AiMessage> dev.langchain4j.model.output.Response
<dev.langchain4j.data.message.AiMessage> generate
(List<dev.langchain4j.data.message.ChatMessage> messages, dev.langchain4j.agent.tool.ToolSpecification toolSpecification) dev.langchain4j.model.output.Response
<dev.langchain4j.data.message.AiMessage> generate
(List<dev.langchain4j.data.message.ChatMessage> messages, List<dev.langchain4j.agent.tool.ToolSpecification> toolSpecifications) Set
<dev.langchain4j.model.chat.Capability> static OpenAiChatModel
withApiKey
(String apiKey) Deprecated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.langchain4j.model.chat.ChatLanguageModel
generate, generate
Methods inherited from interface dev.langchain4j.model.chat.TokenCountEstimator
estimateTokenCount, estimateTokenCount, estimateTokenCount, estimateTokenCount
-
Constructor Details
-
OpenAiChatModel
public OpenAiChatModel(String baseUrl, String apiKey, String organizationId, String modelName, Double temperature, Double topP, List<String> stop, Integer maxTokens, Integer maxCompletionTokens, Double presencePenalty, Double frequencyPenalty, Map<String, Integer> logitBias, String responseFormat, Boolean strictJsonSchema, Integer seed, String user, Boolean strictTools, Boolean parallelToolCalls, Duration timeout, Integer maxRetries, Proxy proxy, Boolean logRequests, Boolean logResponses, dev.langchain4j.model.Tokenizer tokenizer, Map<String, String> customHeaders, List<dev.langchain4j.model.chat.listener.ChatModelListener> listeners)
-
-
Method Details
-
modelName
-
supportedCapabilities
- Specified by:
supportedCapabilities
in interfacedev.langchain4j.model.chat.ChatLanguageModel
-
generate
public dev.langchain4j.model.output.Response<dev.langchain4j.data.message.AiMessage> generate(List<dev.langchain4j.data.message.ChatMessage> messages) - Specified by:
generate
in interfacedev.langchain4j.model.chat.ChatLanguageModel
-
generate
public dev.langchain4j.model.output.Response<dev.langchain4j.data.message.AiMessage> generate(List<dev.langchain4j.data.message.ChatMessage> messages, List<dev.langchain4j.agent.tool.ToolSpecification> toolSpecifications) - Specified by:
generate
in interfacedev.langchain4j.model.chat.ChatLanguageModel
-
generate
public dev.langchain4j.model.output.Response<dev.langchain4j.data.message.AiMessage> generate(List<dev.langchain4j.data.message.ChatMessage> messages, dev.langchain4j.agent.tool.ToolSpecification toolSpecification) - Specified by:
generate
in interfacedev.langchain4j.model.chat.ChatLanguageModel
-
chat
public dev.langchain4j.model.chat.response.ChatResponse chat(dev.langchain4j.model.chat.request.ChatRequest request) - Specified by:
chat
in interfacedev.langchain4j.model.chat.ChatLanguageModel
-
estimateTokenCount
- Specified by:
estimateTokenCount
in interfacedev.langchain4j.model.chat.TokenCountEstimator
-
withApiKey
Deprecated.usebuilder()
instead and explicitly set the model name and, if required, other parameters. -
builder
-
builder()
instead and explicitly set the model name and, if required, other parameters.