| 119 | } |
| 120 | |
| 121 | func (p *Server) newModel( |
| 122 | ctx context.Context, |
| 123 | req modelClientRequest, |
| 124 | route resolvedModelRoute, |
| 125 | opts modelBuildOptions, |
| 126 | ) (fantasy.LanguageModel, error) { |
| 127 | switch route.kind { |
| 128 | case modelRouteKindDirect: |
| 129 | return p.newDirectModel(ctx, req, route.direct, opts) |
| 130 | case modelRouteKindAIGateway: |
| 131 | return p.newAIGatewayModel(ctx, req, route.aiGateway, opts) |
| 132 | default: |
| 133 | return nil, xerrors.New("model route is not configured") |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | func newLanguageModel( |
| 138 | providerHint string, |