(left: ProviderOptions, right: ProviderOptions)
| 1524 | export const fromMessages = (messages: ReadonlyArray<Message>): Prompt => makePrompt(messages) |
| 1525 | |
| 1526 | const mergeOptions = (left: ProviderOptions, right: ProviderOptions): ProviderOptions => { |
| 1527 | const result: Record<string, ProviderOptions[string]> = { ...left } |
| 1528 | for (const [provider, options] of Object.entries(right)) { |
| 1529 | if (Predicate.isUndefined(options)) { |
| 1530 | continue |
| 1531 | } |
| 1532 | const merged: Record<string, unknown> = { ...result[provider] } |
| 1533 | for (const [key, value] of Object.entries(options)) { |
| 1534 | // Later chunks may omit values (e.g. `thoughtSignature: undefined`), so |
| 1535 | // avoid overwriting values received from earlier chunks |
| 1536 | if (Predicate.isNotUndefined(value)) { |
| 1537 | merged[key] = value |
| 1538 | } |
| 1539 | } |
| 1540 | result[provider] = merged |
| 1541 | } |
| 1542 | return result |
| 1543 | } |
| 1544 | |
| 1545 | /** |
| 1546 | * Creates a Prompt from the response parts of a previous interaction with a |
no test coverage detected