Generators Overview
pkgs/genx/generators manages the registration and selection of genx.Generator. The caller uses the pattern to select the Generator, and then executes the generation with the unified ModelContext -> Stream contract, without directly binding the specific model protocol.
Structure
| Modules | Responsibilities |
|---|---|
| OpenAI Adapter | Convert OpenAI-compatible Chat Completions to GenX message, stream, tool call and usage. |
| Gemini Adapter | Convert Gemini GenerateContent to the same GenX contract. |
Core structure and main function
| Symbol | Function |
|---|---|
Mux | Stores the route of pattern to Generator and complete the matching. |
NewMux | Create an independent Generator registry. |
Handle | Register the Generator with the default registry. |
GenerateStream | Select Generator and return the generated result Stream. |
Invoke | Request the model to call the specified FuncTool, and return the usage and parsed call. |
Generators only manage generating protocols and routes. Model configuration, credentials, tenants, and product catalog do not belong to this package.