(request: ChatRequest)
| 155 | |
| 156 | /** The body, built in one place so the eval and the chat send the same bytes. */ |
| 157 | export function chatBody(request: ChatRequest): Record<string, unknown> { |
| 158 | return { |
| 159 | messages: [ |
| 160 | { role: 'system', content: request.system }, |
| 161 | { role: 'user', content: request.user }, |
| 162 | ], |
| 163 | temperature: CHAT_TEMPERATURE, |
| 164 | seed: CHAT_SEED, |
| 165 | repeat_penalty: CHAT_REPEAT_PENALTY, |
| 166 | max_tokens: request.maxTokens ?? CHAT_MAX_TOKENS, |
| 167 | stream: false, |
| 168 | ...(request.chatTemplateKwargs === undefined |
| 169 | ? {} |
| 170 | : { chat_template_kwargs: request.chatTemplateKwargs }), |
| 171 | ...(request.model === undefined || request.model.length === 0 |
| 172 | ? {} |
| 173 | : { model: request.model }), |
| 174 | }; |
| 175 | } |
| 176 | |
| 177 | /** Ask the sidecar once. Rejects with a {@link ChatError} and never with a string. */ |
| 178 | export async function askModel(request: ChatRequest): Promise<ChatReply> { |
no outgoing calls
no test coverage detected