🐛 Fix ky not working due to fetch rewriting by mistral package

Closes #1396
This commit is contained in:
Baptiste Arnaud
2024-04-03 14:35:18 +02:00
parent 6a4a43efb4
commit ef10f69f92
15 changed files with 28 additions and 14 deletions

View File

@@ -1,7 +1,6 @@
import { option, createAction } from '@typebot.io/forge'
import { isDefined } from '@typebot.io/lib'
import { auth } from '../auth'
import MistralClient from '@mistralai/mistralai'
import { parseMessages } from '../helpers/parseMessages'
import { OpenAIStream } from 'ai'
@@ -96,6 +95,7 @@ export const createChatCompletion = createAction({
id: 'fetchModels',
dependencies: [],
fetch: async ({ credentials }) => {
const MistralClient = (await import('@mistralai/mistralai')).default
const client = new MistralClient(credentials.apiKey)
const listModelsResponse = await client.listModels()
@@ -111,6 +111,7 @@ export const createChatCompletion = createAction({
run: {
server: async ({ credentials: { apiKey }, options, variables, logs }) => {
if (!options.model) return logs.add('No model selected')
const MistralClient = (await import('@mistralai/mistralai')).default
const client = new MistralClient(apiKey)
const response = await client.chat({
@@ -131,6 +132,7 @@ export const createChatCompletion = createAction({
)?.variableId,
run: async ({ credentials: { apiKey }, options, variables }) => {
if (!options.model) return
const MistralClient = (await import('@mistralai/mistralai')).default
const client = new MistralClient(apiKey)
const response = client.chatStream({

View File

@@ -13,7 +13,7 @@
"typescript": "5.3.2"
},
"dependencies": {
"@mistralai/mistralai": "0.0.10",
"@mistralai/mistralai": "0.1.3",
"ai": "3.0.12"
}
}