| 260 | setAdditionalHeaders(request, args, baseUrl); | 243 | setAdditionalHeaders(request, args, baseUrl); |
| 261 | | 244 | |
| 262 | const apiType = request.body.api_type; | 245 | const apiType = request.body.api_type; |
| 263 | const chatTemplateUrl = baseUrl + chat_template_endpoints[apiType]; | 246 | const propsUrl = baseUrl + "/props"; |
| 264 | const chatTemplateReply = await fetch(chatTemplateUrl, args); | 247 | const propsReply = await fetch(propsUrl, args); |
| 265 | | 248 | |
| 266 | if (!chatTemplateReply.ok) { | 249 | if (!propsReply.ok) { |
| 267 | console.log('Chat template endpoint is offline.'); | 250 | console.log('Properties endpoint is offline.'); |
| 268 | return response.status(400); | 251 | return response.status(400); |
| 269 | } | 252 | } |
| 270 | | 253 | |
| 271 | /** @type {any} */ | 254 | /** @type {any} */ |
| 272 | const chatTemplate = await chatTemplateReply.json(); | 255 | const props = await propsReply.json(); |
| 273 | // TEMPORARY: llama.cpp's /props endpoint includes a \u0000 at the end of the chat template, resulting in mismatching hashes | 256 | // TEMPORARY: llama.cpp's /props endpoint includes a \u0000 at the end of the chat template, resulting in mismatching hashes |
| 274 | if (apiType === TEXTGEN_TYPES.LLAMACPP && chatTemplate['chat_template'].endsWith('\u0000')) { | 257 | if (apiType === TEXTGEN_TYPES.LLAMACPP && props['chat_template'].endsWith('\u0000')) { |
| 275 | chatTemplate['chat_template'] = chatTemplate['chat_template'].slice(0, -1); | 258 | props['chat_template'] = props['chat_template'].slice(0, -1); |
| 276 | } | 259 | } |
| 277 | chatTemplate['chat_template_hash'] = createHash('sha256').update(chatTemplate['chat_template']).digest('hex'); | 260 | props['chat_template_hash'] = createHash('sha256').update(props['chat_template']).digest('hex'); |
| 278 | console.log(`We have chat template stuff: ${JSON.stringify(chatTemplate)}`); | 261 | console.log(`We have chat template stuff: ${JSON.stringify(props)}`); |
| 279 | return response.send(chatTemplate); | 262 | return response.send(props); |
| 280 | } catch (error) { | 263 | } catch (error) { |
| 281 | console.error(error); | 264 | console.error(error); |
| 282 | return response.status(500); | 265 | return response.status(500); |