重写插件为V2格式:使用define+id+setup(ctx)+ctx.tool.transform注册工具
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*)
|
||||
if command -v cygpath > /dev/null 2>&1; then
|
||||
basedir=`cygpath -w "$basedir"`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../msgpackr-extract/bin/download-prebuilds.js" "$@"
|
||||
else
|
||||
exec node "$basedir/../msgpackr-extract/bin/download-prebuilds.js" "$@"
|
||||
fi
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\msgpackr-extract\bin\download-prebuilds.js" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../msgpackr-extract/bin/download-prebuilds.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../msgpackr-extract/bin/download-prebuilds.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../msgpackr-extract/bin/download-prebuilds.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../msgpackr-extract/bin/download-prebuilds.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*)
|
||||
if command -v cygpath > /dev/null 2>&1; then
|
||||
basedir=`cygpath -w "$basedir"`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../node-gyp-build-optional-packages/bin.js" "$@"
|
||||
else
|
||||
exec node "$basedir/../node-gyp-build-optional-packages/bin.js" "$@"
|
||||
fi
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*)
|
||||
if command -v cygpath > /dev/null 2>&1; then
|
||||
basedir=`cygpath -w "$basedir"`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../node-gyp-build-optional-packages/optional.js" "$@"
|
||||
else
|
||||
exec node "$basedir/../node-gyp-build-optional-packages/optional.js" "$@"
|
||||
fi
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\node-gyp-build-optional-packages\optional.js" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../node-gyp-build-optional-packages/optional.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../node-gyp-build-optional-packages/optional.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../node-gyp-build-optional-packages/optional.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../node-gyp-build-optional-packages/optional.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*)
|
||||
if command -v cygpath > /dev/null 2>&1; then
|
||||
basedir=`cygpath -w "$basedir"`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../node-gyp-build-optional-packages/build-test.js" "$@"
|
||||
else
|
||||
exec node "$basedir/../node-gyp-build-optional-packages/build-test.js" "$@"
|
||||
fi
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\node-gyp-build-optional-packages\build-test.js" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../node-gyp-build-optional-packages/build-test.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../node-gyp-build-optional-packages/build-test.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../node-gyp-build-optional-packages/build-test.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../node-gyp-build-optional-packages/build-test.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\node-gyp-build-optional-packages\bin.js" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../node-gyp-build-optional-packages/bin.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../node-gyp-build-optional-packages/bin.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../node-gyp-build-optional-packages/bin.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../node-gyp-build-optional-packages/bin.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*)
|
||||
if command -v cygpath > /dev/null 2>&1; then
|
||||
basedir=`cygpath -w "$basedir"`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../which/bin/node-which" "$@"
|
||||
else
|
||||
exec node "$basedir/../which/bin/node-which" "$@"
|
||||
fi
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\which\bin\node-which" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../which/bin/node-which" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../which/bin/node-which" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../which/bin/node-which" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../which/bin/node-which" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*)
|
||||
if command -v cygpath > /dev/null 2>&1; then
|
||||
basedir=`cygpath -w "$basedir"`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../typescript/bin/tsc" "$@"
|
||||
else
|
||||
exec node "$basedir/../typescript/bin/tsc" "$@"
|
||||
fi
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\typescript\bin\tsc" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../typescript/bin/tsc" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../typescript/bin/tsc" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../typescript/bin/tsc" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../typescript/bin/tsc" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*)
|
||||
if command -v cygpath > /dev/null 2>&1; then
|
||||
basedir=`cygpath -w "$basedir"`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
|
||||
else
|
||||
exec node "$basedir/../typescript/bin/tsserver" "$@"
|
||||
fi
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\typescript\bin\tsserver" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../typescript/bin/tsserver" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../typescript/bin/tsserver" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../typescript/bin/tsserver" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../typescript/bin/tsserver" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*)
|
||||
if command -v cygpath > /dev/null 2>&1; then
|
||||
basedir=`cygpath -w "$basedir"`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../uuid/dist-node/bin/uuid" "$@"
|
||||
else
|
||||
exec node "$basedir/../uuid/dist-node/bin/uuid" "$@"
|
||||
fi
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\uuid\dist-node\bin\uuid" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../uuid/dist-node/bin/uuid" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../uuid/dist-node/bin/uuid" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../uuid/dist-node/bin/uuid" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../uuid/dist-node/bin/uuid" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*)
|
||||
if command -v cygpath > /dev/null 2>&1; then
|
||||
basedir=`cygpath -w "$basedir"`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../yaml/bin.mjs" "$@"
|
||||
else
|
||||
exec node "$basedir/../yaml/bin.mjs" "$@"
|
||||
fi
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\yaml\bin.mjs" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../yaml/bin.mjs" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../yaml/bin.mjs" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../yaml/bin.mjs" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../yaml/bin.mjs" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+346
@@ -0,0 +1,346 @@
|
||||
{
|
||||
"name": "oc-session-all",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/@ai-sdk/provider": {
|
||||
"version": "3.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@ai-sdk/provider/-/provider-3.0.8.tgz",
|
||||
"integrity": "sha512-oGMAgGoQdBXbZqNG0Ze56CHjDZ1IDYOwGYxYjO5KLSlz5HiNQ9udIXsPZ61VWaHGZ5XW/jyjmr6t2xz2jGVwbQ==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"json-schema": "^0.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@msgpackr-extract/msgpackr-extract-win32-x64": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-win32-x64/-/msgpackr-extract-win32-x64-3.0.4.tgz",
|
||||
"integrity": "sha512-CmCXPQrkbwExx3j946/PtHWHbYJiCRBRDl4BlkRQcJB/YOwQxJRTpoo7aTsortjgoJ1x7opzTSxn7C+ASSLVjQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@opencode-ai/plugin": {
|
||||
"version": "1.18.31",
|
||||
"resolved": "https://registry.npmjs.org/@opencode-ai/plugin/-/plugin-1.18.31.tgz",
|
||||
"integrity": "sha512-Rdc1bPK06PByaGyGd0kf7JUZ4pTkexz2OOUNlqZWLpHOiMEZ+/rFGjt46ypZ3QwA697gNdWwwwQbHbKG5NMwGA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@ai-sdk/provider": "3.0.8",
|
||||
"@opencode-ai/sdk": "1.18.31",
|
||||
"effect": "4.0.0-beta.83",
|
||||
"zod": "4.1.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@opentui/core": ">=0.4.5",
|
||||
"@opentui/keymap": ">=0.4.5",
|
||||
"@opentui/solid": ">=0.4.5"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@opentui/core": {
|
||||
"optional": true
|
||||
},
|
||||
"@opentui/keymap": {
|
||||
"optional": true
|
||||
},
|
||||
"@opentui/solid": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@opencode-ai/sdk": {
|
||||
"version": "1.18.31",
|
||||
"resolved": "https://registry.npmjs.org/@opencode-ai/sdk/-/sdk-1.18.31.tgz",
|
||||
"integrity": "sha512-Raouthf8Lhe9edjvYeeSK7SgvdoU6bBjH9qV3f70dHoa6h+z0X2TMz/e22/wKp/StlFUZ4kIRpYYxFnY8/k01w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cross-spawn": "7.0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@standard-schema/spec": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz",
|
||||
"integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"path-key": "^3.1.0",
|
||||
"shebang-command": "^2.0.0",
|
||||
"which": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/detect-libc": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
|
||||
"integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/effect": {
|
||||
"version": "4.0.0-beta.83",
|
||||
"resolved": "https://registry.npmjs.org/effect/-/effect-4.0.0-beta.83.tgz",
|
||||
"integrity": "sha512-0wsak8RtgGAr9UWSbVDgJHZcUqMSvicHcvaZv1MbMM7MCGgW4Rn/137J1MHQbwYPcwYGxT/IqehFd+UbYuj78w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@standard-schema/spec": "^1.1.0",
|
||||
"fast-check": "^4.8.0",
|
||||
"find-my-way-ts": "^0.1.6",
|
||||
"ini": "^7.0.0",
|
||||
"kubernetes-types": "^1.30.0",
|
||||
"msgpackr": "^2.0.1",
|
||||
"multipasta": "^0.2.7",
|
||||
"toml": "^4.1.1",
|
||||
"uuid": "^14.0.0",
|
||||
"yaml": "^2.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fast-check": {
|
||||
"version": "4.10.2",
|
||||
"resolved": "https://registry.npmjs.org/fast-check/-/fast-check-4.10.2.tgz",
|
||||
"integrity": "sha512-iK2f+YrcmoeGqk6fA0ea2bptcu/itMIm4NfEozq6N25+aG6h7s5HZbB/k1aV7b5w5sFLMCbbtRUsTVR+BgC3xw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/dubzzz"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/fast-check"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pure-rand": "^8.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.17.0"
|
||||
}
|
||||
},
|
||||
"node_modules/find-my-way-ts": {
|
||||
"version": "0.1.6",
|
||||
"resolved": "https://registry.npmjs.org/find-my-way-ts/-/find-my-way-ts-0.1.6.tgz",
|
||||
"integrity": "sha512-a85L9ZoXtNAey3Y6Z+eBWW658kO/MwR7zIafkIUPUMf3isZG0NCs2pjW2wtjxAKuJPxMAsHUIP4ZPGv0o5gyTA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ini": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ini/-/ini-7.0.0.tgz",
|
||||
"integrity": "sha512-ifK0CgjALofS5bkrcTy4RaQ9Vx2Knf/eLeIO+NaswQEpH1UblrtTSCIvN71qQDMq0PeQ/SSPojvEJp9vvvfr+w==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/isexe": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/json-schema": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz",
|
||||
"integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==",
|
||||
"license": "(AFL-2.1 OR BSD-3-Clause)"
|
||||
},
|
||||
"node_modules/kubernetes-types": {
|
||||
"version": "1.30.0",
|
||||
"resolved": "https://registry.npmjs.org/kubernetes-types/-/kubernetes-types-1.30.0.tgz",
|
||||
"integrity": "sha512-Dew1okvhM/SQcIa2rcgujNndZwU8VnSapDgdxlYoB84ZlpAD43U6KLAFqYo17ykSFGHNPrg0qry0bP+GJd9v7Q==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/msgpackr": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/msgpackr/-/msgpackr-2.1.0.tgz",
|
||||
"integrity": "sha512-p/pBCVO63CsvvpkomUnNNag6+n38rULuDA6HHe70o2gtC8ODI52foF/4ko2qQcp6OiErJXTmrZeXmsGGHsIQNQ==",
|
||||
"license": "MIT",
|
||||
"optionalDependencies": {
|
||||
"msgpackr-extract": "^3.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/msgpackr-extract": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/msgpackr-extract/-/msgpackr-extract-3.0.4.tgz",
|
||||
"integrity": "sha512-4kmO/MdyUIkLIvTPr8VHLil4AtoKIoniWPIEk5+CDy0xnWC84azhSFmuJ7PxZdsYtiP5kEeQsORAVIeMgxT+Hw==",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"node-gyp-build-optional-packages": "5.2.2"
|
||||
},
|
||||
"bin": {
|
||||
"download-msgpackr-prebuilds": "bin/download-prebuilds.js"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@msgpackr-extract/msgpackr-extract-darwin-arm64": "3.0.4",
|
||||
"@msgpackr-extract/msgpackr-extract-darwin-x64": "3.0.4",
|
||||
"@msgpackr-extract/msgpackr-extract-linux-arm": "3.0.4",
|
||||
"@msgpackr-extract/msgpackr-extract-linux-arm64": "3.0.4",
|
||||
"@msgpackr-extract/msgpackr-extract-linux-x64": "3.0.4",
|
||||
"@msgpackr-extract/msgpackr-extract-win32-x64": "3.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/multipasta": {
|
||||
"version": "0.2.8",
|
||||
"resolved": "https://registry.npmjs.org/multipasta/-/multipasta-0.2.8.tgz",
|
||||
"integrity": "sha512-ZPWuMKyv0cSO29f7hozp+k6+crZbQijV8ipMvxNxRf2SwtYGTX1ZX89Kd20VV4H9Znonx+EQn+iy1wGQsJ+b+Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/node-gyp-build-optional-packages": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.2.2.tgz",
|
||||
"integrity": "sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"detect-libc": "^2.0.1"
|
||||
},
|
||||
"bin": {
|
||||
"node-gyp-build-optional-packages": "bin.js",
|
||||
"node-gyp-build-optional-packages-optional": "optional.js",
|
||||
"node-gyp-build-optional-packages-test": "build-test.js"
|
||||
}
|
||||
},
|
||||
"node_modules/path-key": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
|
||||
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/pure-rand": {
|
||||
"version": "8.4.2",
|
||||
"resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-8.4.2.tgz",
|
||||
"integrity": "sha512-vvuOGgcuPJAirlHvuQw1TrOiw7ptaIXXmIbNuiNOY6lNGJJH49PQ1Kj4nd783nPdQhQdicgOjVI2yI/9BD6/Ng==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/dubzzz"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/fast-check"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/shebang-command": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
|
||||
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"shebang-regex": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/shebang-regex": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
|
||||
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/toml": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/toml/-/toml-4.3.0.tgz",
|
||||
"integrity": "sha512-lVb8X9BsPVuH0M4BKeS91tXAmJvCjQ5UIyAbQFaxkKGyUFK2RPkhwaFSQH8vbpl1d23eu/IBH+dwVMHWaq9A5A==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "14.0.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.2.tgz",
|
||||
"integrity": "sha512-xZe/16rV4aa+HGSOCiY2YeLT1OybRLrrkL/Rqaq7p7GMVXjFh+6wN4oMYgjFmnSnhY8t6Xpdl2l9qmnHYuMHwQ==",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/broofa",
|
||||
"https://github.com/sponsors/ctavan"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "dist-node/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"isexe": "^2.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"node-which": "bin/node-which"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/yaml": {
|
||||
"version": "2.9.1",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz",
|
||||
"integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"yaml": "bin.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14.6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/eemeli"
|
||||
}
|
||||
},
|
||||
"node_modules/zod": {
|
||||
"version": "4.1.8",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-4.1.8.tgz",
|
||||
"integrity": "sha512-5R1P+WwQqmmMIEACyzSvo4JXHY5WiAFHRMg+zBZKgKS+Q1viRa0C1hmUKtHltoIFKtIdki3pRxkmpP74jnNYHQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+979
@@ -0,0 +1,979 @@
|
||||
# @ai-sdk/provider
|
||||
|
||||
## 3.0.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 7168375: feat (ai, provider): default global provider video model resolution
|
||||
|
||||
## 3.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 53f6731: feat (ai, provider): experimental generate video support
|
||||
|
||||
## 3.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 2810850: fix(ai): improve type validation error messages with field paths and entity identifiers
|
||||
|
||||
## 3.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 4de5a1d: chore: excluded tests from src folder in npm package
|
||||
|
||||
## 3.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 5c090e7: fix(ai): fix LanguageModelV2ProviderTool type
|
||||
|
||||
## 3.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1b11dcb: chore(ai): include sources in npm package
|
||||
|
||||
## 3.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- d937c8f: Add Image model middleware support via `wrapImageModel` and `ImageModelV3Middleware`.
|
||||
|
||||
## 3.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 863d34f: fix: trigger release to update `@latest`
|
||||
|
||||
## 3.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- dee8b05: ai SDK 6 beta
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 78928cb: release: start 5.1 beta
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0c3b58b: fix(provider): add specificationVersion to ProviderV3
|
||||
- 0adc679: feat(provider): shared spec v3
|
||||
- d1bdadb: Added reranking model
|
||||
- 046aa3b: feat(provider): speech model v3 spec
|
||||
- 8d9e8ad: chore(provider): remove generics from EmbeddingModelV3
|
||||
|
||||
Before
|
||||
|
||||
```ts
|
||||
model.textEmbeddingModel('my-model-id');
|
||||
```
|
||||
|
||||
After
|
||||
|
||||
```ts
|
||||
model.embeddingModel('my-model-id');
|
||||
```
|
||||
|
||||
- dce03c4: feat: tool input examples
|
||||
- 2625a04: feat(openai); update spec for mcp approval
|
||||
- 37c58a0: This release introduces `wrapEmbeddingModel`, a new helper that brings embedding model customization capabilities similar to `wrapLanguageModel`.
|
||||
- 2b0caef: feat(provider): add preliminary provider executed tool results to language model specification
|
||||
- 954c356: feat(openai): allow custom names for provider-defined tools
|
||||
- 544d4e8: chore(specification): rename v3 provider defined tool to provider tool
|
||||
- 0c4822d: feat: `EmbeddingModelV3`
|
||||
- 4c44a5b: fix(spec): allow `undefined` values in `JSONObject` type
|
||||
- e8109d3: feat: tool execution approval
|
||||
- ed329cb: feat: `Provider-V3`
|
||||
- 53f3368: feat(provider): support embedding model call warnings in specification
|
||||
- 3bd2689: feat: extended token usage
|
||||
- bb36798: fix(spec): `LanguageModelV3ToolResult["result"]` change from `unknown` to `NonNullable<JSONValue>`
|
||||
- 8dac895: feat: `LanguageModelV3`
|
||||
- a755db5: feat(provider): Add SharedV3Warning type
|
||||
- 475189e: chore(specification): rename EmbeddingModelCallOptions
|
||||
- 457318b: chore(provider,ai): switch to SharedV3Warning and unified warnings
|
||||
- b681d7d: feat: expose usage tokens for 'generateImage' function
|
||||
- db913bd: fix(google): add thought signature to gemini 3 pro image parts
|
||||
- 9061dc0: feat: image editing
|
||||
- 366f50b: chore(provider): add deprecated textEmbeddingModel and textEmbedding aliases
|
||||
- 81d4308: feat: provider-executed dynamic tools
|
||||
- 9549c9e: chore(specification): extract types
|
||||
- af3780b: chore(provider): remove providerExecuted from LanguageModelV3ToolResult
|
||||
- 522f6b8: feat: `ImageModelV3`
|
||||
- 10d819b: fix(packages/provider): fix CallWarning and allow strings as type
|
||||
- 3794514: feat: flexible tool output content support
|
||||
- cbf52cd: feat: expose raw finish reason
|
||||
- 1bd7d32: feat: tool-specific strict mode
|
||||
|
||||
## 3.0.0-beta.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 475189e: chore(specification): rename EmbeddingModelCallOptions
|
||||
|
||||
## 3.0.0-beta.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 2625a04: feat(openai); update spec for mcp approval
|
||||
|
||||
## 3.0.0-beta.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- cbf52cd: feat: expose raw finish reason
|
||||
|
||||
## 3.0.0-beta.29
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 9549c9e: chore(specification): extract types
|
||||
|
||||
## 3.0.0-beta.28
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 9061dc0: feat: image editing
|
||||
|
||||
## 3.0.0-beta.27
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 366f50b: chore(provider): add deprecated textEmbeddingModel and textEmbedding aliases
|
||||
|
||||
## 3.0.0-beta.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3bd2689: feat: extended token usage
|
||||
|
||||
## 3.0.0-beta.25
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 53f3368: feat(provider): support embedding model call warnings in specification
|
||||
|
||||
## 3.0.0-beta.24
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- dce03c4: feat: tool input examples
|
||||
|
||||
## 3.0.0-beta.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1bd7d32: feat: tool-specific strict mode
|
||||
|
||||
## 3.0.0-beta.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 544d4e8: chore(specification): rename v3 provider defined tool to provider tool
|
||||
|
||||
## 3.0.0-beta.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 954c356: feat(openai): allow custom names for provider-defined tools
|
||||
|
||||
## 3.0.0-beta.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 457318b: chore(provider,ai): switch to SharedV3Warning and unified warnings
|
||||
|
||||
## 3.0.0-beta.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 8d9e8ad: chore(provider): remove generics from EmbeddingModelV3
|
||||
|
||||
Before
|
||||
|
||||
```ts
|
||||
model.textEmbeddingModel('my-model-id');
|
||||
```
|
||||
|
||||
After
|
||||
|
||||
```ts
|
||||
model.embeddingModel('my-model-id');
|
||||
```
|
||||
|
||||
## 3.0.0-beta.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 10d819b: fix(packages/provider): fix CallWarning and allow strings as type
|
||||
|
||||
## 3.0.0-beta.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- db913bd: fix(google): add thought signature to gemini 3 pro image parts
|
||||
|
||||
## 3.0.0-beta.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b681d7d: feat: expose usage tokens for 'generateImage' function
|
||||
|
||||
## 3.0.0-beta.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- bb36798: fix(spec): `LanguageModelV3ToolResult["result"]` change from `unknown` to `NonNullable<JSONValue>`
|
||||
|
||||
## 3.0.0-beta.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- af3780b: chore(provider): remove providerExecuted from LanguageModelV3ToolResult
|
||||
|
||||
## 3.0.0-beta.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 37c58a0: This release introduces `wrapEmbeddingModel`, a new helper that brings embedding model customization capabilities similar to `wrapLanguageModel`.
|
||||
|
||||
## 3.0.0-beta.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- d1bdadb: Added reranking model
|
||||
|
||||
## 3.0.0-beta.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 4c44a5b: fix(spec): allow `undefined` values in `JSONObject` type
|
||||
|
||||
## 3.0.0-beta.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0c3b58b: fix(provider): add specificationVersion to ProviderV3
|
||||
|
||||
## 3.0.0-beta.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a755db5: feat(provider): Add SharedV3Warning type
|
||||
|
||||
## 3.0.0-beta.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3794514: feat: flexible tool output content support
|
||||
|
||||
## 3.0.0-beta.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 81d4308: feat: provider-executed dynamic tools
|
||||
|
||||
## 3.0.0-beta.6
|
||||
|
||||
### Major Changes
|
||||
|
||||
- dee8b05: ai SDK 6 beta
|
||||
|
||||
## 2.1.0-beta.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 046aa3b: feat(provider): speech model v3 spec
|
||||
- e8109d3: feat: tool execution approval
|
||||
|
||||
## 2.1.0-beta.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0adc679: feat(provider): shared spec v3
|
||||
- 2b0caef: feat(provider): add preliminary provider executed tool results to language model specification
|
||||
|
||||
## 2.1.0-beta.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 8dac895: feat: `LanguageModelV3`
|
||||
|
||||
## 2.1.0-beta.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ed329cb: feat: `Provider-V3`
|
||||
- 522f6b8: feat: `ImageModelV3`
|
||||
|
||||
## 2.1.0-beta.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0c4822d: feat: `EmbeddingModelV3`
|
||||
|
||||
## 2.1.0-beta.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 78928cb: release: start 5.1 beta
|
||||
|
||||
## 2.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 742b7be: feat: forward id, streaming start, streaming end of content blocks
|
||||
- 7cddb72: refactoring (provider): collapse provider defined tools into single definition
|
||||
- ccce59b: feat (provider): support changing provider, model, supportedUrls in middleware
|
||||
- e2b9e4b: feat (provider): add name for provider defined tools for future validation
|
||||
- 95857aa: chore: restructure language model supported urls
|
||||
- 6f6bb89: chore (provider): cleanup request and rawRequest (language model v2)
|
||||
- d1a1aa1: chore (provider): merge rawRequest into request (language model v2)
|
||||
- 63f9e9b: chore (provider,ai): tools have input/output instead of args,result
|
||||
- d5f588f: AI SDK 5
|
||||
- b6b43c7: chore: move warnings into stream-start part (spec)
|
||||
- 411e483: chore (provider): refactor usage (language model v2)
|
||||
- abf9a79: chore: rename mimeType to mediaType
|
||||
- 14c9410: chore: refactor file towards source pattern (spec)
|
||||
- e86be6f: chore: remove logprobs
|
||||
- 0d06df6: chore (ai): remove v1 providers
|
||||
- d9c98f4: chore: refactor reasoning parts (spec)
|
||||
- a3f768e: chore: restructure reasoning support
|
||||
- 7435eb5: feat: upgrade speech models to v2 specification
|
||||
- 0054544: chore: refactor source parts (spec)
|
||||
- 9e9c809: chore: refactor tool call and tool call delta parts (spec)
|
||||
- 32831c6: chore: refactor text parts (spec)
|
||||
- 6dc848c: chore (provider): remove image parts
|
||||
- d0f9495: chore: refactor file parts (spec)
|
||||
- 7979f7f: feat (provider): support reasoning tokens, cached input tokens, total token in usage information
|
||||
- 44f4aba: feat: upgrade transcription models to v2 specification
|
||||
- 7ea4132: chore: remove object generation mode
|
||||
- 023ba40: feat (provider): support arbitrary media types in tool results
|
||||
- e030615: chore (provider): remove prompt type from language model v2 spec
|
||||
- 5e57fae: refactoring (provider): restructure tool result output
|
||||
- c57e248: chore (provider): remove mode
|
||||
- 3795467: chore: return content array from doGenerate (spec)
|
||||
- 1766ede: chore: rename maxTokens to maxOutputTokens
|
||||
- 33f4a6a: chore (provider): rename providerMetadata inputs to providerOptions
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- dc714f3: release alpha.4
|
||||
- b5da06a: update to LanguageModelV2ProviderDefinedClientTool to add server side tool later on
|
||||
- 48d257a: release alpha.15
|
||||
- 0d2c085: chore (provider): tweak provider definition
|
||||
- 9222aeb: release alpha.8
|
||||
- e2aceaf: feat: add raw chunk support
|
||||
- 7b3ae3f: chore (provider): change getSupportedUrls to supportedUrls (language model v2)
|
||||
- a166433: feat: add transcription with experimental_transcribe
|
||||
- 26735b5: chore(embedding-model): add v2 interface
|
||||
- 443d8ec: feat(embedding-model-v2): add response body field
|
||||
- a8c8bd5: feat(embed-many): respect supportsParallelCalls & concurrency
|
||||
- 9bf7291: chore(providers/openai): enable structuredOutputs by default & switch to provider option
|
||||
- 2e13791: feat(anthropic): add server-side web search support
|
||||
- 472524a: spec (ai): add provider options to tools
|
||||
- dd3ff01: chore: add language setting to speechv2
|
||||
- 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2`
|
||||
- 0a87932: core (ai): change transcription model mimeType to mediaType
|
||||
- c4a2fec: chore (provider): extract shared provider options and metadata (spec)
|
||||
- 79457bd: chore (provider): extract LanguageModelV2File
|
||||
- 8aa9e20: feat: add speech with experimental_generateSpeech
|
||||
- 4617fab: chore(embedding-models): remove remaining settings
|
||||
- cb68df0: feat: add transcription and speech model support to provider registry
|
||||
- ad80501: chore (provider): allow both binary and base64 file content (spec)
|
||||
|
||||
Before
|
||||
|
||||
```ts
|
||||
import { convertUint8ArrayToBase64 } from '@ai-sdk/provider-utils';
|
||||
|
||||
// Had to manually convert binary data to base64
|
||||
const fileData = new Uint8Array([0, 1, 2, 3]);
|
||||
const filePart = {
|
||||
type: 'file',
|
||||
mediaType: 'application/pdf',
|
||||
data: convertUint8ArrayToBase64(fileData), // Required conversion
|
||||
};
|
||||
```
|
||||
|
||||
After
|
||||
|
||||
```ts
|
||||
// Can use binary data directly
|
||||
const fileData = new Uint8Array([0, 1, 2, 3]);
|
||||
const filePart = {
|
||||
type: 'file',
|
||||
mediaType: 'application/pdf',
|
||||
data: fileData, // Direct Uint8Array support
|
||||
};
|
||||
```
|
||||
|
||||
- 68ecf2f: release alpha.13
|
||||
- 6b98118: release alpha.3
|
||||
- 3f2f00c: feat: `ImageModelV2#maxImagesPerCall` can be set to a function that returns a `number` or `undefined`, optionally as a promise
|
||||
|
||||
pull request: https://github.com/vercel/ai/pull/6343
|
||||
|
||||
- 9bd5ab5: feat (provider): add providerMetadata to ImageModelV2 interface (#5977)
|
||||
|
||||
The `experimental_generateImage` method from the `ai` package now returnes revised prompts for OpenAI's image models.
|
||||
|
||||
```js
|
||||
const prompt = 'Santa Claus driving a Cadillac';
|
||||
|
||||
const { providerMetadata } = await experimental_generateImage({
|
||||
model: openai.image('dall-e-3'),
|
||||
prompt,
|
||||
});
|
||||
|
||||
const revisedPrompt = providerMetadata.openai.images[0]?.revisedPrompt;
|
||||
|
||||
console.log({
|
||||
prompt,
|
||||
revisedPrompt,
|
||||
});
|
||||
```
|
||||
|
||||
- 5c56081: release alpha.7
|
||||
- fd65bc6: chore(embedding-model-v2): rename rawResponse to response
|
||||
- 26535e0: release alpha.2
|
||||
- 393138b: feat(embedding-model-v2): add providerOptions
|
||||
- 7182d14: Remove `Experimental_LanguageModelV2Middleware` type
|
||||
- c1e6647: release alpha.11
|
||||
- 811dff3: release alpha.9
|
||||
- f10304b: feat(tool-calling): don't require the user to have to pass parameters
|
||||
- 27deb4d: feat (provider/gateway): Add providerMetadata to embeddings response
|
||||
- c4df419: release alpha.10
|
||||
|
||||
## 2.0.0-beta.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 27deb4d: feat (provider/gateway): Add providerMetadata to embeddings response
|
||||
|
||||
## 2.0.0-beta.1
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 742b7be: feat: forward id, streaming start, streaming end of content blocks
|
||||
- 7cddb72: refactoring (provider): collapse provider defined tools into single definition
|
||||
- ccce59b: feat (provider): support changing provider, model, supportedUrls in middleware
|
||||
- e2b9e4b: feat (provider): add name for provider defined tools for future validation
|
||||
- 0d06df6: chore (ai): remove v1 providers
|
||||
- 7435eb5: feat: upgrade speech models to v2 specification
|
||||
- 44f4aba: feat: upgrade transcription models to v2 specification
|
||||
- 023ba40: feat (provider): support arbitrary media types in tool results
|
||||
- 5e57fae: refactoring (provider): restructure tool result output
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 472524a: spec (ai): add provider options to tools
|
||||
- dd3ff01: chore: add language setting to speechv2
|
||||
- cb68df0: feat: add transcription and speech model support to provider registry
|
||||
|
||||
## 2.0.0-alpha.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 48d257a: release alpha.15
|
||||
|
||||
## 2.0.0-alpha.14
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 63f9e9b: chore (provider,ai): tools have input/output instead of args,result
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b5da06a: update to LanguageModelV2ProviderDefinedClientTool to add server side tool later on
|
||||
- 2e13791: feat(anthropic): add server-side web search support
|
||||
|
||||
## 2.0.0-alpha.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 68ecf2f: release alpha.13
|
||||
|
||||
## 2.0.0-alpha.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- e2aceaf: feat: add raw chunk support
|
||||
|
||||
## 2.0.0-alpha.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- c1e6647: release alpha.11
|
||||
|
||||
## 2.0.0-alpha.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- c4df419: release alpha.10
|
||||
|
||||
## 2.0.0-alpha.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 811dff3: release alpha.9
|
||||
|
||||
## 2.0.0-alpha.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 9222aeb: release alpha.8
|
||||
|
||||
## 2.0.0-alpha.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 5c56081: release alpha.7
|
||||
|
||||
## 2.0.0-alpha.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0d2c085: chore (provider): tweak provider definition
|
||||
|
||||
## 2.0.0-alpha.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- dc714f3: release alpha.4
|
||||
|
||||
## 2.0.0-alpha.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 6b98118: release alpha.3
|
||||
|
||||
## 2.0.0-alpha.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 26535e0: release alpha.2
|
||||
|
||||
## 2.0.0-alpha.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3f2f00c: feat: `ImageModelV2#maxImagesPerCall` can be set to a function that returns a `number` or `undefined`, optionally as a promise
|
||||
|
||||
pull request: https://github.com/vercel/ai/pull/6343
|
||||
|
||||
## 2.0.0-canary.14
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 7979f7f: feat (provider): support reasoning tokens, cached input tokens, total token in usage information
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a8c8bd5: feat(embed-many): respect supportsParallelCalls & concurrency
|
||||
|
||||
## 2.0.0-canary.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 9bd5ab5: feat (provider): add providerMetadata to ImageModelV2 interface (#5977)
|
||||
|
||||
The `experimental_generateImage` method from the `ai` package now returnes revised prompts for OpenAI's image models.
|
||||
|
||||
```js
|
||||
const prompt = 'Santa Claus driving a Cadillac';
|
||||
|
||||
const { providerMetadata } = await experimental_generateImage({
|
||||
model: openai.image('dall-e-3'),
|
||||
prompt,
|
||||
});
|
||||
|
||||
const revisedPrompt = providerMetadata.openai.images[0]?.revisedPrompt;
|
||||
|
||||
console.log({
|
||||
prompt,
|
||||
revisedPrompt,
|
||||
});
|
||||
```
|
||||
|
||||
## 2.0.0-canary.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 7b3ae3f: chore (provider): change getSupportedUrls to supportedUrls (language model v2)
|
||||
|
||||
## 2.0.0-canary.11
|
||||
|
||||
### Major Changes
|
||||
|
||||
- e030615: chore (provider): remove prompt type from language model v2 spec
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 9bf7291: chore(providers/openai): enable structuredOutputs by default & switch to provider option
|
||||
- 4617fab: chore(embedding-models): remove remaining settings
|
||||
|
||||
## 2.0.0-canary.10
|
||||
|
||||
### Major Changes
|
||||
|
||||
- a3f768e: chore: restructure reasoning support
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2`
|
||||
|
||||
## 2.0.0-canary.9
|
||||
|
||||
### Major Changes
|
||||
|
||||
- e86be6f: chore: remove logprobs
|
||||
|
||||
## 2.0.0-canary.8
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 95857aa: chore: restructure language model supported urls
|
||||
- 7ea4132: chore: remove object generation mode
|
||||
|
||||
## 2.0.0-canary.7
|
||||
|
||||
### Major Changes
|
||||
|
||||
- b6b43c7: chore: move warnings into stream-start part (spec)
|
||||
- 3795467: chore: return content array from doGenerate (spec)
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 8aa9e20: feat: add speech with experimental_generateSpeech
|
||||
|
||||
## 2.0.0-canary.6
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 14c9410: chore: refactor file towards source pattern (spec)
|
||||
- d9c98f4: chore: refactor reasoning parts (spec)
|
||||
- 0054544: chore: refactor source parts (spec)
|
||||
- 9e9c809: chore: refactor tool call and tool call delta parts (spec)
|
||||
- 32831c6: chore: refactor text parts (spec)
|
||||
- d0f9495: chore: refactor file parts (spec)
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 26735b5: chore(embedding-model): add v2 interface
|
||||
- 443d8ec: feat(embedding-model-v2): add response body field
|
||||
- c4a2fec: chore (provider): extract shared provider options and metadata (spec)
|
||||
- fd65bc6: chore(embedding-model-v2): rename rawResponse to response
|
||||
- 393138b: feat(embedding-model-v2): add providerOptions
|
||||
- 7182d14: Remove `Experimental_LanguageModelV2Middleware` type
|
||||
|
||||
## 2.0.0-canary.5
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 411e483: chore (provider): refactor usage (language model v2)
|
||||
- ad80501: chore (provider): allow both binary and base64 file content (spec)
|
||||
- 1766ede: chore: rename maxTokens to maxOutputTokens
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 79457bd: chore (provider): extract LanguageModelV2File
|
||||
- f10304b: feat(tool-calling): don't require the user to have to pass parameters
|
||||
|
||||
## 2.0.0-canary.4
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 6f6bb89: chore (provider): cleanup request and rawRequest (language model v2)
|
||||
|
||||
## 2.0.0-canary.3
|
||||
|
||||
### Major Changes
|
||||
|
||||
- d1a1aa1: chore (provider): merge rawRequest into request (language model v2)
|
||||
|
||||
## 2.0.0-canary.2
|
||||
|
||||
### Major Changes
|
||||
|
||||
- abf9a79: chore: rename mimeType to mediaType
|
||||
- 6dc848c: chore (provider): remove image parts
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a166433: feat: add transcription with experimental_transcribe
|
||||
- 0a87932: core (ai): change transcription model mimeType to mediaType
|
||||
|
||||
## 2.0.0-canary.1
|
||||
|
||||
### Major Changes
|
||||
|
||||
- c57e248: chore (provider): remove mode
|
||||
- 33f4a6a: chore (provider): rename providerMetadata inputs to providerOptions
|
||||
|
||||
## 2.0.0-canary.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- d5f588f: AI SDK 5
|
||||
|
||||
## 1.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 5bc638d: AI SDK 4.2
|
||||
|
||||
## 1.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0bd5bc6: feat (ai): support model-generated files
|
||||
|
||||
## 1.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 2e1101a: feat (provider/openai): pdf input support
|
||||
|
||||
## 1.0.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- e1d3d42: feat (ai): expose raw response body in generateText and generateObject
|
||||
|
||||
## 1.0.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ddf9740: feat (ai): add anthropic reasoning
|
||||
|
||||
## 1.0.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 2761f06: fix (ai/provider): publish with LanguageModelV1Source
|
||||
|
||||
## 1.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- d89c3b9: feat (provider): add image model support to provider specification
|
||||
|
||||
## 1.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3a58a2e: feat (ai/core): throw NoImageGeneratedError from generateImage when no predictions are returned.
|
||||
|
||||
## 1.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0a699f1: feat: add reasoning token support
|
||||
|
||||
## 1.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 19a2ce7: feat (provider): add message option to UnsupportedFunctionalityError
|
||||
- 6337688: feat: change image generation errors to warnings
|
||||
|
||||
## 1.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 5ed5e45: chore (config): Use ts-library.json tsconfig for no-UI libs.
|
||||
|
||||
## 1.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 09a9cab: feat (ai/core): add experimental generateImage function
|
||||
|
||||
## 1.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b446ae5: feat (provider): Define type for ObjectGenerationMode.
|
||||
|
||||
## 1.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- b469a7e: chore: remove isXXXError methods
|
||||
- c0ddc24: chore (ai): remove toJSON method from AI SDK errors
|
||||
|
||||
## 1.0.0-canary.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- b469a7e: chore: remove isXXXError methods
|
||||
- c0ddc24: chore (ai): remove toJSON method from AI SDK errors
|
||||
|
||||
## 0.0.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- aa98cdb: chore: more flexible dependency versioning
|
||||
- 1486128: feat: add supportsUrl to language model specification
|
||||
- 7b937c5: feat (provider-utils): improve id generator robustness
|
||||
- 3b1b69a: feat: provider-defined tools
|
||||
- 811a317: feat (ai/core): multi-part tool results (incl. images)
|
||||
|
||||
## 0.0.25
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b9b0d7b: feat (ai): access raw request body
|
||||
|
||||
## 0.0.24
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- d595d0d: feat (ai/core): file content parts
|
||||
|
||||
## 0.0.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 03313cd: feat (ai): expose response id, response model, response timestamp in telemetry and api
|
||||
- 3be7c1c: fix (provider/anthropic): support prompt caching on assistant messages
|
||||
|
||||
## 0.0.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 26515cb: feat (ai/provider): introduce ProviderV1 specification
|
||||
|
||||
## 0.0.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- f2c025e: feat (ai/core): prompt validation
|
||||
|
||||
## 0.0.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 6ac355e: feat (provider/anthropic): add cache control support
|
||||
|
||||
## 0.0.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- dd4a0f5: fix (ai/provider): remove invalid check in isJSONParseError
|
||||
|
||||
## 0.0.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 4bd27a9: chore (ai/provider): refactor type validation
|
||||
|
||||
## 0.0.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 029af4c: feat (ai/core): support schema name & description in generateObject & streamObject
|
||||
|
||||
## 0.0.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- d58517b: feat (ai/openai): structured outputs
|
||||
|
||||
## 0.0.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 96aed25: fix (ai/provider): release new version
|
||||
|
||||
## 0.0.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a8d1c9e9: feat (ai/core): parallel image download
|
||||
|
||||
## 0.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 2b9da0f0: feat (core): support stopSequences setting.
|
||||
- a5b58845: feat (core): support topK setting
|
||||
- 4aa8deb3: feat (provider): support responseFormat setting in provider api
|
||||
- 13b27ec6: chore (ai/core): remove grammar mode
|
||||
|
||||
## 0.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b7290943: feat (ai/core): add token usage to embed and embedMany
|
||||
|
||||
## 0.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 5edc6110: feat (provider): add headers support to language and embedding model spec
|
||||
|
||||
## 0.0.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 102ca22f: fix (@ai-sdk/provider): fix TypeValidationError.isTypeValidationError
|
||||
|
||||
## 0.0.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 09295e2e: feat (@ai-sdk/provider): add DownloadError
|
||||
|
||||
## 0.0.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- f39c0dd2: feat (provider): add toolChoice to language model specification
|
||||
|
||||
## 0.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 8e780288: feat (ai/provider): add "unknown" finish reason (for models that don't provide a finish reason)
|
||||
|
||||
## 0.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 6a50ac4: feat (provider): add additional error types
|
||||
|
||||
## 0.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0f6bc4e: feat (ai/core): add embed function
|
||||
|
||||
## 0.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 325ca55: feat (ai/core): improve image content part error message
|
||||
|
||||
## 0.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 41d5736: ai/core: re-expose language model types.
|
||||
|
||||
## 0.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- d6431ae: ai/core: add logprobs support (thanks @SamStenner for the contribution)
|
||||
- 25f3350: ai/core: add support for getting raw response headers.
|
||||
|
||||
## 0.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- eb150a6: ai/core: remove scaling of setting values (breaking change). If you were using the temperature, frequency penalty, or presence penalty settings, you need to update the providers and adjust the setting values.
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
Copyright 2023 Vercel, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
+1
@@ -0,0 +1 @@
|
||||
# AI SDK - Provider Language Model Specification
|
||||
+4030
File diff suppressed because it is too large
Load Diff
+4030
File diff suppressed because it is too large
Load Diff
+448
@@ -0,0 +1,448 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name14 in all)
|
||||
__defProp(target, name14, { get: all[name14], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
AISDKError: () => AISDKError,
|
||||
APICallError: () => APICallError,
|
||||
EmptyResponseBodyError: () => EmptyResponseBodyError,
|
||||
InvalidArgumentError: () => InvalidArgumentError,
|
||||
InvalidPromptError: () => InvalidPromptError,
|
||||
InvalidResponseDataError: () => InvalidResponseDataError,
|
||||
JSONParseError: () => JSONParseError,
|
||||
LoadAPIKeyError: () => LoadAPIKeyError,
|
||||
LoadSettingError: () => LoadSettingError,
|
||||
NoContentGeneratedError: () => NoContentGeneratedError,
|
||||
NoSuchModelError: () => NoSuchModelError,
|
||||
TooManyEmbeddingValuesForCallError: () => TooManyEmbeddingValuesForCallError,
|
||||
TypeValidationError: () => TypeValidationError,
|
||||
UnsupportedFunctionalityError: () => UnsupportedFunctionalityError,
|
||||
getErrorMessage: () => getErrorMessage,
|
||||
isJSONArray: () => isJSONArray,
|
||||
isJSONObject: () => isJSONObject,
|
||||
isJSONValue: () => isJSONValue
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
|
||||
// src/errors/ai-sdk-error.ts
|
||||
var marker = "vercel.ai.error";
|
||||
var symbol = Symbol.for(marker);
|
||||
var _a, _b;
|
||||
var AISDKError = class _AISDKError extends (_b = Error, _a = symbol, _b) {
|
||||
/**
|
||||
* Creates an AI SDK Error.
|
||||
*
|
||||
* @param {Object} params - The parameters for creating the error.
|
||||
* @param {string} params.name - The name of the error.
|
||||
* @param {string} params.message - The error message.
|
||||
* @param {unknown} [params.cause] - The underlying cause of the error.
|
||||
*/
|
||||
constructor({
|
||||
name: name14,
|
||||
message,
|
||||
cause
|
||||
}) {
|
||||
super(message);
|
||||
this[_a] = true;
|
||||
this.name = name14;
|
||||
this.cause = cause;
|
||||
}
|
||||
/**
|
||||
* Checks if the given error is an AI SDK Error.
|
||||
* @param {unknown} error - The error to check.
|
||||
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
||||
*/
|
||||
static isInstance(error) {
|
||||
return _AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
static hasMarker(error, marker15) {
|
||||
const markerSymbol = Symbol.for(marker15);
|
||||
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/api-call-error.ts
|
||||
var name = "AI_APICallError";
|
||||
var marker2 = `vercel.ai.error.${name}`;
|
||||
var symbol2 = Symbol.for(marker2);
|
||||
var _a2, _b2;
|
||||
var APICallError = class extends (_b2 = AISDKError, _a2 = symbol2, _b2) {
|
||||
constructor({
|
||||
message,
|
||||
url,
|
||||
requestBodyValues,
|
||||
statusCode,
|
||||
responseHeaders,
|
||||
responseBody,
|
||||
cause,
|
||||
isRetryable = statusCode != null && (statusCode === 408 || // request timeout
|
||||
statusCode === 409 || // conflict
|
||||
statusCode === 429 || // too many requests
|
||||
statusCode >= 500),
|
||||
// server error
|
||||
data
|
||||
}) {
|
||||
super({ name, message, cause });
|
||||
this[_a2] = true;
|
||||
this.url = url;
|
||||
this.requestBodyValues = requestBodyValues;
|
||||
this.statusCode = statusCode;
|
||||
this.responseHeaders = responseHeaders;
|
||||
this.responseBody = responseBody;
|
||||
this.isRetryable = isRetryable;
|
||||
this.data = data;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker2);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/empty-response-body-error.ts
|
||||
var name2 = "AI_EmptyResponseBodyError";
|
||||
var marker3 = `vercel.ai.error.${name2}`;
|
||||
var symbol3 = Symbol.for(marker3);
|
||||
var _a3, _b3;
|
||||
var EmptyResponseBodyError = class extends (_b3 = AISDKError, _a3 = symbol3, _b3) {
|
||||
// used in isInstance
|
||||
constructor({ message = "Empty response body" } = {}) {
|
||||
super({ name: name2, message });
|
||||
this[_a3] = true;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker3);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/get-error-message.ts
|
||||
function getErrorMessage(error) {
|
||||
if (error == null) {
|
||||
return "unknown error";
|
||||
}
|
||||
if (typeof error === "string") {
|
||||
return error;
|
||||
}
|
||||
if (error instanceof Error) {
|
||||
return error.message;
|
||||
}
|
||||
return JSON.stringify(error);
|
||||
}
|
||||
|
||||
// src/errors/invalid-argument-error.ts
|
||||
var name3 = "AI_InvalidArgumentError";
|
||||
var marker4 = `vercel.ai.error.${name3}`;
|
||||
var symbol4 = Symbol.for(marker4);
|
||||
var _a4, _b4;
|
||||
var InvalidArgumentError = class extends (_b4 = AISDKError, _a4 = symbol4, _b4) {
|
||||
constructor({
|
||||
message,
|
||||
cause,
|
||||
argument
|
||||
}) {
|
||||
super({ name: name3, message, cause });
|
||||
this[_a4] = true;
|
||||
this.argument = argument;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker4);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/invalid-prompt-error.ts
|
||||
var name4 = "AI_InvalidPromptError";
|
||||
var marker5 = `vercel.ai.error.${name4}`;
|
||||
var symbol5 = Symbol.for(marker5);
|
||||
var _a5, _b5;
|
||||
var InvalidPromptError = class extends (_b5 = AISDKError, _a5 = symbol5, _b5) {
|
||||
constructor({
|
||||
prompt,
|
||||
message,
|
||||
cause
|
||||
}) {
|
||||
super({ name: name4, message: `Invalid prompt: ${message}`, cause });
|
||||
this[_a5] = true;
|
||||
this.prompt = prompt;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker5);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/invalid-response-data-error.ts
|
||||
var name5 = "AI_InvalidResponseDataError";
|
||||
var marker6 = `vercel.ai.error.${name5}`;
|
||||
var symbol6 = Symbol.for(marker6);
|
||||
var _a6, _b6;
|
||||
var InvalidResponseDataError = class extends (_b6 = AISDKError, _a6 = symbol6, _b6) {
|
||||
constructor({
|
||||
data,
|
||||
message = `Invalid response data: ${JSON.stringify(data)}.`
|
||||
}) {
|
||||
super({ name: name5, message });
|
||||
this[_a6] = true;
|
||||
this.data = data;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker6);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/json-parse-error.ts
|
||||
var name6 = "AI_JSONParseError";
|
||||
var marker7 = `vercel.ai.error.${name6}`;
|
||||
var symbol7 = Symbol.for(marker7);
|
||||
var _a7, _b7;
|
||||
var JSONParseError = class extends (_b7 = AISDKError, _a7 = symbol7, _b7) {
|
||||
constructor({ text, cause }) {
|
||||
super({
|
||||
name: name6,
|
||||
message: `JSON parsing failed: Text: ${text}.
|
||||
Error message: ${getErrorMessage(cause)}`,
|
||||
cause
|
||||
});
|
||||
this[_a7] = true;
|
||||
this.text = text;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker7);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/load-api-key-error.ts
|
||||
var name7 = "AI_LoadAPIKeyError";
|
||||
var marker8 = `vercel.ai.error.${name7}`;
|
||||
var symbol8 = Symbol.for(marker8);
|
||||
var _a8, _b8;
|
||||
var LoadAPIKeyError = class extends (_b8 = AISDKError, _a8 = symbol8, _b8) {
|
||||
// used in isInstance
|
||||
constructor({ message }) {
|
||||
super({ name: name7, message });
|
||||
this[_a8] = true;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker8);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/load-setting-error.ts
|
||||
var name8 = "AI_LoadSettingError";
|
||||
var marker9 = `vercel.ai.error.${name8}`;
|
||||
var symbol9 = Symbol.for(marker9);
|
||||
var _a9, _b9;
|
||||
var LoadSettingError = class extends (_b9 = AISDKError, _a9 = symbol9, _b9) {
|
||||
// used in isInstance
|
||||
constructor({ message }) {
|
||||
super({ name: name8, message });
|
||||
this[_a9] = true;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker9);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/no-content-generated-error.ts
|
||||
var name9 = "AI_NoContentGeneratedError";
|
||||
var marker10 = `vercel.ai.error.${name9}`;
|
||||
var symbol10 = Symbol.for(marker10);
|
||||
var _a10, _b10;
|
||||
var NoContentGeneratedError = class extends (_b10 = AISDKError, _a10 = symbol10, _b10) {
|
||||
// used in isInstance
|
||||
constructor({
|
||||
message = "No content generated."
|
||||
} = {}) {
|
||||
super({ name: name9, message });
|
||||
this[_a10] = true;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker10);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/no-such-model-error.ts
|
||||
var name10 = "AI_NoSuchModelError";
|
||||
var marker11 = `vercel.ai.error.${name10}`;
|
||||
var symbol11 = Symbol.for(marker11);
|
||||
var _a11, _b11;
|
||||
var NoSuchModelError = class extends (_b11 = AISDKError, _a11 = symbol11, _b11) {
|
||||
constructor({
|
||||
errorName = name10,
|
||||
modelId,
|
||||
modelType,
|
||||
message = `No such ${modelType}: ${modelId}`
|
||||
}) {
|
||||
super({ name: errorName, message });
|
||||
this[_a11] = true;
|
||||
this.modelId = modelId;
|
||||
this.modelType = modelType;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker11);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/too-many-embedding-values-for-call-error.ts
|
||||
var name11 = "AI_TooManyEmbeddingValuesForCallError";
|
||||
var marker12 = `vercel.ai.error.${name11}`;
|
||||
var symbol12 = Symbol.for(marker12);
|
||||
var _a12, _b12;
|
||||
var TooManyEmbeddingValuesForCallError = class extends (_b12 = AISDKError, _a12 = symbol12, _b12) {
|
||||
constructor(options) {
|
||||
super({
|
||||
name: name11,
|
||||
message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`
|
||||
});
|
||||
this[_a12] = true;
|
||||
this.provider = options.provider;
|
||||
this.modelId = options.modelId;
|
||||
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
||||
this.values = options.values;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker12);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/type-validation-error.ts
|
||||
var name12 = "AI_TypeValidationError";
|
||||
var marker13 = `vercel.ai.error.${name12}`;
|
||||
var symbol13 = Symbol.for(marker13);
|
||||
var _a13, _b13;
|
||||
var TypeValidationError = class _TypeValidationError extends (_b13 = AISDKError, _a13 = symbol13, _b13) {
|
||||
constructor({
|
||||
value,
|
||||
cause,
|
||||
context
|
||||
}) {
|
||||
let contextPrefix = "Type validation failed";
|
||||
if (context == null ? void 0 : context.field) {
|
||||
contextPrefix += ` for ${context.field}`;
|
||||
}
|
||||
if ((context == null ? void 0 : context.entityName) || (context == null ? void 0 : context.entityId)) {
|
||||
contextPrefix += " (";
|
||||
const parts = [];
|
||||
if (context.entityName) {
|
||||
parts.push(context.entityName);
|
||||
}
|
||||
if (context.entityId) {
|
||||
parts.push(`id: "${context.entityId}"`);
|
||||
}
|
||||
contextPrefix += parts.join(", ");
|
||||
contextPrefix += ")";
|
||||
}
|
||||
super({
|
||||
name: name12,
|
||||
message: `${contextPrefix}: Value: ${JSON.stringify(value)}.
|
||||
Error message: ${getErrorMessage(cause)}`,
|
||||
cause
|
||||
});
|
||||
this[_a13] = true;
|
||||
this.value = value;
|
||||
this.context = context;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker13);
|
||||
}
|
||||
/**
|
||||
* Wraps an error into a TypeValidationError.
|
||||
* If the cause is already a TypeValidationError with the same value and context, it returns the cause.
|
||||
* Otherwise, it creates a new TypeValidationError.
|
||||
*
|
||||
* @param {Object} params - The parameters for wrapping the error.
|
||||
* @param {unknown} params.value - The value that failed validation.
|
||||
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
||||
* @param {TypeValidationContext} params.context - Optional context about what is being validated.
|
||||
* @returns {TypeValidationError} A TypeValidationError instance.
|
||||
*/
|
||||
static wrap({
|
||||
value,
|
||||
cause,
|
||||
context
|
||||
}) {
|
||||
var _a15, _b15, _c;
|
||||
if (_TypeValidationError.isInstance(cause) && cause.value === value && ((_a15 = cause.context) == null ? void 0 : _a15.field) === (context == null ? void 0 : context.field) && ((_b15 = cause.context) == null ? void 0 : _b15.entityName) === (context == null ? void 0 : context.entityName) && ((_c = cause.context) == null ? void 0 : _c.entityId) === (context == null ? void 0 : context.entityId)) {
|
||||
return cause;
|
||||
}
|
||||
return new _TypeValidationError({ value, cause, context });
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/unsupported-functionality-error.ts
|
||||
var name13 = "AI_UnsupportedFunctionalityError";
|
||||
var marker14 = `vercel.ai.error.${name13}`;
|
||||
var symbol14 = Symbol.for(marker14);
|
||||
var _a14, _b14;
|
||||
var UnsupportedFunctionalityError = class extends (_b14 = AISDKError, _a14 = symbol14, _b14) {
|
||||
constructor({
|
||||
functionality,
|
||||
message = `'${functionality}' functionality not supported.`
|
||||
}) {
|
||||
super({ name: name13, message });
|
||||
this[_a14] = true;
|
||||
this.functionality = functionality;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker14);
|
||||
}
|
||||
};
|
||||
|
||||
// src/json-value/is-json.ts
|
||||
function isJSONValue(value) {
|
||||
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
||||
return true;
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
return value.every(isJSONValue);
|
||||
}
|
||||
if (typeof value === "object") {
|
||||
return Object.entries(value).every(
|
||||
([key, val]) => typeof key === "string" && (val === void 0 || isJSONValue(val))
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isJSONArray(value) {
|
||||
return Array.isArray(value) && value.every(isJSONValue);
|
||||
}
|
||||
function isJSONObject(value) {
|
||||
return value != null && typeof value === "object" && Object.entries(value).every(
|
||||
([key, val]) => typeof key === "string" && (val === void 0 || isJSONValue(val))
|
||||
);
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
AISDKError,
|
||||
APICallError,
|
||||
EmptyResponseBodyError,
|
||||
InvalidArgumentError,
|
||||
InvalidPromptError,
|
||||
InvalidResponseDataError,
|
||||
JSONParseError,
|
||||
LoadAPIKeyError,
|
||||
LoadSettingError,
|
||||
NoContentGeneratedError,
|
||||
NoSuchModelError,
|
||||
TooManyEmbeddingValuesForCallError,
|
||||
TypeValidationError,
|
||||
UnsupportedFunctionalityError,
|
||||
getErrorMessage,
|
||||
isJSONArray,
|
||||
isJSONObject,
|
||||
isJSONValue
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+404
@@ -0,0 +1,404 @@
|
||||
// src/errors/ai-sdk-error.ts
|
||||
var marker = "vercel.ai.error";
|
||||
var symbol = Symbol.for(marker);
|
||||
var _a, _b;
|
||||
var AISDKError = class _AISDKError extends (_b = Error, _a = symbol, _b) {
|
||||
/**
|
||||
* Creates an AI SDK Error.
|
||||
*
|
||||
* @param {Object} params - The parameters for creating the error.
|
||||
* @param {string} params.name - The name of the error.
|
||||
* @param {string} params.message - The error message.
|
||||
* @param {unknown} [params.cause] - The underlying cause of the error.
|
||||
*/
|
||||
constructor({
|
||||
name: name14,
|
||||
message,
|
||||
cause
|
||||
}) {
|
||||
super(message);
|
||||
this[_a] = true;
|
||||
this.name = name14;
|
||||
this.cause = cause;
|
||||
}
|
||||
/**
|
||||
* Checks if the given error is an AI SDK Error.
|
||||
* @param {unknown} error - The error to check.
|
||||
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
||||
*/
|
||||
static isInstance(error) {
|
||||
return _AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
static hasMarker(error, marker15) {
|
||||
const markerSymbol = Symbol.for(marker15);
|
||||
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/api-call-error.ts
|
||||
var name = "AI_APICallError";
|
||||
var marker2 = `vercel.ai.error.${name}`;
|
||||
var symbol2 = Symbol.for(marker2);
|
||||
var _a2, _b2;
|
||||
var APICallError = class extends (_b2 = AISDKError, _a2 = symbol2, _b2) {
|
||||
constructor({
|
||||
message,
|
||||
url,
|
||||
requestBodyValues,
|
||||
statusCode,
|
||||
responseHeaders,
|
||||
responseBody,
|
||||
cause,
|
||||
isRetryable = statusCode != null && (statusCode === 408 || // request timeout
|
||||
statusCode === 409 || // conflict
|
||||
statusCode === 429 || // too many requests
|
||||
statusCode >= 500),
|
||||
// server error
|
||||
data
|
||||
}) {
|
||||
super({ name, message, cause });
|
||||
this[_a2] = true;
|
||||
this.url = url;
|
||||
this.requestBodyValues = requestBodyValues;
|
||||
this.statusCode = statusCode;
|
||||
this.responseHeaders = responseHeaders;
|
||||
this.responseBody = responseBody;
|
||||
this.isRetryable = isRetryable;
|
||||
this.data = data;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker2);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/empty-response-body-error.ts
|
||||
var name2 = "AI_EmptyResponseBodyError";
|
||||
var marker3 = `vercel.ai.error.${name2}`;
|
||||
var symbol3 = Symbol.for(marker3);
|
||||
var _a3, _b3;
|
||||
var EmptyResponseBodyError = class extends (_b3 = AISDKError, _a3 = symbol3, _b3) {
|
||||
// used in isInstance
|
||||
constructor({ message = "Empty response body" } = {}) {
|
||||
super({ name: name2, message });
|
||||
this[_a3] = true;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker3);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/get-error-message.ts
|
||||
function getErrorMessage(error) {
|
||||
if (error == null) {
|
||||
return "unknown error";
|
||||
}
|
||||
if (typeof error === "string") {
|
||||
return error;
|
||||
}
|
||||
if (error instanceof Error) {
|
||||
return error.message;
|
||||
}
|
||||
return JSON.stringify(error);
|
||||
}
|
||||
|
||||
// src/errors/invalid-argument-error.ts
|
||||
var name3 = "AI_InvalidArgumentError";
|
||||
var marker4 = `vercel.ai.error.${name3}`;
|
||||
var symbol4 = Symbol.for(marker4);
|
||||
var _a4, _b4;
|
||||
var InvalidArgumentError = class extends (_b4 = AISDKError, _a4 = symbol4, _b4) {
|
||||
constructor({
|
||||
message,
|
||||
cause,
|
||||
argument
|
||||
}) {
|
||||
super({ name: name3, message, cause });
|
||||
this[_a4] = true;
|
||||
this.argument = argument;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker4);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/invalid-prompt-error.ts
|
||||
var name4 = "AI_InvalidPromptError";
|
||||
var marker5 = `vercel.ai.error.${name4}`;
|
||||
var symbol5 = Symbol.for(marker5);
|
||||
var _a5, _b5;
|
||||
var InvalidPromptError = class extends (_b5 = AISDKError, _a5 = symbol5, _b5) {
|
||||
constructor({
|
||||
prompt,
|
||||
message,
|
||||
cause
|
||||
}) {
|
||||
super({ name: name4, message: `Invalid prompt: ${message}`, cause });
|
||||
this[_a5] = true;
|
||||
this.prompt = prompt;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker5);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/invalid-response-data-error.ts
|
||||
var name5 = "AI_InvalidResponseDataError";
|
||||
var marker6 = `vercel.ai.error.${name5}`;
|
||||
var symbol6 = Symbol.for(marker6);
|
||||
var _a6, _b6;
|
||||
var InvalidResponseDataError = class extends (_b6 = AISDKError, _a6 = symbol6, _b6) {
|
||||
constructor({
|
||||
data,
|
||||
message = `Invalid response data: ${JSON.stringify(data)}.`
|
||||
}) {
|
||||
super({ name: name5, message });
|
||||
this[_a6] = true;
|
||||
this.data = data;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker6);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/json-parse-error.ts
|
||||
var name6 = "AI_JSONParseError";
|
||||
var marker7 = `vercel.ai.error.${name6}`;
|
||||
var symbol7 = Symbol.for(marker7);
|
||||
var _a7, _b7;
|
||||
var JSONParseError = class extends (_b7 = AISDKError, _a7 = symbol7, _b7) {
|
||||
constructor({ text, cause }) {
|
||||
super({
|
||||
name: name6,
|
||||
message: `JSON parsing failed: Text: ${text}.
|
||||
Error message: ${getErrorMessage(cause)}`,
|
||||
cause
|
||||
});
|
||||
this[_a7] = true;
|
||||
this.text = text;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker7);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/load-api-key-error.ts
|
||||
var name7 = "AI_LoadAPIKeyError";
|
||||
var marker8 = `vercel.ai.error.${name7}`;
|
||||
var symbol8 = Symbol.for(marker8);
|
||||
var _a8, _b8;
|
||||
var LoadAPIKeyError = class extends (_b8 = AISDKError, _a8 = symbol8, _b8) {
|
||||
// used in isInstance
|
||||
constructor({ message }) {
|
||||
super({ name: name7, message });
|
||||
this[_a8] = true;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker8);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/load-setting-error.ts
|
||||
var name8 = "AI_LoadSettingError";
|
||||
var marker9 = `vercel.ai.error.${name8}`;
|
||||
var symbol9 = Symbol.for(marker9);
|
||||
var _a9, _b9;
|
||||
var LoadSettingError = class extends (_b9 = AISDKError, _a9 = symbol9, _b9) {
|
||||
// used in isInstance
|
||||
constructor({ message }) {
|
||||
super({ name: name8, message });
|
||||
this[_a9] = true;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker9);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/no-content-generated-error.ts
|
||||
var name9 = "AI_NoContentGeneratedError";
|
||||
var marker10 = `vercel.ai.error.${name9}`;
|
||||
var symbol10 = Symbol.for(marker10);
|
||||
var _a10, _b10;
|
||||
var NoContentGeneratedError = class extends (_b10 = AISDKError, _a10 = symbol10, _b10) {
|
||||
// used in isInstance
|
||||
constructor({
|
||||
message = "No content generated."
|
||||
} = {}) {
|
||||
super({ name: name9, message });
|
||||
this[_a10] = true;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker10);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/no-such-model-error.ts
|
||||
var name10 = "AI_NoSuchModelError";
|
||||
var marker11 = `vercel.ai.error.${name10}`;
|
||||
var symbol11 = Symbol.for(marker11);
|
||||
var _a11, _b11;
|
||||
var NoSuchModelError = class extends (_b11 = AISDKError, _a11 = symbol11, _b11) {
|
||||
constructor({
|
||||
errorName = name10,
|
||||
modelId,
|
||||
modelType,
|
||||
message = `No such ${modelType}: ${modelId}`
|
||||
}) {
|
||||
super({ name: errorName, message });
|
||||
this[_a11] = true;
|
||||
this.modelId = modelId;
|
||||
this.modelType = modelType;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker11);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/too-many-embedding-values-for-call-error.ts
|
||||
var name11 = "AI_TooManyEmbeddingValuesForCallError";
|
||||
var marker12 = `vercel.ai.error.${name11}`;
|
||||
var symbol12 = Symbol.for(marker12);
|
||||
var _a12, _b12;
|
||||
var TooManyEmbeddingValuesForCallError = class extends (_b12 = AISDKError, _a12 = symbol12, _b12) {
|
||||
constructor(options) {
|
||||
super({
|
||||
name: name11,
|
||||
message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`
|
||||
});
|
||||
this[_a12] = true;
|
||||
this.provider = options.provider;
|
||||
this.modelId = options.modelId;
|
||||
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
||||
this.values = options.values;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker12);
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/type-validation-error.ts
|
||||
var name12 = "AI_TypeValidationError";
|
||||
var marker13 = `vercel.ai.error.${name12}`;
|
||||
var symbol13 = Symbol.for(marker13);
|
||||
var _a13, _b13;
|
||||
var TypeValidationError = class _TypeValidationError extends (_b13 = AISDKError, _a13 = symbol13, _b13) {
|
||||
constructor({
|
||||
value,
|
||||
cause,
|
||||
context
|
||||
}) {
|
||||
let contextPrefix = "Type validation failed";
|
||||
if (context == null ? void 0 : context.field) {
|
||||
contextPrefix += ` for ${context.field}`;
|
||||
}
|
||||
if ((context == null ? void 0 : context.entityName) || (context == null ? void 0 : context.entityId)) {
|
||||
contextPrefix += " (";
|
||||
const parts = [];
|
||||
if (context.entityName) {
|
||||
parts.push(context.entityName);
|
||||
}
|
||||
if (context.entityId) {
|
||||
parts.push(`id: "${context.entityId}"`);
|
||||
}
|
||||
contextPrefix += parts.join(", ");
|
||||
contextPrefix += ")";
|
||||
}
|
||||
super({
|
||||
name: name12,
|
||||
message: `${contextPrefix}: Value: ${JSON.stringify(value)}.
|
||||
Error message: ${getErrorMessage(cause)}`,
|
||||
cause
|
||||
});
|
||||
this[_a13] = true;
|
||||
this.value = value;
|
||||
this.context = context;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker13);
|
||||
}
|
||||
/**
|
||||
* Wraps an error into a TypeValidationError.
|
||||
* If the cause is already a TypeValidationError with the same value and context, it returns the cause.
|
||||
* Otherwise, it creates a new TypeValidationError.
|
||||
*
|
||||
* @param {Object} params - The parameters for wrapping the error.
|
||||
* @param {unknown} params.value - The value that failed validation.
|
||||
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
||||
* @param {TypeValidationContext} params.context - Optional context about what is being validated.
|
||||
* @returns {TypeValidationError} A TypeValidationError instance.
|
||||
*/
|
||||
static wrap({
|
||||
value,
|
||||
cause,
|
||||
context
|
||||
}) {
|
||||
var _a15, _b15, _c;
|
||||
if (_TypeValidationError.isInstance(cause) && cause.value === value && ((_a15 = cause.context) == null ? void 0 : _a15.field) === (context == null ? void 0 : context.field) && ((_b15 = cause.context) == null ? void 0 : _b15.entityName) === (context == null ? void 0 : context.entityName) && ((_c = cause.context) == null ? void 0 : _c.entityId) === (context == null ? void 0 : context.entityId)) {
|
||||
return cause;
|
||||
}
|
||||
return new _TypeValidationError({ value, cause, context });
|
||||
}
|
||||
};
|
||||
|
||||
// src/errors/unsupported-functionality-error.ts
|
||||
var name13 = "AI_UnsupportedFunctionalityError";
|
||||
var marker14 = `vercel.ai.error.${name13}`;
|
||||
var symbol14 = Symbol.for(marker14);
|
||||
var _a14, _b14;
|
||||
var UnsupportedFunctionalityError = class extends (_b14 = AISDKError, _a14 = symbol14, _b14) {
|
||||
constructor({
|
||||
functionality,
|
||||
message = `'${functionality}' functionality not supported.`
|
||||
}) {
|
||||
super({ name: name13, message });
|
||||
this[_a14] = true;
|
||||
this.functionality = functionality;
|
||||
}
|
||||
static isInstance(error) {
|
||||
return AISDKError.hasMarker(error, marker14);
|
||||
}
|
||||
};
|
||||
|
||||
// src/json-value/is-json.ts
|
||||
function isJSONValue(value) {
|
||||
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
||||
return true;
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
return value.every(isJSONValue);
|
||||
}
|
||||
if (typeof value === "object") {
|
||||
return Object.entries(value).every(
|
||||
([key, val]) => typeof key === "string" && (val === void 0 || isJSONValue(val))
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isJSONArray(value) {
|
||||
return Array.isArray(value) && value.every(isJSONValue);
|
||||
}
|
||||
function isJSONObject(value) {
|
||||
return value != null && typeof value === "object" && Object.entries(value).every(
|
||||
([key, val]) => typeof key === "string" && (val === void 0 || isJSONValue(val))
|
||||
);
|
||||
}
|
||||
export {
|
||||
AISDKError,
|
||||
APICallError,
|
||||
EmptyResponseBodyError,
|
||||
InvalidArgumentError,
|
||||
InvalidPromptError,
|
||||
InvalidResponseDataError,
|
||||
JSONParseError,
|
||||
LoadAPIKeyError,
|
||||
LoadSettingError,
|
||||
NoContentGeneratedError,
|
||||
NoSuchModelError,
|
||||
TooManyEmbeddingValuesForCallError,
|
||||
TypeValidationError,
|
||||
UnsupportedFunctionalityError,
|
||||
getErrorMessage,
|
||||
isJSONArray,
|
||||
isJSONObject,
|
||||
isJSONValue
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
+1
File diff suppressed because one or more lines are too long
+63
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "@ai-sdk/provider",
|
||||
"version": "3.0.8",
|
||||
"license": "Apache-2.0",
|
||||
"sideEffects": false,
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"source": "./src/index.ts",
|
||||
"files": [
|
||||
"dist/**/*",
|
||||
"src",
|
||||
"!src/**/*.test.ts",
|
||||
"!src/**/*.test-d.ts",
|
||||
"!src/**/__snapshots__",
|
||||
"!src/**/__fixtures__",
|
||||
"CHANGELOG.md",
|
||||
"README.md"
|
||||
],
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"json-schema": "^0.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/json-schema": "7.0.15",
|
||||
"@types/node": "20.17.24",
|
||||
"tsup": "^8",
|
||||
"typescript": "5.8.3",
|
||||
"@vercel/ai-tsconfig": "0.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"homepage": "https://ai-sdk.dev/docs",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vercel/ai.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/vercel/ai/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"ai"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
|
||||
"build:watch": "pnpm clean && tsup --watch",
|
||||
"clean": "del-cli dist *.tsbuildinfo",
|
||||
"lint": "eslint \"./**/*.ts*\"",
|
||||
"type-check": "tsc --build",
|
||||
"prettier-check": "prettier --check \"./**/*.ts*\""
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './v3/index';
|
||||
Generated
Vendored
+69
@@ -0,0 +1,69 @@
|
||||
import { EmbeddingModelV3 } from '../../embedding-model/v3/embedding-model-v3';
|
||||
import { EmbeddingModelV3CallOptions } from '../../embedding-model/v3/embedding-model-v3-call-options';
|
||||
|
||||
/**
|
||||
* Middleware for EmbeddingModelV3.
|
||||
* This type defines the structure for middleware that can be used to modify
|
||||
* the behavior of EmbeddingModelV3 operations.
|
||||
*/
|
||||
export type EmbeddingModelV3Middleware = {
|
||||
/**
|
||||
* Middleware specification version. Use `v3` for the current version.
|
||||
*/
|
||||
readonly specificationVersion: 'v3';
|
||||
|
||||
/**
|
||||
* Override the provider name if desired.
|
||||
* @param options.model - The embedding model instance.
|
||||
*/
|
||||
overrideProvider?: (options: { model: EmbeddingModelV3 }) => string;
|
||||
|
||||
/**
|
||||
* Override the model ID if desired.
|
||||
* @param options.model - The embedding model instance.
|
||||
*/
|
||||
overrideModelId?: (options: { model: EmbeddingModelV3 }) => string;
|
||||
|
||||
/**
|
||||
* Override the limit of how many embeddings can be generated in a single API call if desired.
|
||||
* @param options.model - The embedding model instance.
|
||||
*/
|
||||
overrideMaxEmbeddingsPerCall?: (options: {
|
||||
model: EmbeddingModelV3;
|
||||
}) => PromiseLike<number | undefined> | number | undefined;
|
||||
|
||||
/**
|
||||
* Override support for handling multiple embedding calls in parallel, if desired..
|
||||
* @param options.model - The embedding model instance.
|
||||
*/
|
||||
overrideSupportsParallelCalls?: (options: {
|
||||
model: EmbeddingModelV3;
|
||||
}) => PromiseLike<boolean> | boolean;
|
||||
|
||||
/**
|
||||
* Transforms the parameters before they are passed to the embed model.
|
||||
* @param options - Object containing the type of operation and the parameters.
|
||||
* @param options.params - The original parameters for the embedding model call.
|
||||
* @returns A promise that resolves to the transformed parameters.
|
||||
*/
|
||||
transformParams?: (options: {
|
||||
params: EmbeddingModelV3CallOptions;
|
||||
model: EmbeddingModelV3;
|
||||
}) => PromiseLike<EmbeddingModelV3CallOptions>;
|
||||
|
||||
/**
|
||||
* Wraps the embed operation of the embedding model.
|
||||
*
|
||||
* @param options - Object containing the embed function, parameters, and model.
|
||||
* @param options.doEmbed - The original embed function.
|
||||
* @param options.params - The parameters for the embed call. If the
|
||||
* `transformParams` middleware is used, this will be the transformed parameters.
|
||||
* @param options.model - The embedding model instance.
|
||||
* @returns A promise that resolves to the result of the generate operation.
|
||||
*/
|
||||
wrapEmbed?: (options: {
|
||||
doEmbed: () => ReturnType<EmbeddingModelV3['doEmbed']>;
|
||||
params: EmbeddingModelV3CallOptions;
|
||||
model: EmbeddingModelV3;
|
||||
}) => Promise<Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>>;
|
||||
};
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './embedding-model-v3-middleware';
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from './v3/index';
|
||||
export * from './v2/index';
|
||||
Generated
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* An embedding is a vector, i.e. an array of numbers.
|
||||
* It is e.g. used to represent a text as a vector of word embeddings.
|
||||
*/
|
||||
export type EmbeddingModelV2Embedding = Array<number>;
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
import {
|
||||
SharedV2Headers,
|
||||
SharedV2ProviderOptions,
|
||||
SharedV2ProviderMetadata,
|
||||
} from '../../shared';
|
||||
import { EmbeddingModelV2Embedding } from './embedding-model-v2-embedding';
|
||||
|
||||
/**
|
||||
* Specification for an embedding model that implements the embedding model
|
||||
* interface version 2.
|
||||
*
|
||||
* VALUE is the type of the values that the model can embed.
|
||||
* This will allow us to go beyond text embeddings in the future,
|
||||
* e.g. to support image embeddings
|
||||
*/
|
||||
export type EmbeddingModelV2<VALUE> = {
|
||||
/**
|
||||
* The embedding model must specify which embedding model interface
|
||||
* version it implements. This will allow us to evolve the embedding
|
||||
* model interface and retain backwards compatibility. The different
|
||||
* implementation versions can be handled as a discriminated union
|
||||
* on our side.
|
||||
*/
|
||||
readonly specificationVersion: 'v2';
|
||||
|
||||
/**
|
||||
* Name of the provider for logging purposes.
|
||||
*/
|
||||
readonly provider: string;
|
||||
|
||||
/**
|
||||
* Provider-specific model ID for logging purposes.
|
||||
*/
|
||||
readonly modelId: string;
|
||||
|
||||
/**
|
||||
* Limit of how many embeddings can be generated in a single API call.
|
||||
*
|
||||
* Use Infinity for models that do not have a limit.
|
||||
*/
|
||||
readonly maxEmbeddingsPerCall:
|
||||
| PromiseLike<number | undefined>
|
||||
| number
|
||||
| undefined;
|
||||
|
||||
/**
|
||||
* True if the model can handle multiple embedding calls in parallel.
|
||||
*/
|
||||
readonly supportsParallelCalls: PromiseLike<boolean> | boolean;
|
||||
|
||||
/**
|
||||
* Generates a list of embeddings for the given input text.
|
||||
*
|
||||
* Naming: "do" prefix to prevent accidental direct usage of the method
|
||||
* by the user.
|
||||
*/
|
||||
doEmbed(options: {
|
||||
/**
|
||||
* List of values to embed.
|
||||
*/
|
||||
values: Array<VALUE>;
|
||||
|
||||
/**
|
||||
* Abort signal for cancelling the operation.
|
||||
*/
|
||||
abortSignal?: AbortSignal;
|
||||
|
||||
/**
|
||||
* Additional provider-specific options. They are passed through
|
||||
* to the provider from the AI SDK and enable provider-specific
|
||||
* functionality that can be fully encapsulated in the provider.
|
||||
*/
|
||||
providerOptions?: SharedV2ProviderOptions;
|
||||
|
||||
/**
|
||||
* Additional HTTP headers to be sent with the request.
|
||||
* Only applicable for HTTP-based providers.
|
||||
*/
|
||||
headers?: Record<string, string | undefined>;
|
||||
}): PromiseLike<{
|
||||
/**
|
||||
* Generated embeddings. They are in the same order as the input values.
|
||||
*/
|
||||
embeddings: Array<EmbeddingModelV2Embedding>;
|
||||
|
||||
/**
|
||||
* Token usage. We only have input tokens for embeddings.
|
||||
*/
|
||||
usage?: { tokens: number };
|
||||
|
||||
/**
|
||||
* Additional provider-specific metadata. They are passed through
|
||||
* from the provider to the AI SDK and enable provider-specific
|
||||
* results that can be fully encapsulated in the provider.
|
||||
*/
|
||||
providerMetadata?: SharedV2ProviderMetadata;
|
||||
|
||||
/**
|
||||
* Optional response information for debugging purposes.
|
||||
*/
|
||||
response?: {
|
||||
/**
|
||||
* Response headers.
|
||||
*/
|
||||
headers?: SharedV2Headers;
|
||||
|
||||
/**
|
||||
* The response body.
|
||||
*/
|
||||
body?: unknown;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from './embedding-model-v2';
|
||||
export * from './embedding-model-v2-embedding';
|
||||
Generated
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
import { SharedV3Headers, SharedV3ProviderOptions } from '../../shared';
|
||||
|
||||
export type EmbeddingModelV3CallOptions = {
|
||||
/**
|
||||
* List of text values to generate embeddings for.
|
||||
*/
|
||||
values: Array<string>;
|
||||
|
||||
/**
|
||||
* Abort signal for cancelling the operation.
|
||||
*/
|
||||
abortSignal?: AbortSignal;
|
||||
|
||||
/**
|
||||
* Additional provider-specific options. They are passed through
|
||||
* to the provider from the AI SDK and enable provider-specific
|
||||
* functionality that can be fully encapsulated in the provider.
|
||||
*/
|
||||
providerOptions?: SharedV3ProviderOptions;
|
||||
|
||||
/**
|
||||
* Additional HTTP headers to be sent with the request.
|
||||
* Only applicable for HTTP-based providers.
|
||||
*/
|
||||
headers?: SharedV3Headers;
|
||||
};
|
||||
Generated
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* An embedding is a vector, i.e. an array of numbers.
|
||||
* It is e.g. used to represent a text as a vector of word embeddings.
|
||||
*/
|
||||
export type EmbeddingModelV3Embedding = Array<number>;
|
||||
Generated
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
import {
|
||||
SharedV3Headers,
|
||||
SharedV3ProviderMetadata,
|
||||
SharedV3Warning,
|
||||
} from '../../shared';
|
||||
import { EmbeddingModelV3Embedding } from './embedding-model-v3-embedding';
|
||||
|
||||
/**
|
||||
* The result of a embedding model doEmbed call.
|
||||
*/
|
||||
export type EmbeddingModelV3Result = {
|
||||
/**
|
||||
* Generated embeddings. They are in the same order as the input values.
|
||||
*/
|
||||
embeddings: Array<EmbeddingModelV3Embedding>;
|
||||
|
||||
/**
|
||||
* Token usage. We only have input tokens for embeddings.
|
||||
*/
|
||||
usage?: { tokens: number };
|
||||
|
||||
/**
|
||||
* Additional provider-specific metadata. They are passed through
|
||||
* from the provider to the AI SDK and enable provider-specific
|
||||
* results that can be fully encapsulated in the provider.
|
||||
*/
|
||||
providerMetadata?: SharedV3ProviderMetadata;
|
||||
|
||||
/**
|
||||
* Optional response information for debugging purposes.
|
||||
*/
|
||||
response?: {
|
||||
/**
|
||||
* Response headers.
|
||||
*/
|
||||
headers?: SharedV3Headers;
|
||||
|
||||
/**
|
||||
* The response body.
|
||||
*/
|
||||
body?: unknown;
|
||||
};
|
||||
|
||||
/**
|
||||
* Warnings for the call, e.g. unsupported settings.
|
||||
*/
|
||||
warnings: Array<SharedV3Warning>;
|
||||
};
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
import { EmbeddingModelV3CallOptions } from './embedding-model-v3-call-options';
|
||||
import { EmbeddingModelV3Result } from './embedding-model-v3-result';
|
||||
|
||||
/**
|
||||
* Specification for an embedding model that implements the embedding model
|
||||
* interface version 3.
|
||||
*
|
||||
* It is specific to text embeddings.
|
||||
*/
|
||||
export type EmbeddingModelV3 = {
|
||||
/**
|
||||
* The embedding model must specify which embedding model interface
|
||||
* version it implements. This will allow us to evolve the embedding
|
||||
* model interface and retain backwards compatibility. The different
|
||||
* implementation versions can be handled as a discriminated union
|
||||
* on our side.
|
||||
*/
|
||||
readonly specificationVersion: 'v3';
|
||||
|
||||
/**
|
||||
* Name of the provider for logging purposes.
|
||||
*/
|
||||
readonly provider: string;
|
||||
|
||||
/**
|
||||
* Provider-specific model ID for logging purposes.
|
||||
*/
|
||||
readonly modelId: string;
|
||||
|
||||
/**
|
||||
* Limit of how many embeddings can be generated in a single API call.
|
||||
*
|
||||
* Use Infinity for models that do not have a limit.
|
||||
*/
|
||||
readonly maxEmbeddingsPerCall:
|
||||
| PromiseLike<number | undefined>
|
||||
| number
|
||||
| undefined;
|
||||
|
||||
/**
|
||||
* True if the model can handle multiple embedding calls in parallel.
|
||||
*/
|
||||
readonly supportsParallelCalls: PromiseLike<boolean> | boolean;
|
||||
|
||||
/**
|
||||
* Generates a list of embeddings for the given input text.
|
||||
*
|
||||
* Naming: "do" prefix to prevent accidental direct usage of the method
|
||||
* by the user.
|
||||
*/
|
||||
doEmbed(
|
||||
options: EmbeddingModelV3CallOptions,
|
||||
): PromiseLike<EmbeddingModelV3Result>;
|
||||
};
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export * from './embedding-model-v3';
|
||||
export * from './embedding-model-v3-call-options';
|
||||
export * from './embedding-model-v3-embedding';
|
||||
export * from './embedding-model-v3-result';
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Symbol used for identifying AI SDK Error instances.
|
||||
* Enables checking if an error is an instance of AISDKError across package versions.
|
||||
*/
|
||||
const marker = 'vercel.ai.error';
|
||||
const symbol = Symbol.for(marker);
|
||||
|
||||
/**
|
||||
* Custom error class for AI SDK related errors.
|
||||
* @extends Error
|
||||
*/
|
||||
export class AISDKError extends Error {
|
||||
private readonly [symbol] = true; // used in isInstance
|
||||
|
||||
/**
|
||||
* The underlying cause of the error, if any.
|
||||
*/
|
||||
readonly cause?: unknown;
|
||||
|
||||
/**
|
||||
* Creates an AI SDK Error.
|
||||
*
|
||||
* @param {Object} params - The parameters for creating the error.
|
||||
* @param {string} params.name - The name of the error.
|
||||
* @param {string} params.message - The error message.
|
||||
* @param {unknown} [params.cause] - The underlying cause of the error.
|
||||
*/
|
||||
constructor({
|
||||
name,
|
||||
message,
|
||||
cause,
|
||||
}: {
|
||||
name: string;
|
||||
message: string;
|
||||
cause?: unknown;
|
||||
}) {
|
||||
super(message);
|
||||
|
||||
this.name = name;
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given error is an AI SDK Error.
|
||||
* @param {unknown} error - The error to check.
|
||||
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
||||
*/
|
||||
static isInstance(error: unknown): error is AISDKError {
|
||||
return AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
|
||||
protected static hasMarker(error: unknown, marker: string): boolean {
|
||||
const markerSymbol = Symbol.for(marker);
|
||||
return (
|
||||
error != null &&
|
||||
typeof error === 'object' &&
|
||||
markerSymbol in error &&
|
||||
typeof error[markerSymbol] === 'boolean' &&
|
||||
error[markerSymbol] === true
|
||||
);
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
import { AISDKError } from './ai-sdk-error';
|
||||
|
||||
const name = 'AI_APICallError';
|
||||
const marker = `vercel.ai.error.${name}`;
|
||||
const symbol = Symbol.for(marker);
|
||||
|
||||
export class APICallError extends AISDKError {
|
||||
private readonly [symbol] = true; // used in isInstance
|
||||
|
||||
readonly url: string;
|
||||
readonly requestBodyValues: unknown;
|
||||
readonly statusCode?: number;
|
||||
|
||||
readonly responseHeaders?: Record<string, string>;
|
||||
readonly responseBody?: string;
|
||||
|
||||
readonly isRetryable: boolean;
|
||||
readonly data?: unknown;
|
||||
|
||||
constructor({
|
||||
message,
|
||||
url,
|
||||
requestBodyValues,
|
||||
statusCode,
|
||||
responseHeaders,
|
||||
responseBody,
|
||||
cause,
|
||||
isRetryable = statusCode != null &&
|
||||
(statusCode === 408 || // request timeout
|
||||
statusCode === 409 || // conflict
|
||||
statusCode === 429 || // too many requests
|
||||
statusCode >= 500), // server error
|
||||
data,
|
||||
}: {
|
||||
message: string;
|
||||
url: string;
|
||||
requestBodyValues: unknown;
|
||||
statusCode?: number;
|
||||
responseHeaders?: Record<string, string>;
|
||||
responseBody?: string;
|
||||
cause?: unknown;
|
||||
isRetryable?: boolean;
|
||||
data?: unknown;
|
||||
}) {
|
||||
super({ name, message, cause });
|
||||
|
||||
this.url = url;
|
||||
this.requestBodyValues = requestBodyValues;
|
||||
this.statusCode = statusCode;
|
||||
this.responseHeaders = responseHeaders;
|
||||
this.responseBody = responseBody;
|
||||
this.isRetryable = isRetryable;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
static isInstance(error: unknown): error is APICallError {
|
||||
return AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { AISDKError } from './ai-sdk-error';
|
||||
|
||||
const name = 'AI_EmptyResponseBodyError';
|
||||
const marker = `vercel.ai.error.${name}`;
|
||||
const symbol = Symbol.for(marker);
|
||||
|
||||
export class EmptyResponseBodyError extends AISDKError {
|
||||
private readonly [symbol] = true; // used in isInstance
|
||||
|
||||
constructor({ message = 'Empty response body' }: { message?: string } = {}) {
|
||||
super({ name, message });
|
||||
}
|
||||
|
||||
static isInstance(error: unknown): error is EmptyResponseBodyError {
|
||||
return AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
export function getErrorMessage(error: unknown | undefined) {
|
||||
if (error == null) {
|
||||
return 'unknown error';
|
||||
}
|
||||
|
||||
if (typeof error === 'string') {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (error instanceof Error) {
|
||||
return error.message;
|
||||
}
|
||||
|
||||
return JSON.stringify(error);
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
export { AISDKError } from './ai-sdk-error';
|
||||
export { APICallError } from './api-call-error';
|
||||
export { EmptyResponseBodyError } from './empty-response-body-error';
|
||||
export { getErrorMessage } from './get-error-message';
|
||||
export { InvalidArgumentError } from './invalid-argument-error';
|
||||
export { InvalidPromptError } from './invalid-prompt-error';
|
||||
export { InvalidResponseDataError } from './invalid-response-data-error';
|
||||
export { JSONParseError } from './json-parse-error';
|
||||
export { LoadAPIKeyError } from './load-api-key-error';
|
||||
export { LoadSettingError } from './load-setting-error';
|
||||
export { NoContentGeneratedError } from './no-content-generated-error';
|
||||
export { NoSuchModelError } from './no-such-model-error';
|
||||
export { TooManyEmbeddingValuesForCallError } from './too-many-embedding-values-for-call-error';
|
||||
export type { TypeValidationContext } from './type-validation-error';
|
||||
export { TypeValidationError } from './type-validation-error';
|
||||
export { UnsupportedFunctionalityError } from './unsupported-functionality-error';
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
import { AISDKError } from './ai-sdk-error';
|
||||
|
||||
const name = 'AI_InvalidArgumentError';
|
||||
const marker = `vercel.ai.error.${name}`;
|
||||
const symbol = Symbol.for(marker);
|
||||
|
||||
/**
|
||||
* A function argument is invalid.
|
||||
*/
|
||||
export class InvalidArgumentError extends AISDKError {
|
||||
private readonly [symbol] = true; // used in isInstance
|
||||
|
||||
readonly argument: string;
|
||||
|
||||
constructor({
|
||||
message,
|
||||
cause,
|
||||
argument,
|
||||
}: {
|
||||
argument: string;
|
||||
message: string;
|
||||
cause?: unknown;
|
||||
}) {
|
||||
super({ name, message, cause });
|
||||
|
||||
this.argument = argument;
|
||||
}
|
||||
|
||||
static isInstance(error: unknown): error is InvalidArgumentError {
|
||||
return AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
import { AISDKError } from './ai-sdk-error';
|
||||
|
||||
const name = 'AI_InvalidPromptError';
|
||||
const marker = `vercel.ai.error.${name}`;
|
||||
const symbol = Symbol.for(marker);
|
||||
|
||||
/**
|
||||
* A prompt is invalid. This error should be thrown by providers when they cannot
|
||||
* process a prompt.
|
||||
*/
|
||||
export class InvalidPromptError extends AISDKError {
|
||||
private readonly [symbol] = true; // used in isInstance
|
||||
|
||||
readonly prompt: unknown;
|
||||
|
||||
constructor({
|
||||
prompt,
|
||||
message,
|
||||
cause,
|
||||
}: {
|
||||
prompt: unknown;
|
||||
message: string;
|
||||
cause?: unknown;
|
||||
}) {
|
||||
super({ name, message: `Invalid prompt: ${message}`, cause });
|
||||
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
static isInstance(error: unknown): error is InvalidPromptError {
|
||||
return AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import { AISDKError } from './ai-sdk-error';
|
||||
|
||||
const name = 'AI_InvalidResponseDataError';
|
||||
const marker = `vercel.ai.error.${name}`;
|
||||
const symbol = Symbol.for(marker);
|
||||
|
||||
/**
|
||||
* Server returned a response with invalid data content.
|
||||
* This should be thrown by providers when they cannot parse the response from the API.
|
||||
*/
|
||||
export class InvalidResponseDataError extends AISDKError {
|
||||
private readonly [symbol] = true; // used in isInstance
|
||||
|
||||
readonly data: unknown;
|
||||
|
||||
constructor({
|
||||
data,
|
||||
message = `Invalid response data: ${JSON.stringify(data)}.`,
|
||||
}: {
|
||||
data: unknown;
|
||||
message?: string;
|
||||
}) {
|
||||
super({ name, message });
|
||||
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
static isInstance(error: unknown): error is InvalidResponseDataError {
|
||||
return AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
import { AISDKError } from './ai-sdk-error';
|
||||
import { getErrorMessage } from './get-error-message';
|
||||
|
||||
const name = 'AI_JSONParseError';
|
||||
const marker = `vercel.ai.error.${name}`;
|
||||
const symbol = Symbol.for(marker);
|
||||
|
||||
export class JSONParseError extends AISDKError {
|
||||
private readonly [symbol] = true; // used in isInstance
|
||||
|
||||
readonly text: string;
|
||||
|
||||
constructor({ text, cause }: { text: string; cause: unknown }) {
|
||||
super({
|
||||
name,
|
||||
message:
|
||||
`JSON parsing failed: ` +
|
||||
`Text: ${text}.\n` +
|
||||
`Error message: ${getErrorMessage(cause)}`,
|
||||
cause,
|
||||
});
|
||||
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
static isInstance(error: unknown): error is JSONParseError {
|
||||
return AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { AISDKError } from './ai-sdk-error';
|
||||
|
||||
const name = 'AI_LoadAPIKeyError';
|
||||
const marker = `vercel.ai.error.${name}`;
|
||||
const symbol = Symbol.for(marker);
|
||||
|
||||
export class LoadAPIKeyError extends AISDKError {
|
||||
private readonly [symbol] = true; // used in isInstance
|
||||
|
||||
constructor({ message }: { message: string }) {
|
||||
super({ name, message });
|
||||
}
|
||||
|
||||
static isInstance(error: unknown): error is LoadAPIKeyError {
|
||||
return AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { AISDKError } from './ai-sdk-error';
|
||||
|
||||
const name = 'AI_LoadSettingError';
|
||||
const marker = `vercel.ai.error.${name}`;
|
||||
const symbol = Symbol.for(marker);
|
||||
|
||||
export class LoadSettingError extends AISDKError {
|
||||
private readonly [symbol] = true; // used in isInstance
|
||||
|
||||
constructor({ message }: { message: string }) {
|
||||
super({ name, message });
|
||||
}
|
||||
|
||||
static isInstance(error: unknown): error is LoadSettingError {
|
||||
return AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import { AISDKError } from './ai-sdk-error';
|
||||
|
||||
const name = 'AI_NoContentGeneratedError';
|
||||
const marker = `vercel.ai.error.${name}`;
|
||||
const symbol = Symbol.for(marker);
|
||||
|
||||
/**
|
||||
* Thrown when the AI provider fails to generate any content.
|
||||
*/
|
||||
export class NoContentGeneratedError extends AISDKError {
|
||||
private readonly [symbol] = true; // used in isInstance
|
||||
|
||||
constructor({
|
||||
message = 'No content generated.',
|
||||
}: { message?: string } = {}) {
|
||||
super({ name, message });
|
||||
}
|
||||
|
||||
static isInstance(error: unknown): error is NoContentGeneratedError {
|
||||
return AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
import { AISDKError } from './ai-sdk-error';
|
||||
|
||||
const name = 'AI_NoSuchModelError';
|
||||
const marker = `vercel.ai.error.${name}`;
|
||||
const symbol = Symbol.for(marker);
|
||||
|
||||
export class NoSuchModelError extends AISDKError {
|
||||
private readonly [symbol] = true; // used in isInstance
|
||||
|
||||
readonly modelId: string;
|
||||
readonly modelType:
|
||||
| 'languageModel'
|
||||
| 'embeddingModel'
|
||||
| 'imageModel'
|
||||
| 'transcriptionModel'
|
||||
| 'speechModel'
|
||||
| 'rerankingModel'
|
||||
| 'videoModel';
|
||||
|
||||
constructor({
|
||||
errorName = name,
|
||||
modelId,
|
||||
modelType,
|
||||
message = `No such ${modelType}: ${modelId}`,
|
||||
}: {
|
||||
errorName?: string;
|
||||
modelId: string;
|
||||
modelType:
|
||||
| 'languageModel'
|
||||
| 'embeddingModel'
|
||||
| 'imageModel'
|
||||
| 'transcriptionModel'
|
||||
| 'speechModel'
|
||||
| 'rerankingModel'
|
||||
| 'videoModel';
|
||||
message?: string;
|
||||
}) {
|
||||
super({ name: errorName, message });
|
||||
|
||||
this.modelId = modelId;
|
||||
this.modelType = modelType;
|
||||
}
|
||||
|
||||
static isInstance(error: unknown): error is NoSuchModelError {
|
||||
return AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
import { AISDKError } from './ai-sdk-error';
|
||||
|
||||
const name = 'AI_TooManyEmbeddingValuesForCallError';
|
||||
const marker = `vercel.ai.error.${name}`;
|
||||
const symbol = Symbol.for(marker);
|
||||
|
||||
export class TooManyEmbeddingValuesForCallError extends AISDKError {
|
||||
private readonly [symbol] = true; // used in isInstance
|
||||
|
||||
readonly provider: string;
|
||||
readonly modelId: string;
|
||||
readonly maxEmbeddingsPerCall: number;
|
||||
readonly values: Array<unknown>;
|
||||
|
||||
constructor(options: {
|
||||
provider: string;
|
||||
modelId: string;
|
||||
maxEmbeddingsPerCall: number;
|
||||
values: Array<unknown>;
|
||||
}) {
|
||||
super({
|
||||
name,
|
||||
message:
|
||||
`Too many values for a single embedding call. ` +
|
||||
`The ${options.provider} model "${options.modelId}" can only embed up to ` +
|
||||
`${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`,
|
||||
});
|
||||
|
||||
this.provider = options.provider;
|
||||
this.modelId = options.modelId;
|
||||
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
||||
this.values = options.values;
|
||||
}
|
||||
|
||||
static isInstance(
|
||||
error: unknown,
|
||||
): error is TooManyEmbeddingValuesForCallError {
|
||||
return AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
import { AISDKError } from './ai-sdk-error';
|
||||
import { getErrorMessage } from './get-error-message';
|
||||
|
||||
const name = 'AI_TypeValidationError';
|
||||
const marker = `vercel.ai.error.${name}`;
|
||||
const symbol = Symbol.for(marker);
|
||||
|
||||
export interface TypeValidationContext {
|
||||
/**
|
||||
* Field path in dot notation (e.g., "message.metadata", "message.parts[3].data")
|
||||
*/
|
||||
field?: string;
|
||||
|
||||
/**
|
||||
* Entity name (e.g., tool name, data type name)
|
||||
*/
|
||||
entityName?: string;
|
||||
|
||||
/**
|
||||
* Entity identifier (e.g., message ID, tool call ID)
|
||||
*/
|
||||
entityId?: string;
|
||||
}
|
||||
|
||||
export class TypeValidationError extends AISDKError {
|
||||
private readonly [symbol] = true; // used in isInstance
|
||||
|
||||
readonly value: unknown;
|
||||
readonly context?: TypeValidationContext;
|
||||
|
||||
constructor({
|
||||
value,
|
||||
cause,
|
||||
context,
|
||||
}: {
|
||||
value: unknown;
|
||||
cause: unknown;
|
||||
context?: TypeValidationContext;
|
||||
}) {
|
||||
let contextPrefix = 'Type validation failed';
|
||||
|
||||
if (context?.field) {
|
||||
contextPrefix += ` for ${context.field}`;
|
||||
}
|
||||
|
||||
if (context?.entityName || context?.entityId) {
|
||||
contextPrefix += ' (';
|
||||
const parts: string[] = [];
|
||||
if (context.entityName) {
|
||||
parts.push(context.entityName);
|
||||
}
|
||||
if (context.entityId) {
|
||||
parts.push(`id: "${context.entityId}"`);
|
||||
}
|
||||
contextPrefix += parts.join(', ');
|
||||
contextPrefix += ')';
|
||||
}
|
||||
|
||||
super({
|
||||
name,
|
||||
message:
|
||||
`${contextPrefix}: ` +
|
||||
`Value: ${JSON.stringify(value)}.\n` +
|
||||
`Error message: ${getErrorMessage(cause)}`,
|
||||
cause,
|
||||
});
|
||||
|
||||
this.value = value;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
static isInstance(error: unknown): error is TypeValidationError {
|
||||
return AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps an error into a TypeValidationError.
|
||||
* If the cause is already a TypeValidationError with the same value and context, it returns the cause.
|
||||
* Otherwise, it creates a new TypeValidationError.
|
||||
*
|
||||
* @param {Object} params - The parameters for wrapping the error.
|
||||
* @param {unknown} params.value - The value that failed validation.
|
||||
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
||||
* @param {TypeValidationContext} params.context - Optional context about what is being validated.
|
||||
* @returns {TypeValidationError} A TypeValidationError instance.
|
||||
*/
|
||||
static wrap({
|
||||
value,
|
||||
cause,
|
||||
context,
|
||||
}: {
|
||||
value: unknown;
|
||||
cause: unknown;
|
||||
context?: TypeValidationContext;
|
||||
}): TypeValidationError {
|
||||
if (
|
||||
TypeValidationError.isInstance(cause) &&
|
||||
cause.value === value &&
|
||||
cause.context?.field === context?.field &&
|
||||
cause.context?.entityName === context?.entityName &&
|
||||
cause.context?.entityId === context?.entityId
|
||||
) {
|
||||
return cause;
|
||||
}
|
||||
|
||||
return new TypeValidationError({ value, cause, context });
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import { AISDKError } from './ai-sdk-error';
|
||||
|
||||
const name = 'AI_UnsupportedFunctionalityError';
|
||||
const marker = `vercel.ai.error.${name}`;
|
||||
const symbol = Symbol.for(marker);
|
||||
|
||||
export class UnsupportedFunctionalityError extends AISDKError {
|
||||
private readonly [symbol] = true; // used in isInstance
|
||||
|
||||
readonly functionality: string;
|
||||
|
||||
constructor({
|
||||
functionality,
|
||||
message = `'${functionality}' functionality not supported.`,
|
||||
}: {
|
||||
functionality: string;
|
||||
message?: string;
|
||||
}) {
|
||||
super({ name, message });
|
||||
this.functionality = functionality;
|
||||
}
|
||||
|
||||
static isInstance(error: unknown): error is UnsupportedFunctionalityError {
|
||||
return AISDKError.hasMarker(error, marker);
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './v3/index';
|
||||
Generated
Vendored
+61
@@ -0,0 +1,61 @@
|
||||
import { ImageModelV3 } from '../../image-model/v3/image-model-v3';
|
||||
import { ImageModelV3CallOptions } from '../../image-model/v3/image-model-v3-call-options';
|
||||
|
||||
/**
|
||||
* Middleware for ImageModelV3.
|
||||
* This type defines the structure for middleware that can be used to modify
|
||||
* the behavior of ImageModelV3 operations.
|
||||
*/
|
||||
export type ImageModelV3Middleware = {
|
||||
/**
|
||||
* Middleware specification version. Use `v3` for the current version.
|
||||
*/
|
||||
readonly specificationVersion: 'v3';
|
||||
|
||||
/**
|
||||
* Override the provider name if desired.
|
||||
* @param options.model - The image model instance.
|
||||
*/
|
||||
overrideProvider?: (options: { model: ImageModelV3 }) => string;
|
||||
|
||||
/**
|
||||
* Override the model ID if desired.
|
||||
* @param options.model - The image model instance.
|
||||
*/
|
||||
overrideModelId?: (options: { model: ImageModelV3 }) => string;
|
||||
|
||||
/**
|
||||
* Override the limit of how many images can be generated in a single API call if desired.
|
||||
* @param options.model - The image model instance.
|
||||
*/
|
||||
overrideMaxImagesPerCall?: (options: {
|
||||
model: ImageModelV3;
|
||||
}) => ImageModelV3['maxImagesPerCall'];
|
||||
|
||||
/**
|
||||
* Transforms the parameters before they are passed to the image model.
|
||||
* @param options - Object containing the parameters.
|
||||
* @param options.params - The original parameters for the image model call.
|
||||
* @returns A promise that resolves to the transformed parameters.
|
||||
*/
|
||||
transformParams?: (options: {
|
||||
params: ImageModelV3CallOptions;
|
||||
model: ImageModelV3;
|
||||
}) => PromiseLike<ImageModelV3CallOptions>;
|
||||
|
||||
/**
|
||||
* Wraps the generate operation of the image model.
|
||||
*
|
||||
* @param options - Object containing the generate function, parameters, and model.
|
||||
* @param options.doGenerate - The original generate function.
|
||||
* @param options.params - The parameters for the generate call. If the
|
||||
* `transformParams` middleware is used, this will be the transformed parameters.
|
||||
* @param options.model - The image model instance.
|
||||
* @returns A promise that resolves to the result of the generate operation.
|
||||
*/
|
||||
wrapGenerate?: (options: {
|
||||
doGenerate: () => ReturnType<ImageModelV3['doGenerate']>;
|
||||
params: ImageModelV3CallOptions;
|
||||
model: ImageModelV3;
|
||||
}) => Promise<Awaited<ReturnType<ImageModelV3['doGenerate']>>>;
|
||||
};
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './image-model-v3-middleware';
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from './v3/index';
|
||||
export * from './v2/index';
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
import { SharedV2ProviderOptions } from '../../shared';
|
||||
|
||||
export type ImageModelV2CallOptions = {
|
||||
/**
|
||||
* Prompt for the image generation.
|
||||
*/
|
||||
prompt: string;
|
||||
|
||||
/**
|
||||
* Number of images to generate.
|
||||
*/
|
||||
n: number;
|
||||
|
||||
/**
|
||||
* Size of the images to generate.
|
||||
* Must have the format `{width}x{height}`.
|
||||
* `undefined` will use the provider's default size.
|
||||
*/
|
||||
size: `${number}x${number}` | undefined;
|
||||
|
||||
/**
|
||||
* Aspect ratio of the images to generate.
|
||||
* Must have the format `{width}:{height}`.
|
||||
* `undefined` will use the provider's default aspect ratio.
|
||||
*/
|
||||
aspectRatio: `${number}:${number}` | undefined;
|
||||
|
||||
/**
|
||||
* Seed for the image generation.
|
||||
* `undefined` will use the provider's default seed.
|
||||
*/
|
||||
seed: number | undefined;
|
||||
|
||||
/**
|
||||
* Additional provider-specific options that are passed through to the provider
|
||||
* as body parameters.
|
||||
*
|
||||
* The outer record is keyed by the provider name, and the inner
|
||||
* record is keyed by the provider-specific metadata key.
|
||||
* ```ts
|
||||
* {
|
||||
* "openai": {
|
||||
* "style": "vivid"
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
providerOptions: SharedV2ProviderOptions;
|
||||
|
||||
/**
|
||||
* Abort signal for cancelling the operation.
|
||||
*/
|
||||
abortSignal?: AbortSignal;
|
||||
|
||||
/**
|
||||
* Additional HTTP headers to be sent with the request.
|
||||
* Only applicable for HTTP-based providers.
|
||||
*/
|
||||
headers?: Record<string, string | undefined>;
|
||||
};
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { ImageModelV2CallOptions } from './image-model-v2-call-options';
|
||||
|
||||
/**
|
||||
* Warning from the model provider for this call. The call will proceed, but e.g.
|
||||
* some settings might not be supported, which can lead to suboptimal results.
|
||||
*/
|
||||
export type ImageModelV2CallWarning =
|
||||
| {
|
||||
type: 'unsupported-setting';
|
||||
setting: keyof ImageModelV2CallOptions;
|
||||
details?: string;
|
||||
}
|
||||
| {
|
||||
type: 'other';
|
||||
message: string;
|
||||
};
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
import { JSONArray, JSONValue } from '../../json-value';
|
||||
import { ImageModelV2CallOptions } from './image-model-v2-call-options';
|
||||
import { ImageModelV2CallWarning } from './image-model-v2-call-warning';
|
||||
|
||||
export type ImageModelV2ProviderMetadata = Record<
|
||||
string,
|
||||
{
|
||||
images: JSONArray;
|
||||
} & JSONValue
|
||||
>;
|
||||
|
||||
type GetMaxImagesPerCallFunction = (options: {
|
||||
modelId: string;
|
||||
}) => PromiseLike<number | undefined> | number | undefined;
|
||||
|
||||
/**
|
||||
* Image generation model specification version 2.
|
||||
*/
|
||||
export type ImageModelV2 = {
|
||||
/**
|
||||
* The image model must specify which image model interface
|
||||
* version it implements. This will allow us to evolve the image
|
||||
* model interface and retain backwards compatibility. The different
|
||||
* implementation versions can be handled as a discriminated union
|
||||
* on our side.
|
||||
*/
|
||||
readonly specificationVersion: 'v2';
|
||||
|
||||
/**
|
||||
* Name of the provider for logging purposes.
|
||||
*/
|
||||
readonly provider: string;
|
||||
|
||||
/**
|
||||
* Provider-specific model ID for logging purposes.
|
||||
*/
|
||||
readonly modelId: string;
|
||||
|
||||
/**
|
||||
* Limit of how many images can be generated in a single API call.
|
||||
* Can be set to a number for a fixed limit, to undefined to use
|
||||
* the global limit, or a function that returns a number or undefined,
|
||||
* optionally as a promise.
|
||||
*/
|
||||
readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction;
|
||||
|
||||
/**
|
||||
* Generates an array of images.
|
||||
*/
|
||||
doGenerate(options: ImageModelV2CallOptions): PromiseLike<{
|
||||
/**
|
||||
* Generated images as base64 encoded strings or binary data.
|
||||
* The images should be returned without any unnecessary conversion.
|
||||
* If the API returns base64 encoded strings, the images should be returned
|
||||
* as base64 encoded strings. If the API returns binary data, the images should
|
||||
* be returned as binary data.
|
||||
*/
|
||||
images: Array<string> | Array<Uint8Array>;
|
||||
|
||||
/**
|
||||
* Warnings for the call, e.g. unsupported settings.
|
||||
*/
|
||||
warnings: Array<ImageModelV2CallWarning>;
|
||||
|
||||
/**
|
||||
* Additional provider-specific metadata. They are passed through
|
||||
* from the provider to the AI SDK and enable provider-specific
|
||||
* results that can be fully encapsulated in the provider.
|
||||
*
|
||||
* The outer record is keyed by the provider name, and the inner
|
||||
* record is provider-specific metadata. It always includes an
|
||||
* `images` key with image-specific metadata
|
||||
*
|
||||
* ```ts
|
||||
* {
|
||||
* "openai": {
|
||||
* "images": ["revisedPrompt": "Revised prompt here."]
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
providerMetadata?: ImageModelV2ProviderMetadata;
|
||||
|
||||
/**
|
||||
* Response information for telemetry and debugging purposes.
|
||||
*/
|
||||
response: {
|
||||
/**
|
||||
* Timestamp for the start of the generated response.
|
||||
*/
|
||||
timestamp: Date;
|
||||
|
||||
/**
|
||||
* The ID of the response model that was used to generate the response.
|
||||
*/
|
||||
modelId: string;
|
||||
|
||||
/**
|
||||
* Response headers.
|
||||
*/
|
||||
headers: Record<string, string> | undefined;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
export type {
|
||||
ImageModelV2,
|
||||
ImageModelV2ProviderMetadata,
|
||||
} from './image-model-v2';
|
||||
export type { ImageModelV2CallOptions } from './image-model-v2-call-options';
|
||||
export type { ImageModelV2CallWarning } from './image-model-v2-call-warning';
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
import { SharedV3ProviderOptions } from '../../shared';
|
||||
import { ImageModelV3File } from './image-model-v3-file';
|
||||
|
||||
export type ImageModelV3CallOptions = {
|
||||
/**
|
||||
* Prompt for the image generation. Some operations, like upscaling, may not require a prompt.
|
||||
*/
|
||||
prompt: string | undefined;
|
||||
|
||||
/**
|
||||
* Number of images to generate.
|
||||
*/
|
||||
n: number;
|
||||
|
||||
/**
|
||||
* Size of the images to generate.
|
||||
* Must have the format `{width}x{height}`.
|
||||
* `undefined` will use the provider's default size.
|
||||
*/
|
||||
size: `${number}x${number}` | undefined;
|
||||
|
||||
/**
|
||||
* Aspect ratio of the images to generate.
|
||||
* Must have the format `{width}:{height}`.
|
||||
* `undefined` will use the provider's default aspect ratio.
|
||||
*/
|
||||
aspectRatio: `${number}:${number}` | undefined;
|
||||
|
||||
/**
|
||||
* Seed for the image generation.
|
||||
* `undefined` will use the provider's default seed.
|
||||
*/
|
||||
seed: number | undefined;
|
||||
|
||||
/**
|
||||
* Array of images for image editing or variation generation.
|
||||
* The images should be provided as base64 encoded strings or binary data.
|
||||
*/
|
||||
files: ImageModelV3File[] | undefined;
|
||||
|
||||
/**
|
||||
* Mask image for inpainting operations.
|
||||
* The mask should be provided as base64 encoded strings or binary data.
|
||||
*/
|
||||
mask: ImageModelV3File | undefined;
|
||||
|
||||
/**
|
||||
* Additional provider-specific options that are passed through to the provider
|
||||
* as body parameters.
|
||||
*
|
||||
* The outer record is keyed by the provider name, and the inner
|
||||
* record is keyed by the provider-specific metadata key.
|
||||
*
|
||||
* ```ts
|
||||
* {
|
||||
* "openai": {
|
||||
* "style": "vivid"
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
providerOptions: SharedV3ProviderOptions;
|
||||
|
||||
/**
|
||||
* Abort signal for cancelling the operation.
|
||||
*/
|
||||
abortSignal?: AbortSignal;
|
||||
|
||||
/**
|
||||
* Additional HTTP headers to be sent with the request.
|
||||
* Only applicable for HTTP-based providers.
|
||||
*/
|
||||
headers?: Record<string, string | undefined>;
|
||||
};
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
import { SharedV3ProviderMetadata } from '../../shared';
|
||||
|
||||
/**
|
||||
* An image file that can be used for image editing or variation generation.
|
||||
*/
|
||||
export type ImageModelV3File =
|
||||
| {
|
||||
type: 'file';
|
||||
|
||||
/**
|
||||
* The IANA media type of the file, e.g. `image/png`. Any string is supported.
|
||||
*
|
||||
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
||||
*/
|
||||
mediaType: string;
|
||||
|
||||
/**
|
||||
* Generated file data as base64 encoded strings or binary data.
|
||||
*
|
||||
* The file data should be returned without any unnecessary conversion.
|
||||
* If the API returns base64 encoded strings, the file data should be returned
|
||||
* as base64 encoded strings. If the API returns binary data, the file data should
|
||||
* be returned as binary data.
|
||||
*/
|
||||
data: string | Uint8Array;
|
||||
|
||||
/**
|
||||
* Optional provider-specific metadata for the file part.
|
||||
*/
|
||||
providerOptions?: SharedV3ProviderMetadata;
|
||||
}
|
||||
| {
|
||||
type: 'url';
|
||||
|
||||
/**
|
||||
* The URL of the image file.
|
||||
*/
|
||||
url: string;
|
||||
|
||||
/**
|
||||
* Optional provider-specific metadata for the file part.
|
||||
*/
|
||||
providerOptions?: SharedV3ProviderMetadata;
|
||||
};
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Usage information for an image model call.
|
||||
*/
|
||||
export type ImageModelV3Usage = {
|
||||
/**
|
||||
* The number of input (prompt) tokens used.
|
||||
*/
|
||||
inputTokens: number | undefined;
|
||||
|
||||
/**
|
||||
* The number of output tokens used, if reported by the provider.
|
||||
*/
|
||||
outputTokens: number | undefined;
|
||||
|
||||
/**
|
||||
* The total number of tokens as reported by the provider.
|
||||
*/
|
||||
totalTokens: number | undefined;
|
||||
};
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
import { JSONArray, JSONValue } from '../../json-value';
|
||||
import { ImageModelV3Usage } from './image-model-v3-usage';
|
||||
import { ImageModelV3CallOptions } from './image-model-v3-call-options';
|
||||
import { SharedV3Warning } from '../../shared/v3/shared-v3-warning';
|
||||
|
||||
export type ImageModelV3ProviderMetadata = Record<
|
||||
string,
|
||||
{
|
||||
images: JSONArray;
|
||||
} & JSONValue
|
||||
>;
|
||||
|
||||
type GetMaxImagesPerCallFunction = (options: {
|
||||
modelId: string;
|
||||
}) => PromiseLike<number | undefined> | number | undefined;
|
||||
|
||||
/**
|
||||
* Image generation model specification version 3.
|
||||
*/
|
||||
export type ImageModelV3 = {
|
||||
/**
|
||||
* The image model must specify which image model interface
|
||||
* version it implements. This will allow us to evolve the image
|
||||
* model interface and retain backwards compatibility. The different
|
||||
* implementation versions can be handled as a discriminated union
|
||||
* on our side.
|
||||
*/
|
||||
readonly specificationVersion: 'v3';
|
||||
|
||||
/**
|
||||
* Name of the provider for logging purposes.
|
||||
*/
|
||||
readonly provider: string;
|
||||
|
||||
/**
|
||||
* Provider-specific model ID for logging purposes.
|
||||
*/
|
||||
readonly modelId: string;
|
||||
|
||||
/**
|
||||
* Limit of how many images can be generated in a single API call.
|
||||
* Can be set to a number for a fixed limit, to undefined to use
|
||||
* the global limit, or a function that returns a number or undefined,
|
||||
* optionally as a promise.
|
||||
*/
|
||||
readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction;
|
||||
|
||||
/**
|
||||
* Generates an array of images.
|
||||
*/
|
||||
doGenerate(options: ImageModelV3CallOptions): PromiseLike<{
|
||||
/**
|
||||
* Generated images as base64 encoded strings or binary data.
|
||||
* The images should be returned without any unnecessary conversion.
|
||||
* If the API returns base64 encoded strings, the images should be returned
|
||||
* as base64 encoded strings. If the API returns binary data, the images should
|
||||
* be returned as binary data.
|
||||
*/
|
||||
images: Array<string> | Array<Uint8Array>;
|
||||
|
||||
/**
|
||||
* Warnings for the call, e.g. unsupported features.
|
||||
*/
|
||||
warnings: Array<SharedV3Warning>;
|
||||
|
||||
/**
|
||||
* Additional provider-specific metadata. They are passed through
|
||||
* from the provider to the AI SDK and enable provider-specific
|
||||
* results that can be fully encapsulated in the provider.
|
||||
*
|
||||
* The outer record is keyed by the provider name, and the inner
|
||||
* record is provider-specific metadata. It always includes an
|
||||
* `images` key with image-specific metadata
|
||||
*
|
||||
* ```ts
|
||||
* {
|
||||
* "openai": {
|
||||
* "images": ["revisedPrompt": "Revised prompt here."]
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
providerMetadata?: ImageModelV3ProviderMetadata;
|
||||
|
||||
/**
|
||||
* Response information for telemetry and debugging purposes.
|
||||
*/
|
||||
response: {
|
||||
/**
|
||||
* Timestamp for the start of the generated response.
|
||||
*/
|
||||
timestamp: Date;
|
||||
|
||||
/**
|
||||
* The ID of the response model that was used to generate the response.
|
||||
*/
|
||||
modelId: string;
|
||||
|
||||
/**
|
||||
* Response headers.
|
||||
*/
|
||||
headers: Record<string, string> | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Optional token usage for the image generation call (if the provider reports it).
|
||||
*/
|
||||
usage?: ImageModelV3Usage;
|
||||
}>;
|
||||
};
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
export type {
|
||||
ImageModelV3,
|
||||
ImageModelV3ProviderMetadata,
|
||||
} from './image-model-v3';
|
||||
export type { ImageModelV3CallOptions } from './image-model-v3-call-options';
|
||||
export type { ImageModelV3Usage } from './image-model-v3-usage';
|
||||
export type { ImageModelV3File } from './image-model-v3-file';
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
export * from './embedding-model/index';
|
||||
export * from './errors/index';
|
||||
export * from './image-model/index';
|
||||
export * from './image-model-middleware/index';
|
||||
export * from './json-value/index';
|
||||
export * from './language-model-middleware/index';
|
||||
export * from './embedding-model-middleware/index';
|
||||
export * from './language-model/index';
|
||||
export * from './provider/index';
|
||||
export * from './reranking-model/index';
|
||||
export * from './shared/index';
|
||||
export * from './speech-model/index';
|
||||
export * from './transcription-model/index';
|
||||
export * from './video-model/index';
|
||||
|
||||
export type { JSONSchema7, JSONSchema7Definition } from 'json-schema';
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { isJSONArray, isJSONObject, isJSONValue } from './is-json';
|
||||
export type { JSONArray, JSONObject, JSONValue } from './json-value';
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import { JSONArray, JSONObject, JSONValue } from './json-value';
|
||||
|
||||
export function isJSONValue(value: unknown): value is JSONValue {
|
||||
if (
|
||||
value === null ||
|
||||
typeof value === 'string' ||
|
||||
typeof value === 'number' ||
|
||||
typeof value === 'boolean'
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
return value.every(isJSONValue);
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
return Object.entries(value).every(
|
||||
([key, val]) =>
|
||||
typeof key === 'string' && (val === undefined || isJSONValue(val)),
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isJSONArray(value: unknown): value is JSONArray {
|
||||
return Array.isArray(value) && value.every(isJSONValue);
|
||||
}
|
||||
|
||||
export function isJSONObject(value: unknown): value is JSONObject {
|
||||
return (
|
||||
value != null &&
|
||||
typeof value === 'object' &&
|
||||
Object.entries(value).every(
|
||||
([key, val]) =>
|
||||
typeof key === 'string' && (val === undefined || isJSONValue(val)),
|
||||
)
|
||||
);
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* A JSON value can be a string, number, boolean, object, array, or null.
|
||||
* JSON values can be serialized and deserialized by the JSON.stringify and JSON.parse methods.
|
||||
*/
|
||||
export type JSONValue =
|
||||
| null
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| JSONObject
|
||||
| JSONArray;
|
||||
|
||||
export type JSONObject = {
|
||||
[key: string]: JSONValue | undefined;
|
||||
};
|
||||
|
||||
export type JSONArray = JSONValue[];
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from './v3/index';
|
||||
export * from './v2/index';
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './language-model-v2-middleware';
|
||||
Generated
Vendored
+82
@@ -0,0 +1,82 @@
|
||||
import { LanguageModelV2 } from '../../language-model/v2/language-model-v2';
|
||||
import { LanguageModelV2CallOptions } from '../../language-model/v2/language-model-v2-call-options';
|
||||
|
||||
/**
|
||||
* Experimental middleware for LanguageModelV2.
|
||||
* This type defines the structure for middleware that can be used to modify
|
||||
* the behavior of LanguageModelV2 operations.
|
||||
*/
|
||||
export type LanguageModelV2Middleware = {
|
||||
/**
|
||||
* Middleware specification version. Use `v2` for the current version.
|
||||
*/
|
||||
middlewareVersion?: 'v2' | undefined; // backwards compatibility
|
||||
|
||||
/**
|
||||
* Override the provider name if desired.
|
||||
* @param options.model - The language model instance.
|
||||
*/
|
||||
overrideProvider?: (options: { model: LanguageModelV2 }) => string;
|
||||
|
||||
/**
|
||||
* Override the model ID if desired.
|
||||
* @param options.model - The language model instance.
|
||||
*/
|
||||
overrideModelId?: (options: { model: LanguageModelV2 }) => string;
|
||||
|
||||
/**
|
||||
* Override the supported URLs if desired.
|
||||
* @param options.model - The language model instance.
|
||||
*/
|
||||
overrideSupportedUrls?: (options: {
|
||||
model: LanguageModelV2;
|
||||
}) => PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
||||
|
||||
/**
|
||||
* Transforms the parameters before they are passed to the language model.
|
||||
* @param options - Object containing the type of operation and the parameters.
|
||||
* @param options.type - The type of operation ('generate' or 'stream').
|
||||
* @param options.params - The original parameters for the language model call.
|
||||
* @returns A promise that resolves to the transformed parameters.
|
||||
*/
|
||||
transformParams?: (options: {
|
||||
type: 'generate' | 'stream';
|
||||
params: LanguageModelV2CallOptions;
|
||||
model: LanguageModelV2;
|
||||
}) => PromiseLike<LanguageModelV2CallOptions>;
|
||||
|
||||
/**
|
||||
* Wraps the generate operation of the language model.
|
||||
* @param options - Object containing the generate function, parameters, and model.
|
||||
* @param options.doGenerate - The original generate function.
|
||||
* @param options.doStream - The original stream function.
|
||||
* @param options.params - The parameters for the generate call. If the
|
||||
* `transformParams` middleware is used, this will be the transformed parameters.
|
||||
* @param options.model - The language model instance.
|
||||
* @returns A promise that resolves to the result of the generate operation.
|
||||
*/
|
||||
wrapGenerate?: (options: {
|
||||
doGenerate: () => ReturnType<LanguageModelV2['doGenerate']>;
|
||||
doStream: () => ReturnType<LanguageModelV2['doStream']>;
|
||||
params: LanguageModelV2CallOptions;
|
||||
model: LanguageModelV2;
|
||||
}) => Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
|
||||
|
||||
/**
|
||||
* Wraps the stream operation of the language model.
|
||||
*
|
||||
* @param options - Object containing the stream function, parameters, and model.
|
||||
* @param options.doGenerate - The original generate function.
|
||||
* @param options.doStream - The original stream function.
|
||||
* @param options.params - The parameters for the stream call. If the
|
||||
* `transformParams` middleware is used, this will be the transformed parameters.
|
||||
* @param options.model - The language model instance.
|
||||
* @returns A promise that resolves to the result of the stream operation.
|
||||
*/
|
||||
wrapStream?: (options: {
|
||||
doGenerate: () => ReturnType<LanguageModelV2['doGenerate']>;
|
||||
doStream: () => ReturnType<LanguageModelV2['doStream']>;
|
||||
params: LanguageModelV2CallOptions;
|
||||
model: LanguageModelV2;
|
||||
}) => PromiseLike<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
||||
};
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './language-model-v3-middleware';
|
||||
Generated
Vendored
+84
@@ -0,0 +1,84 @@
|
||||
import { LanguageModelV3 } from '../../language-model/v3/language-model-v3';
|
||||
import { LanguageModelV3CallOptions } from '../../language-model/v3/language-model-v3-call-options';
|
||||
import { LanguageModelV3GenerateResult } from '../../language-model/v3/language-model-v3-generate-result';
|
||||
import { LanguageModelV3StreamResult } from '../../language-model/v3/language-model-v3-stream-result';
|
||||
|
||||
/**
|
||||
* Experimental middleware for LanguageModelV3.
|
||||
* This type defines the structure for middleware that can be used to modify
|
||||
* the behavior of LanguageModelV3 operations.
|
||||
*/
|
||||
export type LanguageModelV3Middleware = {
|
||||
/**
|
||||
* Middleware specification version. Use `v3` for the current version.
|
||||
*/
|
||||
readonly specificationVersion: 'v3';
|
||||
|
||||
/**
|
||||
* Override the provider name if desired.
|
||||
* @param options.model - The language model instance.
|
||||
*/
|
||||
overrideProvider?: (options: { model: LanguageModelV3 }) => string;
|
||||
|
||||
/**
|
||||
* Override the model ID if desired.
|
||||
* @param options.model - The language model instance.
|
||||
*/
|
||||
overrideModelId?: (options: { model: LanguageModelV3 }) => string;
|
||||
|
||||
/**
|
||||
* Override the supported URLs if desired.
|
||||
* @param options.model - The language model instance.
|
||||
*/
|
||||
overrideSupportedUrls?: (options: {
|
||||
model: LanguageModelV3;
|
||||
}) => PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
||||
|
||||
/**
|
||||
* Transforms the parameters before they are passed to the language model.
|
||||
* @param options - Object containing the type of operation and the parameters.
|
||||
* @param options.type - The type of operation ('generate' or 'stream').
|
||||
* @param options.params - The original parameters for the language model call.
|
||||
* @returns A promise that resolves to the transformed parameters.
|
||||
*/
|
||||
transformParams?: (options: {
|
||||
type: 'generate' | 'stream';
|
||||
params: LanguageModelV3CallOptions;
|
||||
model: LanguageModelV3;
|
||||
}) => PromiseLike<LanguageModelV3CallOptions>;
|
||||
|
||||
/**
|
||||
* Wraps the generate operation of the language model.
|
||||
* @param options - Object containing the generate function, parameters, and model.
|
||||
* @param options.doGenerate - The original generate function.
|
||||
* @param options.doStream - The original stream function.
|
||||
* @param options.params - The parameters for the generate call. If the
|
||||
* `transformParams` middleware is used, this will be the transformed parameters.
|
||||
* @param options.model - The language model instance.
|
||||
* @returns A promise that resolves to the result of the generate operation.
|
||||
*/
|
||||
wrapGenerate?: (options: {
|
||||
doGenerate: () => PromiseLike<LanguageModelV3GenerateResult>;
|
||||
doStream: () => PromiseLike<LanguageModelV3StreamResult>;
|
||||
params: LanguageModelV3CallOptions;
|
||||
model: LanguageModelV3;
|
||||
}) => PromiseLike<LanguageModelV3GenerateResult>;
|
||||
|
||||
/**
|
||||
* Wraps the stream operation of the language model.
|
||||
*
|
||||
* @param options - Object containing the stream function, parameters, and model.
|
||||
* @param options.doGenerate - The original generate function.
|
||||
* @param options.doStream - The original stream function.
|
||||
* @param options.params - The parameters for the stream call. If the
|
||||
* `transformParams` middleware is used, this will be the transformed parameters.
|
||||
* @param options.model - The language model instance.
|
||||
* @returns A promise that resolves to the result of the stream operation.
|
||||
*/
|
||||
wrapStream?: (options: {
|
||||
doGenerate: () => PromiseLike<LanguageModelV3GenerateResult>;
|
||||
doStream: () => PromiseLike<LanguageModelV3StreamResult>;
|
||||
params: LanguageModelV3CallOptions;
|
||||
model: LanguageModelV3;
|
||||
}) => PromiseLike<LanguageModelV3StreamResult>;
|
||||
};
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from './v3/index';
|
||||
export * from './v2/index';
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
export * from './language-model-v2';
|
||||
export * from './language-model-v2-call-options';
|
||||
export * from './language-model-v2-call-warning';
|
||||
export * from './language-model-v2-content';
|
||||
export * from './language-model-v2-data-content';
|
||||
export * from './language-model-v2-file';
|
||||
export * from './language-model-v2-finish-reason';
|
||||
export * from './language-model-v2-function-tool';
|
||||
export * from './language-model-v2-prompt';
|
||||
export * from './language-model-v2-provider-defined-tool';
|
||||
export * from './language-model-v2-reasoning';
|
||||
export * from './language-model-v2-response-metadata';
|
||||
export * from './language-model-v2-source';
|
||||
export * from './language-model-v2-stream-part';
|
||||
export * from './language-model-v2-text';
|
||||
export * from './language-model-v2-tool-call';
|
||||
export * from './language-model-v2-tool-choice';
|
||||
export * from './language-model-v2-usage';
|
||||
Generated
Vendored
+127
@@ -0,0 +1,127 @@
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { SharedV2ProviderOptions } from '../../shared/v2/shared-v2-provider-options';
|
||||
import { LanguageModelV2FunctionTool } from './language-model-v2-function-tool';
|
||||
import { LanguageModelV2Prompt } from './language-model-v2-prompt';
|
||||
import { LanguageModelV2ProviderDefinedTool } from './language-model-v2-provider-defined-tool';
|
||||
import { LanguageModelV2ToolChoice } from './language-model-v2-tool-choice';
|
||||
|
||||
export type LanguageModelV2CallOptions = {
|
||||
/**
|
||||
* A language mode prompt is a standardized prompt type.
|
||||
*
|
||||
* Note: This is **not** the user-facing prompt. The AI SDK methods will map the
|
||||
* user-facing prompt types such as chat or instruction prompts to this format.
|
||||
* That approach allows us to evolve the user facing prompts without breaking
|
||||
* the language model interface.
|
||||
*/
|
||||
prompt: LanguageModelV2Prompt;
|
||||
|
||||
/**
|
||||
* Maximum number of tokens to generate.
|
||||
*/
|
||||
maxOutputTokens?: number;
|
||||
|
||||
/**
|
||||
* Temperature setting. The range depends on the provider and model.
|
||||
*/
|
||||
temperature?: number;
|
||||
|
||||
/**
|
||||
* Stop sequences.
|
||||
* If set, the model will stop generating text when one of the stop sequences is generated.
|
||||
* Providers may have limits on the number of stop sequences.
|
||||
*/
|
||||
stopSequences?: string[];
|
||||
|
||||
/**
|
||||
* Nucleus sampling.
|
||||
*/
|
||||
topP?: number;
|
||||
|
||||
/**
|
||||
* Only sample from the top K options for each subsequent token.
|
||||
*
|
||||
* Used to remove "long tail" low probability responses.
|
||||
* Recommended for advanced use cases only. You usually only need to use temperature.
|
||||
*/
|
||||
topK?: number;
|
||||
|
||||
/**
|
||||
* Presence penalty setting. It affects the likelihood of the model to
|
||||
* repeat information that is already in the prompt.
|
||||
*/
|
||||
presencePenalty?: number;
|
||||
|
||||
/**
|
||||
* Frequency penalty setting. It affects the likelihood of the model
|
||||
* to repeatedly use the same words or phrases.
|
||||
*/
|
||||
frequencyPenalty?: number;
|
||||
|
||||
/**
|
||||
* Response format. The output can either be text or JSON. Default is text.
|
||||
*
|
||||
* If JSON is selected, a schema can optionally be provided to guide the LLM.
|
||||
*/
|
||||
responseFormat?:
|
||||
| { type: 'text' }
|
||||
| {
|
||||
type: 'json';
|
||||
|
||||
/**
|
||||
* JSON schema that the generated output should conform to.
|
||||
*/
|
||||
schema?: JSONSchema7;
|
||||
|
||||
/**
|
||||
* Name of output that should be generated. Used by some providers for additional LLM guidance.
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* Description of the output that should be generated. Used by some providers for additional LLM guidance.
|
||||
*/
|
||||
description?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* The seed (integer) to use for random sampling. If set and supported
|
||||
* by the model, calls will generate deterministic results.
|
||||
*/
|
||||
seed?: number;
|
||||
|
||||
/**
|
||||
* The tools that are available for the model.
|
||||
*/
|
||||
tools?: Array<
|
||||
LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool
|
||||
>;
|
||||
|
||||
/**
|
||||
* Specifies how the tool should be selected. Defaults to 'auto'.
|
||||
*/
|
||||
toolChoice?: LanguageModelV2ToolChoice;
|
||||
|
||||
/**
|
||||
* Include raw chunks in the stream. Only applicable for streaming calls.
|
||||
*/
|
||||
includeRawChunks?: boolean;
|
||||
|
||||
/**
|
||||
* Abort signal for cancelling the operation.
|
||||
*/
|
||||
abortSignal?: AbortSignal;
|
||||
|
||||
/**
|
||||
* Additional HTTP headers to be sent with the request.
|
||||
* Only applicable for HTTP-based providers.
|
||||
*/
|
||||
headers?: Record<string, string | undefined>;
|
||||
|
||||
/**
|
||||
* Additional provider-specific options. They are passed through
|
||||
* to the provider from the AI SDK and enable provider-specific
|
||||
* functionality that can be fully encapsulated in the provider.
|
||||
*/
|
||||
providerOptions?: SharedV2ProviderOptions;
|
||||
};
|
||||
Generated
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
import { LanguageModelV2CallOptions } from './language-model-v2-call-options';
|
||||
import { LanguageModelV2FunctionTool } from './language-model-v2-function-tool';
|
||||
import { LanguageModelV2ProviderDefinedTool } from './language-model-v2-provider-defined-tool';
|
||||
|
||||
/**
|
||||
* Warning from the model provider for this call. The call will proceed, but e.g.
|
||||
* some settings might not be supported, which can lead to suboptimal results.
|
||||
*/
|
||||
export type LanguageModelV2CallWarning =
|
||||
| {
|
||||
type: 'unsupported-setting';
|
||||
setting: Omit<keyof LanguageModelV2CallOptions, 'prompt'>;
|
||||
details?: string;
|
||||
}
|
||||
| {
|
||||
type: 'unsupported-tool';
|
||||
tool: LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool;
|
||||
details?: string;
|
||||
}
|
||||
| {
|
||||
type: 'other';
|
||||
message: string;
|
||||
};
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { LanguageModelV2File } from './language-model-v2-file';
|
||||
import { LanguageModelV2Reasoning } from './language-model-v2-reasoning';
|
||||
import { LanguageModelV2Source } from './language-model-v2-source';
|
||||
import { LanguageModelV2Text } from './language-model-v2-text';
|
||||
import { LanguageModelV2ToolCall } from './language-model-v2-tool-call';
|
||||
import { LanguageModelV2ToolResult } from './language-model-v2-tool-result';
|
||||
|
||||
export type LanguageModelV2Content =
|
||||
| LanguageModelV2Text
|
||||
| LanguageModelV2Reasoning
|
||||
| LanguageModelV2File
|
||||
| LanguageModelV2Source
|
||||
| LanguageModelV2ToolCall
|
||||
| LanguageModelV2ToolResult;
|
||||
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Data content. Can be a Uint8Array, base64 encoded data as a string or a URL.
|
||||
*/
|
||||
export type LanguageModelV2DataContent = Uint8Array | string | URL;
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* A file that has been generated by the model.
|
||||
* Generated files as base64 encoded strings or binary data.
|
||||
* The files should be returned without any unnecessary conversion.
|
||||
*/
|
||||
export type LanguageModelV2File = {
|
||||
type: 'file';
|
||||
|
||||
/**
|
||||
* The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
|
||||
*
|
||||
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
||||
*/
|
||||
mediaType: string;
|
||||
|
||||
/**
|
||||
* Generated file data as base64 encoded strings or binary data.
|
||||
*
|
||||
* The file data should be returned without any unnecessary conversion.
|
||||
* If the API returns base64 encoded strings, the file data should be returned
|
||||
* as base64 encoded strings. If the API returns binary data, the file data should
|
||||
* be returned as binary data.
|
||||
*/
|
||||
data: string | Uint8Array;
|
||||
};
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Reason why a language model finished generating a response.
|
||||
*
|
||||
* Can be one of the following:
|
||||
* - `stop`: model generated stop sequence
|
||||
* - `length`: model generated maximum number of tokens
|
||||
* - `content-filter`: content filter violation stopped the model
|
||||
* - `tool-calls`: model triggered tool calls
|
||||
* - `error`: model stopped because of an error
|
||||
* - `other`: model stopped for other reasons
|
||||
* - `unknown`: the model has not transmitted a finish reason
|
||||
*/
|
||||
export type LanguageModelV2FinishReason =
|
||||
| 'stop' // model generated stop sequence
|
||||
| 'length' // model generated maximum number of tokens
|
||||
| 'content-filter' // content filter violation stopped the model
|
||||
| 'tool-calls' // model triggered tool calls
|
||||
| 'error' // model stopped because of an error
|
||||
| 'other' // model stopped for other reasons
|
||||
| 'unknown'; // the model has not transmitted a finish reason
|
||||
Generated
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { SharedV2ProviderOptions } from '../../shared';
|
||||
|
||||
/**
|
||||
* A tool has a name, a description, and a set of parameters.
|
||||
*
|
||||
* Note: this is **not** the user-facing tool definition. The AI SDK methods will
|
||||
* map the user-facing tool definitions to this format.
|
||||
*/
|
||||
export type LanguageModelV2FunctionTool = {
|
||||
/**
|
||||
* The type of the tool (always 'function').
|
||||
*/
|
||||
type: 'function';
|
||||
|
||||
/**
|
||||
* The name of the tool. Unique within this model call.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* A description of the tool. The language model uses this to understand the
|
||||
* tool's purpose and to provide better completion suggestions.
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* The parameters that the tool expects. The language model uses this to
|
||||
* understand the tool's input requirements and to provide matching suggestions.
|
||||
*/
|
||||
inputSchema: JSONSchema7;
|
||||
|
||||
/**
|
||||
* The provider-specific options for the tool.
|
||||
*/
|
||||
providerOptions?: SharedV2ProviderOptions;
|
||||
};
|
||||
+218
@@ -0,0 +1,218 @@
|
||||
import { JSONValue } from '../../json-value/json-value';
|
||||
import { SharedV2ProviderOptions } from '../../shared/v2/shared-v2-provider-options';
|
||||
import { LanguageModelV2DataContent } from './language-model-v2-data-content';
|
||||
|
||||
/**
|
||||
* A prompt is a list of messages.
|
||||
*
|
||||
* Note: Not all models and prompt formats support multi-modal inputs and
|
||||
* tool calls. The validation happens at runtime.
|
||||
*
|
||||
* Note: This is not a user-facing prompt. The AI SDK methods will map the
|
||||
* user-facing prompt types such as chat or instruction prompts to this format.
|
||||
*/
|
||||
export type LanguageModelV2Prompt = Array<LanguageModelV2Message>;
|
||||
|
||||
export type LanguageModelV2Message =
|
||||
// Note: there could be additional parts for each role in the future,
|
||||
// e.g. when the assistant can return images or the user can share files
|
||||
// such as PDFs.
|
||||
(
|
||||
| {
|
||||
role: 'system';
|
||||
content: string;
|
||||
}
|
||||
| {
|
||||
role: 'user';
|
||||
content: Array<LanguageModelV2TextPart | LanguageModelV2FilePart>;
|
||||
}
|
||||
| {
|
||||
role: 'assistant';
|
||||
content: Array<
|
||||
| LanguageModelV2TextPart
|
||||
| LanguageModelV2FilePart
|
||||
| LanguageModelV2ReasoningPart
|
||||
| LanguageModelV2ToolCallPart
|
||||
| LanguageModelV2ToolResultPart
|
||||
>;
|
||||
}
|
||||
| {
|
||||
role: 'tool';
|
||||
content: Array<LanguageModelV2ToolResultPart>;
|
||||
}
|
||||
) & {
|
||||
/**
|
||||
* Additional provider-specific options. They are passed through
|
||||
* to the provider from the AI SDK and enable provider-specific
|
||||
* functionality that can be fully encapsulated in the provider.
|
||||
*/
|
||||
providerOptions?: SharedV2ProviderOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Text content part of a prompt. It contains a string of text.
|
||||
*/
|
||||
export interface LanguageModelV2TextPart {
|
||||
type: 'text';
|
||||
|
||||
/**
|
||||
* The text content.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* Additional provider-specific options. They are passed through
|
||||
* to the provider from the AI SDK and enable provider-specific
|
||||
* functionality that can be fully encapsulated in the provider.
|
||||
*/
|
||||
providerOptions?: SharedV2ProviderOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reasoning content part of a prompt. It contains a string of reasoning text.
|
||||
*/
|
||||
export interface LanguageModelV2ReasoningPart {
|
||||
type: 'reasoning';
|
||||
|
||||
/**
|
||||
* The reasoning text.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* Additional provider-specific options. They are passed through
|
||||
* to the provider from the AI SDK and enable provider-specific
|
||||
* functionality that can be fully encapsulated in the provider.
|
||||
*/
|
||||
providerOptions?: SharedV2ProviderOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* File content part of a prompt. It contains a file.
|
||||
*/
|
||||
export interface LanguageModelV2FilePart {
|
||||
type: 'file';
|
||||
|
||||
/**
|
||||
* Optional filename of the file.
|
||||
*/
|
||||
filename?: string;
|
||||
|
||||
/**
|
||||
* File data. Can be a Uint8Array, base64 encoded data as a string or a URL.
|
||||
*/
|
||||
data: LanguageModelV2DataContent;
|
||||
|
||||
/**
|
||||
* IANA media type of the file.
|
||||
*
|
||||
* Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action).
|
||||
*
|
||||
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
||||
*/
|
||||
mediaType: string;
|
||||
|
||||
/**
|
||||
* Additional provider-specific options. They are passed through
|
||||
* to the provider from the AI SDK and enable provider-specific
|
||||
* functionality that can be fully encapsulated in the provider.
|
||||
*/
|
||||
providerOptions?: SharedV2ProviderOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
||||
*/
|
||||
export interface LanguageModelV2ToolCallPart {
|
||||
type: 'tool-call';
|
||||
|
||||
/**
|
||||
* ID of the tool call. This ID is used to match the tool call with the tool result.
|
||||
*/
|
||||
toolCallId: string;
|
||||
|
||||
/**
|
||||
* Name of the tool that is being called.
|
||||
*/
|
||||
toolName: string;
|
||||
|
||||
/**
|
||||
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
||||
*/
|
||||
input: unknown;
|
||||
|
||||
/**
|
||||
* Whether the tool call will be executed by the provider.
|
||||
* If this flag is not set or is false, the tool call will be executed by the client.
|
||||
*/
|
||||
providerExecuted?: boolean;
|
||||
|
||||
/**
|
||||
* Additional provider-specific options. They are passed through
|
||||
* to the provider from the AI SDK and enable provider-specific
|
||||
* functionality that can be fully encapsulated in the provider.
|
||||
*/
|
||||
providerOptions?: SharedV2ProviderOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
||||
*/
|
||||
export interface LanguageModelV2ToolResultPart {
|
||||
type: 'tool-result';
|
||||
|
||||
/**
|
||||
* ID of the tool call that this result is associated with.
|
||||
*/
|
||||
toolCallId: string;
|
||||
|
||||
/**
|
||||
* Name of the tool that generated this result.
|
||||
*/
|
||||
toolName: string;
|
||||
|
||||
/**
|
||||
* Result of the tool call.
|
||||
*/
|
||||
output: LanguageModelV2ToolResultOutput;
|
||||
|
||||
/**
|
||||
* Additional provider-specific options. They are passed through
|
||||
* to the provider from the AI SDK and enable provider-specific
|
||||
* functionality that can be fully encapsulated in the provider.
|
||||
*/
|
||||
providerOptions?: SharedV2ProviderOptions;
|
||||
}
|
||||
|
||||
export type LanguageModelV2ToolResultOutput =
|
||||
| { type: 'text'; value: string }
|
||||
| { type: 'json'; value: JSONValue }
|
||||
| { type: 'error-text'; value: string }
|
||||
| { type: 'error-json'; value: JSONValue }
|
||||
| {
|
||||
type: 'content';
|
||||
value: Array<
|
||||
| {
|
||||
type: 'text';
|
||||
|
||||
/**
|
||||
* Text content.
|
||||
*/
|
||||
text: string;
|
||||
}
|
||||
| {
|
||||
type: 'media';
|
||||
|
||||
/**
|
||||
* Base-64 encoded media data.
|
||||
*/
|
||||
data: string;
|
||||
|
||||
/**
|
||||
* IANA media type.
|
||||
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
||||
*/
|
||||
mediaType: string;
|
||||
}
|
||||
>;
|
||||
};
|
||||
Generated
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* The configuration of a tool that is defined by the provider.
|
||||
*/
|
||||
export type LanguageModelV2ProviderDefinedTool = {
|
||||
/**
|
||||
* The type of the tool (always 'provider-defined').
|
||||
*/
|
||||
type: 'provider-defined';
|
||||
|
||||
/**
|
||||
* The ID of the tool. Should follow the format `<provider-name>.<unique-tool-name>`.
|
||||
*/
|
||||
id: `${string}.${string}`;
|
||||
|
||||
/**
|
||||
* The name of the tool that the user must use in the tool set.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
|
||||
*/
|
||||
args: Record<string, unknown>;
|
||||
};
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
import { SharedV2ProviderMetadata } from '../../shared';
|
||||
|
||||
/**
|
||||
* Reasoning that the model has generated.
|
||||
*/
|
||||
export type LanguageModelV2Reasoning = {
|
||||
type: 'reasoning';
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* Optional provider-specific metadata for the reasoning part.
|
||||
*/
|
||||
providerMetadata?: SharedV2ProviderMetadata;
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user