Skip to content

Commit

Permalink
Remove mistral lib type dependency. (#1406)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrammel committed Apr 23, 2024
1 parent c056579 commit 1e84d6d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/brave-candles-hope.md
@@ -0,0 +1,5 @@
---
'ai': patch
---

Fix: remove mistral lib type dependency.
30 changes: 29 additions & 1 deletion packages/core/streams/mistral-stream.ts
@@ -1,11 +1,39 @@
import { ChatCompletionResponseChunk } from '@mistralai/mistralai';
import {
createCallbacksTransformer,
readableFromAsyncIterable,
type AIStreamCallbacksAndOptions,
} from './ai-stream';
import { createStreamDataTransformer } from './stream-data';

interface ChatCompletionResponseChunk {
id: string;
object: 'chat.completion.chunk';
created: number;
model: string;
choices: ChatCompletionResponseChunkChoice[];
}

interface ChatCompletionResponseChunkChoice {
index: number;
delta: {
role?: string;
content?: string;
tool_calls?: ToolCalls[];
};
finish_reason: string;
}

interface FunctionCall {
name: string;
arguments: string;
}

interface ToolCalls {
id: 'null';
type: 'function';
function: FunctionCall;
}

async function* streamable(stream: AsyncIterable<ChatCompletionResponseChunk>) {
for await (const chunk of stream) {
const content = chunk.choices[0]?.delta?.content;
Expand Down

0 comments on commit 1e84d6d

Please sign in to comment.