Skip to content

Commit 1e84d6d

Browse files
authoredApr 23, 2024··
Remove mistral lib type dependency. (#1406)
1 parent c056579 commit 1e84d6d

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed
 

‎.changeset/brave-candles-hope.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'ai': patch
3+
---
4+
5+
Fix: remove mistral lib type dependency.

‎packages/core/streams/mistral-stream.ts

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,39 @@
1-
import { ChatCompletionResponseChunk } from '@mistralai/mistralai';
21
import {
32
createCallbacksTransformer,
43
readableFromAsyncIterable,
54
type AIStreamCallbacksAndOptions,
65
} from './ai-stream';
76
import { createStreamDataTransformer } from './stream-data';
87

8+
interface ChatCompletionResponseChunk {
9+
id: string;
10+
object: 'chat.completion.chunk';
11+
created: number;
12+
model: string;
13+
choices: ChatCompletionResponseChunkChoice[];
14+
}
15+
16+
interface ChatCompletionResponseChunkChoice {
17+
index: number;
18+
delta: {
19+
role?: string;
20+
content?: string;
21+
tool_calls?: ToolCalls[];
22+
};
23+
finish_reason: string;
24+
}
25+
26+
interface FunctionCall {
27+
name: string;
28+
arguments: string;
29+
}
30+
31+
interface ToolCalls {
32+
id: 'null';
33+
type: 'function';
34+
function: FunctionCall;
35+
}
36+
937
async function* streamable(stream: AsyncIterable<ChatCompletionResponseChunk>) {
1038
for await (const chunk of stream) {
1139
const content = chunk.choices[0]?.delta?.content;

0 commit comments

Comments
 (0)
Please sign in to comment.