(
options: Pick<
PackAgentOptions,
"provider" | "modelId" | "apiProtocol" | "reasoning"
>,
modelRegistry?: Pick<ModelRegistry, "find">,
)
| 87 | } |
| 88 | |
| 89 | export function createCustomProviderModelConfig( |
| 90 | options: Pick< |
| 91 | PackAgentOptions, |
| 92 | "provider" | "modelId" | "apiProtocol" | "reasoning" |
| 93 | >, |
| 94 | modelRegistry?: Pick<ModelRegistry, "find">, |
| 95 | ): CustomProviderModelConfig { |
| 96 | const api = (options.apiProtocol ?? |
| 97 | "openai-completions") as CustomProviderModelConfig["api"]; |
| 98 | const registryModel = modelRegistry?.find(options.provider, options.modelId); |
| 99 | if (registryModel) { |
| 100 | const customModel: CustomProviderModelConfig = { |
| 101 | id: registryModel.id, |
| 102 | name: registryModel.name, |
| 103 | api, |
| 104 | reasoning: api === "openai-completions" ? false : registryModel.reasoning, |
| 105 | input: [...registryModel.input], |
| 106 | cost: { ...registryModel.cost }, |
| 107 | contextWindow: registryModel.contextWindow, |
| 108 | maxTokens: registryModel.maxTokens, |
| 109 | }; |
| 110 | |
| 111 | if (registryModel.thinkingLevelMap) { |
| 112 | customModel.thinkingLevelMap = { ...registryModel.thinkingLevelMap }; |
| 113 | } |
| 114 | if (registryModel.headers) { |
| 115 | customModel.headers = { ...registryModel.headers }; |
| 116 | } |
| 117 | if (registryModel.compat) { |
| 118 | customModel.compat = { |
| 119 | ...registryModel.compat, |
| 120 | } as CustomProviderModelConfig["compat"]; |
| 121 | } |
| 122 | |
| 123 | return customModel; |
| 124 | } |
| 125 | |
| 126 | return { |
| 127 | id: options.modelId, |
| 128 | name: options.modelId, |
| 129 | api, |
| 130 | reasoning: options.reasoning ?? false, |
| 131 | input: ["text", "image"] as Array<"text" | "image">, |
| 132 | cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, |
| 133 | contextWindow: 128000, |
| 134 | maxTokens: 4096, |
| 135 | }; |
| 136 | } |
| 137 | |
| 138 | export function readFrevanaSystemPrompts( |
| 139 | env: NodeJS.ProcessEnv = process.env, |
no outgoing calls
no test coverage detected