| 124 | } |
| 125 | |
| 126 | private createModel(): OpenAIModel { |
| 127 | // Generate list of functions |
| 128 | const functions: ChatCompletionFunction[] = []; |
| 129 | for (const entry of this._functions.values()) { |
| 130 | functions.push(entry.schema); |
| 131 | } |
| 132 | |
| 133 | // Create an instance of a model |
| 134 | const modelOptions: OpenAIModelOptions = { |
| 135 | apiKey: this._index.keys!.apiKey, |
| 136 | completion_type: 'chat', |
| 137 | model: this._index.config!.model, |
| 138 | temperature: this._index.config!.temperature, |
| 139 | max_input_tokens: this._index.config!.max_input_tokens, |
| 140 | max_tokens: this._index.config!.max_tokens, |
| 141 | //logRequests: true |
| 142 | }; |
| 143 | |
| 144 | if (functions.length > 0) { |
| 145 | modelOptions.functions = functions; |
| 146 | } |
| 147 | |
| 148 | return new OpenAIModel(modelOptions); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | interface FunctionEntry { |