|
7 | 7 | mapLangchainMessagesToOrchestrationMessages, |
8 | 8 | mapOutputToChatResult |
9 | 9 | } from './util.js'; |
| 10 | +import type { BaseLanguageModelInput } from '@langchain/core/language_models/base'; |
| 11 | +import type { Runnable, RunnableLike } from '@langchain/core/runnables'; |
10 | 12 | import type { CustomRequestConfig } from '@sap-ai-sdk/core'; |
11 | 13 | import type { OrchestrationMessageChunk } from './orchestration-message-chunk.js'; |
12 | 14 | import type { ChatResult } from '@langchain/core/outputs'; |
@@ -40,14 +42,21 @@ export class OrchestrationClient extends BaseChatModel< |
40 | 42 | } |
41 | 43 |
|
42 | 44 | /** |
43 | | - * Decisions: |
44 | | - * bind only supports ParsedCallOptions, we don't support arbitrary LLM options, only tool calls & default BaseLanguageModelCallOptions, e.g. stop ✅ |
45 | | - * this aligns with other vendors' client designs (e.g. openai, google) ✅ |
46 | | - * inputParams are a seperate call option, history = history ✅ |
47 | | - * Module results are part of our own message type, which extends AI Message to work with all other langchain functionality. ✅. |
48 | | - * |
49 | | - * For timeout, we need to apply our own middleware, it is not handled by langchain. ✅. |
| 45 | + * Create a new runnable sequence that runs each individual runnable in series, |
| 46 | + * piping the output of one runnable into another runnable or runnable-like. |
| 47 | + * @param coerceable - A runnable, function, or object whose values are functions or runnables. |
| 48 | + * @returns A new runnable sequence. |
50 | 49 | */ |
| 50 | + override pipe<NewRunOutput>( |
| 51 | + coerceable: RunnableLike<OrchestrationMessageChunk, NewRunOutput> |
| 52 | + ): Runnable<BaseLanguageModelInput, Exclude<NewRunOutput, Error>, OrchestrationCallOptions> { |
| 53 | + // Delegate to the superclass pipe method and narrow the type. |
| 54 | + return super.pipe(coerceable) as Runnable< |
| 55 | + BaseLanguageModelInput, |
| 56 | + Exclude<NewRunOutput, Error>, |
| 57 | + OrchestrationCallOptions |
| 58 | + >; |
| 59 | + } |
51 | 60 |
|
52 | 61 | override async _generate( |
53 | 62 | messages: BaseMessage[], |
|
0 commit comments