basic_processor.go

Overview

basic_processor.go provides core functionality to prepare and populate model.LLMRequest objects with configuration data derived from an LLM agent's internal settings. The primary role of this file is to ensure that the request sent to the Large Language Model (LLM) is properly configured according to the agent's generation parameters and output schema. Additionally, it includes a generic deep cloning utility implemented using Go's reflection capabilities, which supports copying complex nested structures such as structs, slices, maps, and pointers.

This file is an internal component that interacts closely with the agent runtime and model layers, particularly focusing on configuring generation requests before they are dispatched to the underlying LLM services. It references agent context and request models to extract and apply configuration settings.


Functions and Methods

basicRequestProcessor

func basicRequestProcessor(ctx agent.InvocationContext, req *model.LLMRequest) error
var req model.LLMRequest
err := basicRequestProcessor(ctx, &req)
if err != nil {
    // Handle error
}
// req is now populated with LLM generation config

clone

func clone[M any](src M) M

deepCopy

func deepCopy(src, dst reflect.Value)

Important Implementation Details


Interaction with Other System Components


Visual Diagram

classDiagram
class basicRequestProcessor {
+InvocationContext ctx
+*LLMRequest req
+error
}
class clone {
+M src
+M
}
class deepCopy {
+reflect.Value src
+reflect.Value dst
+void
}
basicRequestProcessor --> clone : uses
clone --> deepCopy : calls

The diagram illustrates the functional relationships within the file: the main processor function calls clone to copy config data, which in turn calls deepCopy to recursively realize the deep copy operation.


References