(raw?: string)
| 172 | } |
| 173 | |
| 174 | function parseCustomHeaders(raw?: string): Record<string, string> { |
| 175 | if (!raw) return {}; |
| 176 | const headers: Record<string, string> = {}; |
| 177 | for (const line of raw.split('\n')) { |
| 178 | const trimmed = line.trim(); |
| 179 | if (!trimmed) continue; |
| 180 | const idx = trimmed.indexOf(':'); |
| 181 | if (idx > 0) { |
| 182 | const key = trimmed.slice(0, idx).trim().toLowerCase(); |
| 183 | const val = trimmed.slice(idx + 1).trim(); |
| 184 | headers[`x-custom-${key}`] = val; |
| 185 | } |
| 186 | } |
| 187 | return headers; |
| 188 | } |
| 189 | |
| 190 | export async function chat( |
| 191 | messages: ChatMessage[], |
no outgoing calls
no test coverage detected