Uses of Class
dev.langchain4j.service.AiServiceContext
Packages that use AiServiceContext
Package
Description
-
Uses of AiServiceContext in dev.langchain4j.agentic.agent
Methods in dev.langchain4j.agentic.agent with parameters of type AiServiceContextModifier and TypeMethodDescriptionprotected voidAgentBuilder.build(DefaultAgenticScope agenticScope, AiServiceContext context, AiServices<T> aiServices) protected voidUntypedAgentBuilder.build(DefaultAgenticScope agenticScope, AiServiceContext context, AiServices<UntypedAgent> aiServices) Constructors in dev.langchain4j.agentic.agent with parameters of type AiServiceContextModifierConstructorDescriptionAgentInvocationHandler(AiServiceContext context, Object agent, AgentBuilder<?, ?> builder, boolean agenticScopeDependent) -
Uses of AiServiceContext in dev.langchain4j.service
Fields in dev.langchain4j.service declared as AiServiceContextMethods in dev.langchain4j.service that return AiServiceContextModifier and TypeMethodDescriptionAiServiceTokenStreamParameters.context()static AiServiceContextMethods in dev.langchain4j.service with parameters of type AiServiceContextModifier and TypeMethodDescriptionstatic <T> AiServices<T> AiServices.builder(AiServiceContext context) AiServiceTokenStreamParameters.Builder.context(AiServiceContext context) Sets the AI service context.Constructors in dev.langchain4j.service with parameters of type AiServiceContext -
Uses of AiServiceContext in dev.langchain4j.service.tool
Methods in dev.langchain4j.service.tool with parameters of type AiServiceContextModifier and TypeMethodDescriptionToolService.executeInferenceAndToolsLoop(AiServiceContext context, Object memoryId, ChatResponse chatResponse, ChatRequestParameters parameters, List<ChatMessage> messages, ChatMemory chatMemory, InvocationContext invocationContext, ToolServiceContext toolServiceContext, boolean isReturnTypeResult) ToolService.executeInferenceAndToolsLoop(AiServiceContext context, Object memoryId, ChatResponse chatResponse, ChatRequestParameters parameters, List<ChatMessage> messages, ChatMemory chatMemory, InvocationContext invocationContext, ToolServiceContext toolServiceContext, Function<ChatRequest, ChatResponse> chatModelInvoker) ToolService.executeInferenceAndToolsLoopAsync(AiServiceContext context, Object memoryId, ChatResponse chatResponse, ChatRequestParameters parameters, List<ChatMessage> messages, ChatMemory chatMemory, InvocationContext invocationContext, ToolServiceContext toolServiceContext, CompletableFuture<?> cancellation) ToolService.executeInferenceAndToolsLoopAsync(AiServiceContext context, Object memoryId, ChatResponse chatResponse, ChatRequestParameters parameters, List<ChatMessage> messages, ChatMemory chatMemory, InvocationContext invocationContext, ToolServiceContext toolServiceContext, CompletableFuture<?> cancellation, Function<ChatRequest, CompletableFuture<ChatResponse>> chatModelInvoker) AsToolService.executeInferenceAndToolsLoopAsync(AiServiceContext, Object, ChatResponse, ChatRequestParameters, List, ChatMemory, InvocationContext, ToolServiceContext, CompletableFuture), but with a caller-supplied asynchronous model invoker.ToolService.persistToolResultsAndResolveMessages(AiServiceContext context, ChatMemory chatMemory, List<ChatMessage> accumulator, List<ToolExecutionResultMessage> resultMessages, InvocationContext invocationContext) Persists the tool-result messages and resolves the messages to send in the next request — the memory-touching counterpart toToolService.processToolResults(AiServiceContext, List, Map, List, InvocationContext, ToolServiceContext), kept out of that shared bookkeeping so that each AI Service mode can perform the memory I/O on the appropriate thread (synchronously for the sync/TokenStreammodes, composed for theCompletableFuture/reactive modes).ToolService.persistToolResultsAndResolveMessagesSync(AiServiceContext context, ChatMemory chatMemory, List<ChatMessage> accumulator, List<ToolExecutionResultMessage> resultMessages, InvocationContext invocationContext) Blocking counterpart ofToolService.persistToolResultsAndResolveMessages(AiServiceContext, ChatMemory, List, List, InvocationContext)for the synchronous andTokenStreamAI Service modes, which use the synchronousChatMemorymethods (so a memory backed by a blocking store that only implements the synchronous methods keeps working).ToolService.prepareNextChatRequest(AiServiceContext context, Object memoryId, List<ChatMessage> messages, InvocationContext invocationContext, ToolServiceContext toolServiceContext, Map<ToolExecutionRequest, ToolExecutionResult> toolResults, ChatRequestParameters parameters) Builds the next round'sChatRequest, shared by every AI Service mode: given the already-resolvedmessagesto send (seeToolService.resolveMessagesForNextRequest(List, AiServiceContext, InvocationContext)), it refreshes dynamic tool providers, folds in any tools found by tool search, overrides the tool specifications on the carried-forwardparameters, applies the chat-request transformer, and fires theAiServiceRequestIssuedEvent.ToolService.processToolResults(AiServiceContext context, List<ToolExecutionRequest> toolExecutionRequests, Map<ToolExecutionRequest, ToolExecutionResult> toolResults, List<ToolExecution> toolExecutions, InvocationContext invocationContext, ToolServiceContext toolServiceContext) Per-round bookkeeping shared by every AI Service mode (sync,CompletableFuture,TokenStream, reactiveFlow.Publisher): for each executed tool it records aToolExecution, fires theToolExecutedEvent, collects the tool-result message (in request order), and accumulatesanyToolErrored+ the per-toolReturnBehaviors.static List<ChatMessage> ToolService.resolveMessagesForNextRequest(List<ChatMessage> memoryMessages, AiServiceContext context, InvocationContext invocationContext) Resolves the messages to send in the next request from the current memory view, honoringstoreRetrievedContentInChatMemory(whenfalse, the last user message is replaced with the original, un-augmented one so retrieved content is not persisted across rounds). -
Uses of AiServiceContext in dev.langchain4j.spi.services
Methods in dev.langchain4j.spi.services that return AiServiceContextModifier and TypeMethodDescriptionMethods in dev.langchain4j.spi.services with parameters of type AiServiceContextModifier and TypeMethodDescription<T> AiServices<T> AiServicesFactory.create(AiServiceContext context)