@docsearch/js 4.0.0-beta.8 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/esm/index.d.ts +1640 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/umd/index.js +2 -2
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/index.d.ts
CHANGED
|
@@ -6669,6 +6669,1612 @@ declare type InsightsOption = {
|
|
|
6669
6669
|
interface AutocompleteOptions<TItem extends BaseItem> extends AutocompleteOptions$1<TItem>, InsightsOption {
|
|
6670
6670
|
}
|
|
6671
6671
|
|
|
6672
|
+
// ==================================================================================================
|
|
6673
|
+
// JSON Schema Draft 07
|
|
6674
|
+
// ==================================================================================================
|
|
6675
|
+
// https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
|
|
6676
|
+
// --------------------------------------------------------------------------------------------------
|
|
6677
|
+
|
|
6678
|
+
/**
|
|
6679
|
+
* Primitive type
|
|
6680
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
|
|
6681
|
+
*/
|
|
6682
|
+
type JSONSchema7TypeName =
|
|
6683
|
+
| "string" //
|
|
6684
|
+
| "number"
|
|
6685
|
+
| "integer"
|
|
6686
|
+
| "boolean"
|
|
6687
|
+
| "object"
|
|
6688
|
+
| "array"
|
|
6689
|
+
| "null";
|
|
6690
|
+
|
|
6691
|
+
/**
|
|
6692
|
+
* Primitive type
|
|
6693
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
|
|
6694
|
+
*/
|
|
6695
|
+
type JSONSchema7Type =
|
|
6696
|
+
| string //
|
|
6697
|
+
| number
|
|
6698
|
+
| boolean
|
|
6699
|
+
| JSONSchema7Object
|
|
6700
|
+
| JSONSchema7Array
|
|
6701
|
+
| null;
|
|
6702
|
+
|
|
6703
|
+
// Workaround for infinite type recursion
|
|
6704
|
+
interface JSONSchema7Object {
|
|
6705
|
+
[key: string]: JSONSchema7Type;
|
|
6706
|
+
}
|
|
6707
|
+
|
|
6708
|
+
// Workaround for infinite type recursion
|
|
6709
|
+
// https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
|
|
6710
|
+
interface JSONSchema7Array extends Array<JSONSchema7Type> {}
|
|
6711
|
+
|
|
6712
|
+
/**
|
|
6713
|
+
* Meta schema
|
|
6714
|
+
*
|
|
6715
|
+
* Recommended values:
|
|
6716
|
+
* - 'http://json-schema.org/schema#'
|
|
6717
|
+
* - 'http://json-schema.org/hyper-schema#'
|
|
6718
|
+
* - 'http://json-schema.org/draft-07/schema#'
|
|
6719
|
+
* - 'http://json-schema.org/draft-07/hyper-schema#'
|
|
6720
|
+
*
|
|
6721
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5
|
|
6722
|
+
*/
|
|
6723
|
+
type JSONSchema7Version = string;
|
|
6724
|
+
|
|
6725
|
+
/**
|
|
6726
|
+
* JSON Schema v7
|
|
6727
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
|
|
6728
|
+
*/
|
|
6729
|
+
type JSONSchema7Definition = JSONSchema7 | boolean;
|
|
6730
|
+
interface JSONSchema7 {
|
|
6731
|
+
$id?: string | undefined;
|
|
6732
|
+
$ref?: string | undefined;
|
|
6733
|
+
$schema?: JSONSchema7Version | undefined;
|
|
6734
|
+
$comment?: string | undefined;
|
|
6735
|
+
|
|
6736
|
+
/**
|
|
6737
|
+
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
|
|
6738
|
+
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
|
|
6739
|
+
*/
|
|
6740
|
+
$defs?: {
|
|
6741
|
+
[key: string]: JSONSchema7Definition;
|
|
6742
|
+
} | undefined;
|
|
6743
|
+
|
|
6744
|
+
/**
|
|
6745
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
|
|
6746
|
+
*/
|
|
6747
|
+
type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined;
|
|
6748
|
+
enum?: JSONSchema7Type[] | undefined;
|
|
6749
|
+
const?: JSONSchema7Type | undefined;
|
|
6750
|
+
|
|
6751
|
+
/**
|
|
6752
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
|
|
6753
|
+
*/
|
|
6754
|
+
multipleOf?: number | undefined;
|
|
6755
|
+
maximum?: number | undefined;
|
|
6756
|
+
exclusiveMaximum?: number | undefined;
|
|
6757
|
+
minimum?: number | undefined;
|
|
6758
|
+
exclusiveMinimum?: number | undefined;
|
|
6759
|
+
|
|
6760
|
+
/**
|
|
6761
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
|
|
6762
|
+
*/
|
|
6763
|
+
maxLength?: number | undefined;
|
|
6764
|
+
minLength?: number | undefined;
|
|
6765
|
+
pattern?: string | undefined;
|
|
6766
|
+
|
|
6767
|
+
/**
|
|
6768
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
|
|
6769
|
+
*/
|
|
6770
|
+
items?: JSONSchema7Definition | JSONSchema7Definition[] | undefined;
|
|
6771
|
+
additionalItems?: JSONSchema7Definition | undefined;
|
|
6772
|
+
maxItems?: number | undefined;
|
|
6773
|
+
minItems?: number | undefined;
|
|
6774
|
+
uniqueItems?: boolean | undefined;
|
|
6775
|
+
contains?: JSONSchema7Definition | undefined;
|
|
6776
|
+
|
|
6777
|
+
/**
|
|
6778
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
|
|
6779
|
+
*/
|
|
6780
|
+
maxProperties?: number | undefined;
|
|
6781
|
+
minProperties?: number | undefined;
|
|
6782
|
+
required?: string[] | undefined;
|
|
6783
|
+
properties?: {
|
|
6784
|
+
[key: string]: JSONSchema7Definition;
|
|
6785
|
+
} | undefined;
|
|
6786
|
+
patternProperties?: {
|
|
6787
|
+
[key: string]: JSONSchema7Definition;
|
|
6788
|
+
} | undefined;
|
|
6789
|
+
additionalProperties?: JSONSchema7Definition | undefined;
|
|
6790
|
+
dependencies?: {
|
|
6791
|
+
[key: string]: JSONSchema7Definition | string[];
|
|
6792
|
+
} | undefined;
|
|
6793
|
+
propertyNames?: JSONSchema7Definition | undefined;
|
|
6794
|
+
|
|
6795
|
+
/**
|
|
6796
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
|
|
6797
|
+
*/
|
|
6798
|
+
if?: JSONSchema7Definition | undefined;
|
|
6799
|
+
then?: JSONSchema7Definition | undefined;
|
|
6800
|
+
else?: JSONSchema7Definition | undefined;
|
|
6801
|
+
|
|
6802
|
+
/**
|
|
6803
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
|
|
6804
|
+
*/
|
|
6805
|
+
allOf?: JSONSchema7Definition[] | undefined;
|
|
6806
|
+
anyOf?: JSONSchema7Definition[] | undefined;
|
|
6807
|
+
oneOf?: JSONSchema7Definition[] | undefined;
|
|
6808
|
+
not?: JSONSchema7Definition | undefined;
|
|
6809
|
+
|
|
6810
|
+
/**
|
|
6811
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
|
|
6812
|
+
*/
|
|
6813
|
+
format?: string | undefined;
|
|
6814
|
+
|
|
6815
|
+
/**
|
|
6816
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
|
|
6817
|
+
*/
|
|
6818
|
+
contentMediaType?: string | undefined;
|
|
6819
|
+
contentEncoding?: string | undefined;
|
|
6820
|
+
|
|
6821
|
+
/**
|
|
6822
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
|
|
6823
|
+
*/
|
|
6824
|
+
definitions?: {
|
|
6825
|
+
[key: string]: JSONSchema7Definition;
|
|
6826
|
+
} | undefined;
|
|
6827
|
+
|
|
6828
|
+
/**
|
|
6829
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
|
|
6830
|
+
*/
|
|
6831
|
+
title?: string | undefined;
|
|
6832
|
+
description?: string | undefined;
|
|
6833
|
+
default?: JSONSchema7Type | undefined;
|
|
6834
|
+
readOnly?: boolean | undefined;
|
|
6835
|
+
writeOnly?: boolean | undefined;
|
|
6836
|
+
examples?: JSONSchema7Type | undefined;
|
|
6837
|
+
}
|
|
6838
|
+
|
|
6839
|
+
type SharedV2Headers = Record<string, string>;
|
|
6840
|
+
|
|
6841
|
+
/**
|
|
6842
|
+
A JSON value can be a string, number, boolean, object, array, or null.
|
|
6843
|
+
JSON values can be serialized and deserialized by the JSON.stringify and JSON.parse methods.
|
|
6844
|
+
*/
|
|
6845
|
+
type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
|
|
6846
|
+
type JSONObject = {
|
|
6847
|
+
[key: string]: JSONValue;
|
|
6848
|
+
};
|
|
6849
|
+
type JSONArray = JSONValue[];
|
|
6850
|
+
|
|
6851
|
+
/**
|
|
6852
|
+
* Additional provider-specific metadata.
|
|
6853
|
+
* Metadata are additional outputs from the provider.
|
|
6854
|
+
* They are passed through to the provider from the AI SDK
|
|
6855
|
+
* and enable provider-specific functionality
|
|
6856
|
+
* that can be fully encapsulated in the provider.
|
|
6857
|
+
*
|
|
6858
|
+
* This enables us to quickly ship provider-specific functionality
|
|
6859
|
+
* without affecting the core AI SDK.
|
|
6860
|
+
*
|
|
6861
|
+
* The outer record is keyed by the provider name, and the inner
|
|
6862
|
+
* record is keyed by the provider-specific metadata key.
|
|
6863
|
+
*
|
|
6864
|
+
* ```ts
|
|
6865
|
+
* {
|
|
6866
|
+
* "anthropic": {
|
|
6867
|
+
* "cacheControl": { "type": "ephemeral" }
|
|
6868
|
+
* }
|
|
6869
|
+
* }
|
|
6870
|
+
* ```
|
|
6871
|
+
*/
|
|
6872
|
+
type SharedV2ProviderMetadata = Record<string, Record<string, JSONValue>>;
|
|
6873
|
+
|
|
6874
|
+
/**
|
|
6875
|
+
* Additional provider-specific options.
|
|
6876
|
+
* Options are additional input to the provider.
|
|
6877
|
+
* They are passed through to the provider from the AI SDK
|
|
6878
|
+
* and enable provider-specific functionality
|
|
6879
|
+
* that can be fully encapsulated in the provider.
|
|
6880
|
+
*
|
|
6881
|
+
* This enables us to quickly ship provider-specific functionality
|
|
6882
|
+
* without affecting the core AI SDK.
|
|
6883
|
+
*
|
|
6884
|
+
* The outer record is keyed by the provider name, and the inner
|
|
6885
|
+
* record is keyed by the provider-specific metadata key.
|
|
6886
|
+
*
|
|
6887
|
+
* ```ts
|
|
6888
|
+
* {
|
|
6889
|
+
* "anthropic": {
|
|
6890
|
+
* "cacheControl": { "type": "ephemeral" }
|
|
6891
|
+
* }
|
|
6892
|
+
* }
|
|
6893
|
+
* ```
|
|
6894
|
+
*/
|
|
6895
|
+
type SharedV2ProviderOptions = Record<string, Record<string, JSONValue>>;
|
|
6896
|
+
|
|
6897
|
+
/**
|
|
6898
|
+
An embedding is a vector, i.e. an array of numbers.
|
|
6899
|
+
It is e.g. used to represent a text as a vector of word embeddings.
|
|
6900
|
+
*/
|
|
6901
|
+
type EmbeddingModelV2Embedding = Array<number>;
|
|
6902
|
+
|
|
6903
|
+
/**
|
|
6904
|
+
Specification for an embedding model that implements the embedding model
|
|
6905
|
+
interface version 1.
|
|
6906
|
+
|
|
6907
|
+
VALUE is the type of the values that the model can embed.
|
|
6908
|
+
This will allow us to go beyond text embeddings in the future,
|
|
6909
|
+
e.g. to support image embeddings
|
|
6910
|
+
*/
|
|
6911
|
+
type EmbeddingModelV2<VALUE> = {
|
|
6912
|
+
/**
|
|
6913
|
+
The embedding model must specify which embedding model interface
|
|
6914
|
+
version it implements. This will allow us to evolve the embedding
|
|
6915
|
+
model interface and retain backwards compatibility. The different
|
|
6916
|
+
implementation versions can be handled as a discriminated union
|
|
6917
|
+
on our side.
|
|
6918
|
+
*/
|
|
6919
|
+
readonly specificationVersion: 'v2';
|
|
6920
|
+
/**
|
|
6921
|
+
Name of the provider for logging purposes.
|
|
6922
|
+
*/
|
|
6923
|
+
readonly provider: string;
|
|
6924
|
+
/**
|
|
6925
|
+
Provider-specific model ID for logging purposes.
|
|
6926
|
+
*/
|
|
6927
|
+
readonly modelId: string;
|
|
6928
|
+
/**
|
|
6929
|
+
Limit of how many embeddings can be generated in a single API call.
|
|
6930
|
+
|
|
6931
|
+
Use Infinity for models that do not have a limit.
|
|
6932
|
+
*/
|
|
6933
|
+
readonly maxEmbeddingsPerCall: PromiseLike<number | undefined> | number | undefined;
|
|
6934
|
+
/**
|
|
6935
|
+
True if the model can handle multiple embedding calls in parallel.
|
|
6936
|
+
*/
|
|
6937
|
+
readonly supportsParallelCalls: PromiseLike<boolean> | boolean;
|
|
6938
|
+
/**
|
|
6939
|
+
Generates a list of embeddings for the given input text.
|
|
6940
|
+
|
|
6941
|
+
Naming: "do" prefix to prevent accidental direct usage of the method
|
|
6942
|
+
by the user.
|
|
6943
|
+
*/
|
|
6944
|
+
doEmbed(options: {
|
|
6945
|
+
/**
|
|
6946
|
+
List of values to embed.
|
|
6947
|
+
*/
|
|
6948
|
+
values: Array<VALUE>;
|
|
6949
|
+
/**
|
|
6950
|
+
Abort signal for cancelling the operation.
|
|
6951
|
+
*/
|
|
6952
|
+
abortSignal?: AbortSignal;
|
|
6953
|
+
/**
|
|
6954
|
+
Additional provider-specific options. They are passed through
|
|
6955
|
+
to the provider from the AI SDK and enable provider-specific
|
|
6956
|
+
functionality that can be fully encapsulated in the provider.
|
|
6957
|
+
*/
|
|
6958
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
6959
|
+
/**
|
|
6960
|
+
Additional HTTP headers to be sent with the request.
|
|
6961
|
+
Only applicable for HTTP-based providers.
|
|
6962
|
+
*/
|
|
6963
|
+
headers?: Record<string, string | undefined>;
|
|
6964
|
+
}): PromiseLike<{
|
|
6965
|
+
/**
|
|
6966
|
+
Generated embeddings. They are in the same order as the input values.
|
|
6967
|
+
*/
|
|
6968
|
+
embeddings: Array<EmbeddingModelV2Embedding>;
|
|
6969
|
+
/**
|
|
6970
|
+
Token usage. We only have input tokens for embeddings.
|
|
6971
|
+
*/
|
|
6972
|
+
usage?: {
|
|
6973
|
+
tokens: number;
|
|
6974
|
+
};
|
|
6975
|
+
/**
|
|
6976
|
+
Additional provider-specific metadata. They are passed through
|
|
6977
|
+
from the provider to the AI SDK and enable provider-specific
|
|
6978
|
+
results that can be fully encapsulated in the provider.
|
|
6979
|
+
*/
|
|
6980
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
6981
|
+
/**
|
|
6982
|
+
Optional response information for debugging purposes.
|
|
6983
|
+
*/
|
|
6984
|
+
response?: {
|
|
6985
|
+
/**
|
|
6986
|
+
Response headers.
|
|
6987
|
+
*/
|
|
6988
|
+
headers?: SharedV2Headers;
|
|
6989
|
+
/**
|
|
6990
|
+
The response body.
|
|
6991
|
+
*/
|
|
6992
|
+
body?: unknown;
|
|
6993
|
+
};
|
|
6994
|
+
}>;
|
|
6995
|
+
};
|
|
6996
|
+
|
|
6997
|
+
type ImageModelV2CallOptions = {
|
|
6998
|
+
/**
|
|
6999
|
+
Prompt for the image generation.
|
|
7000
|
+
*/
|
|
7001
|
+
prompt: string;
|
|
7002
|
+
/**
|
|
7003
|
+
Number of images to generate.
|
|
7004
|
+
*/
|
|
7005
|
+
n: number;
|
|
7006
|
+
/**
|
|
7007
|
+
Size of the images to generate.
|
|
7008
|
+
Must have the format `{width}x{height}`.
|
|
7009
|
+
`undefined` will use the provider's default size.
|
|
7010
|
+
*/
|
|
7011
|
+
size: `${number}x${number}` | undefined;
|
|
7012
|
+
/**
|
|
7013
|
+
Aspect ratio of the images to generate.
|
|
7014
|
+
Must have the format `{width}:{height}`.
|
|
7015
|
+
`undefined` will use the provider's default aspect ratio.
|
|
7016
|
+
*/
|
|
7017
|
+
aspectRatio: `${number}:${number}` | undefined;
|
|
7018
|
+
/**
|
|
7019
|
+
Seed for the image generation.
|
|
7020
|
+
`undefined` will use the provider's default seed.
|
|
7021
|
+
*/
|
|
7022
|
+
seed: number | undefined;
|
|
7023
|
+
/**
|
|
7024
|
+
Additional provider-specific options that are passed through to the provider
|
|
7025
|
+
as body parameters.
|
|
7026
|
+
|
|
7027
|
+
The outer record is keyed by the provider name, and the inner
|
|
7028
|
+
record is keyed by the provider-specific metadata key.
|
|
7029
|
+
```ts
|
|
7030
|
+
{
|
|
7031
|
+
"openai": {
|
|
7032
|
+
"style": "vivid"
|
|
7033
|
+
}
|
|
7034
|
+
}
|
|
7035
|
+
```
|
|
7036
|
+
*/
|
|
7037
|
+
providerOptions: SharedV2ProviderOptions;
|
|
7038
|
+
/**
|
|
7039
|
+
Abort signal for cancelling the operation.
|
|
7040
|
+
*/
|
|
7041
|
+
abortSignal?: AbortSignal;
|
|
7042
|
+
/**
|
|
7043
|
+
Additional HTTP headers to be sent with the request.
|
|
7044
|
+
Only applicable for HTTP-based providers.
|
|
7045
|
+
*/
|
|
7046
|
+
headers?: Record<string, string | undefined>;
|
|
7047
|
+
};
|
|
7048
|
+
|
|
7049
|
+
/**
|
|
7050
|
+
Warning from the model provider for this call. The call will proceed, but e.g.
|
|
7051
|
+
some settings might not be supported, which can lead to suboptimal results.
|
|
7052
|
+
*/
|
|
7053
|
+
type ImageModelV2CallWarning = {
|
|
7054
|
+
type: 'unsupported-setting';
|
|
7055
|
+
setting: keyof ImageModelV2CallOptions;
|
|
7056
|
+
details?: string;
|
|
7057
|
+
} | {
|
|
7058
|
+
type: 'other';
|
|
7059
|
+
message: string;
|
|
7060
|
+
};
|
|
7061
|
+
|
|
7062
|
+
type ImageModelV2ProviderMetadata = Record<string, {
|
|
7063
|
+
images: JSONArray;
|
|
7064
|
+
} & JSONValue>;
|
|
7065
|
+
type GetMaxImagesPerCallFunction = (options: {
|
|
7066
|
+
modelId: string;
|
|
7067
|
+
}) => PromiseLike<number | undefined> | number | undefined;
|
|
7068
|
+
/**
|
|
7069
|
+
Image generation model specification version 2.
|
|
7070
|
+
*/
|
|
7071
|
+
type ImageModelV2 = {
|
|
7072
|
+
/**
|
|
7073
|
+
The image model must specify which image model interface
|
|
7074
|
+
version it implements. This will allow us to evolve the image
|
|
7075
|
+
model interface and retain backwards compatibility. The different
|
|
7076
|
+
implementation versions can be handled as a discriminated union
|
|
7077
|
+
on our side.
|
|
7078
|
+
*/
|
|
7079
|
+
readonly specificationVersion: 'v2';
|
|
7080
|
+
/**
|
|
7081
|
+
Name of the provider for logging purposes.
|
|
7082
|
+
*/
|
|
7083
|
+
readonly provider: string;
|
|
7084
|
+
/**
|
|
7085
|
+
Provider-specific model ID for logging purposes.
|
|
7086
|
+
*/
|
|
7087
|
+
readonly modelId: string;
|
|
7088
|
+
/**
|
|
7089
|
+
Limit of how many images can be generated in a single API call.
|
|
7090
|
+
Can be set to a number for a fixed limit, to undefined to use
|
|
7091
|
+
the global limit, or a function that returns a number or undefined,
|
|
7092
|
+
optionally as a promise.
|
|
7093
|
+
*/
|
|
7094
|
+
readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction;
|
|
7095
|
+
/**
|
|
7096
|
+
Generates an array of images.
|
|
7097
|
+
*/
|
|
7098
|
+
doGenerate(options: ImageModelV2CallOptions): PromiseLike<{
|
|
7099
|
+
/**
|
|
7100
|
+
Generated images as base64 encoded strings or binary data.
|
|
7101
|
+
The images should be returned without any unnecessary conversion.
|
|
7102
|
+
If the API returns base64 encoded strings, the images should be returned
|
|
7103
|
+
as base64 encoded strings. If the API returns binary data, the images should
|
|
7104
|
+
be returned as binary data.
|
|
7105
|
+
*/
|
|
7106
|
+
images: Array<string> | Array<Uint8Array>;
|
|
7107
|
+
/**
|
|
7108
|
+
Warnings for the call, e.g. unsupported settings.
|
|
7109
|
+
*/
|
|
7110
|
+
warnings: Array<ImageModelV2CallWarning>;
|
|
7111
|
+
/**
|
|
7112
|
+
Additional provider-specific metadata. They are passed through
|
|
7113
|
+
from the provider to the AI SDK and enable provider-specific
|
|
7114
|
+
results that can be fully encapsulated in the provider.
|
|
7115
|
+
|
|
7116
|
+
The outer record is keyed by the provider name, and the inner
|
|
7117
|
+
record is provider-specific metadata. It always includes an
|
|
7118
|
+
`images` key with image-specific metadata
|
|
7119
|
+
|
|
7120
|
+
```ts
|
|
7121
|
+
{
|
|
7122
|
+
"openai": {
|
|
7123
|
+
"images": ["revisedPrompt": "Revised prompt here."]
|
|
7124
|
+
}
|
|
7125
|
+
}
|
|
7126
|
+
```
|
|
7127
|
+
*/
|
|
7128
|
+
providerMetadata?: ImageModelV2ProviderMetadata;
|
|
7129
|
+
/**
|
|
7130
|
+
Response information for telemetry and debugging purposes.
|
|
7131
|
+
*/
|
|
7132
|
+
response: {
|
|
7133
|
+
/**
|
|
7134
|
+
Timestamp for the start of the generated response.
|
|
7135
|
+
*/
|
|
7136
|
+
timestamp: Date;
|
|
7137
|
+
/**
|
|
7138
|
+
The ID of the response model that was used to generate the response.
|
|
7139
|
+
*/
|
|
7140
|
+
modelId: string;
|
|
7141
|
+
/**
|
|
7142
|
+
Response headers.
|
|
7143
|
+
*/
|
|
7144
|
+
headers: Record<string, string> | undefined;
|
|
7145
|
+
};
|
|
7146
|
+
}>;
|
|
7147
|
+
};
|
|
7148
|
+
|
|
7149
|
+
/**
|
|
7150
|
+
A tool has a name, a description, and a set of parameters.
|
|
7151
|
+
|
|
7152
|
+
Note: this is **not** the user-facing tool definition. The AI SDK methods will
|
|
7153
|
+
map the user-facing tool definitions to this format.
|
|
7154
|
+
*/
|
|
7155
|
+
type LanguageModelV2FunctionTool = {
|
|
7156
|
+
/**
|
|
7157
|
+
The type of the tool (always 'function').
|
|
7158
|
+
*/
|
|
7159
|
+
type: 'function';
|
|
7160
|
+
/**
|
|
7161
|
+
The name of the tool. Unique within this model call.
|
|
7162
|
+
*/
|
|
7163
|
+
name: string;
|
|
7164
|
+
/**
|
|
7165
|
+
A description of the tool. The language model uses this to understand the
|
|
7166
|
+
tool's purpose and to provide better completion suggestions.
|
|
7167
|
+
*/
|
|
7168
|
+
description?: string;
|
|
7169
|
+
/**
|
|
7170
|
+
The parameters that the tool expects. The language model uses this to
|
|
7171
|
+
understand the tool's input requirements and to provide matching suggestions.
|
|
7172
|
+
*/
|
|
7173
|
+
inputSchema: JSONSchema7;
|
|
7174
|
+
/**
|
|
7175
|
+
The provider-specific options for the tool.
|
|
7176
|
+
*/
|
|
7177
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
7178
|
+
};
|
|
7179
|
+
|
|
7180
|
+
/**
|
|
7181
|
+
Data content. Can be a Uint8Array, base64 encoded data as a string or a URL.
|
|
7182
|
+
*/
|
|
7183
|
+
type LanguageModelV2DataContent = Uint8Array | string | URL;
|
|
7184
|
+
|
|
7185
|
+
/**
|
|
7186
|
+
A prompt is a list of messages.
|
|
7187
|
+
|
|
7188
|
+
Note: Not all models and prompt formats support multi-modal inputs and
|
|
7189
|
+
tool calls. The validation happens at runtime.
|
|
7190
|
+
|
|
7191
|
+
Note: This is not a user-facing prompt. The AI SDK methods will map the
|
|
7192
|
+
user-facing prompt types such as chat or instruction prompts to this format.
|
|
7193
|
+
*/
|
|
7194
|
+
type LanguageModelV2Prompt = Array<LanguageModelV2Message>;
|
|
7195
|
+
type LanguageModelV2Message = ({
|
|
7196
|
+
role: 'system';
|
|
7197
|
+
content: string;
|
|
7198
|
+
} | {
|
|
7199
|
+
role: 'user';
|
|
7200
|
+
content: Array<LanguageModelV2TextPart | LanguageModelV2FilePart>;
|
|
7201
|
+
} | {
|
|
7202
|
+
role: 'assistant';
|
|
7203
|
+
content: Array<LanguageModelV2TextPart | LanguageModelV2FilePart | LanguageModelV2ReasoningPart | LanguageModelV2ToolCallPart | LanguageModelV2ToolResultPart>;
|
|
7204
|
+
} | {
|
|
7205
|
+
role: 'tool';
|
|
7206
|
+
content: Array<LanguageModelV2ToolResultPart>;
|
|
7207
|
+
}) & {
|
|
7208
|
+
/**
|
|
7209
|
+
* Additional provider-specific options. They are passed through
|
|
7210
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
7211
|
+
* functionality that can be fully encapsulated in the provider.
|
|
7212
|
+
*/
|
|
7213
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
7214
|
+
};
|
|
7215
|
+
/**
|
|
7216
|
+
Text content part of a prompt. It contains a string of text.
|
|
7217
|
+
*/
|
|
7218
|
+
interface LanguageModelV2TextPart {
|
|
7219
|
+
type: 'text';
|
|
7220
|
+
/**
|
|
7221
|
+
The text content.
|
|
7222
|
+
*/
|
|
7223
|
+
text: string;
|
|
7224
|
+
/**
|
|
7225
|
+
* Additional provider-specific options. They are passed through
|
|
7226
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
7227
|
+
* functionality that can be fully encapsulated in the provider.
|
|
7228
|
+
*/
|
|
7229
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
7230
|
+
}
|
|
7231
|
+
/**
|
|
7232
|
+
Reasoning content part of a prompt. It contains a string of reasoning text.
|
|
7233
|
+
*/
|
|
7234
|
+
interface LanguageModelV2ReasoningPart {
|
|
7235
|
+
type: 'reasoning';
|
|
7236
|
+
/**
|
|
7237
|
+
The reasoning text.
|
|
7238
|
+
*/
|
|
7239
|
+
text: string;
|
|
7240
|
+
/**
|
|
7241
|
+
* Additional provider-specific options. They are passed through
|
|
7242
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
7243
|
+
* functionality that can be fully encapsulated in the provider.
|
|
7244
|
+
*/
|
|
7245
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
7246
|
+
}
|
|
7247
|
+
/**
|
|
7248
|
+
File content part of a prompt. It contains a file.
|
|
7249
|
+
*/
|
|
7250
|
+
interface LanguageModelV2FilePart {
|
|
7251
|
+
type: 'file';
|
|
7252
|
+
/**
|
|
7253
|
+
* Optional filename of the file.
|
|
7254
|
+
*/
|
|
7255
|
+
filename?: string;
|
|
7256
|
+
/**
|
|
7257
|
+
File data. Can be a Uint8Array, base64 encoded data as a string or a URL.
|
|
7258
|
+
*/
|
|
7259
|
+
data: LanguageModelV2DataContent;
|
|
7260
|
+
/**
|
|
7261
|
+
IANA media type of the file.
|
|
7262
|
+
|
|
7263
|
+
Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action).
|
|
7264
|
+
|
|
7265
|
+
@see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
7266
|
+
*/
|
|
7267
|
+
mediaType: string;
|
|
7268
|
+
/**
|
|
7269
|
+
* Additional provider-specific options. They are passed through
|
|
7270
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
7271
|
+
* functionality that can be fully encapsulated in the provider.
|
|
7272
|
+
*/
|
|
7273
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
7274
|
+
}
|
|
7275
|
+
/**
|
|
7276
|
+
Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
|
7277
|
+
*/
|
|
7278
|
+
interface LanguageModelV2ToolCallPart {
|
|
7279
|
+
type: 'tool-call';
|
|
7280
|
+
/**
|
|
7281
|
+
ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
7282
|
+
*/
|
|
7283
|
+
toolCallId: string;
|
|
7284
|
+
/**
|
|
7285
|
+
Name of the tool that is being called.
|
|
7286
|
+
*/
|
|
7287
|
+
toolName: string;
|
|
7288
|
+
/**
|
|
7289
|
+
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
|
7290
|
+
*/
|
|
7291
|
+
input: unknown;
|
|
7292
|
+
/**
|
|
7293
|
+
* Whether the tool call will be executed by the provider.
|
|
7294
|
+
* If this flag is not set or is false, the tool call will be executed by the client.
|
|
7295
|
+
*/
|
|
7296
|
+
providerExecuted?: boolean;
|
|
7297
|
+
/**
|
|
7298
|
+
* Additional provider-specific options. They are passed through
|
|
7299
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
7300
|
+
* functionality that can be fully encapsulated in the provider.
|
|
7301
|
+
*/
|
|
7302
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
7303
|
+
}
|
|
7304
|
+
/**
|
|
7305
|
+
Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
|
7306
|
+
*/
|
|
7307
|
+
interface LanguageModelV2ToolResultPart {
|
|
7308
|
+
type: 'tool-result';
|
|
7309
|
+
/**
|
|
7310
|
+
ID of the tool call that this result is associated with.
|
|
7311
|
+
*/
|
|
7312
|
+
toolCallId: string;
|
|
7313
|
+
/**
|
|
7314
|
+
Name of the tool that generated this result.
|
|
7315
|
+
*/
|
|
7316
|
+
toolName: string;
|
|
7317
|
+
/**
|
|
7318
|
+
Result of the tool call.
|
|
7319
|
+
*/
|
|
7320
|
+
output: LanguageModelV2ToolResultOutput;
|
|
7321
|
+
/**
|
|
7322
|
+
* Additional provider-specific options. They are passed through
|
|
7323
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
7324
|
+
* functionality that can be fully encapsulated in the provider.
|
|
7325
|
+
*/
|
|
7326
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
7327
|
+
}
|
|
7328
|
+
type LanguageModelV2ToolResultOutput = {
|
|
7329
|
+
type: 'text';
|
|
7330
|
+
value: string;
|
|
7331
|
+
} | {
|
|
7332
|
+
type: 'json';
|
|
7333
|
+
value: JSONValue;
|
|
7334
|
+
} | {
|
|
7335
|
+
type: 'error-text';
|
|
7336
|
+
value: string;
|
|
7337
|
+
} | {
|
|
7338
|
+
type: 'error-json';
|
|
7339
|
+
value: JSONValue;
|
|
7340
|
+
} | {
|
|
7341
|
+
type: 'content';
|
|
7342
|
+
value: Array<{
|
|
7343
|
+
type: 'text';
|
|
7344
|
+
/**
|
|
7345
|
+
Text content.
|
|
7346
|
+
*/
|
|
7347
|
+
text: string;
|
|
7348
|
+
} | {
|
|
7349
|
+
type: 'media';
|
|
7350
|
+
/**
|
|
7351
|
+
Base-64 encoded media data.
|
|
7352
|
+
*/
|
|
7353
|
+
data: string;
|
|
7354
|
+
/**
|
|
7355
|
+
IANA media type.
|
|
7356
|
+
@see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
7357
|
+
*/
|
|
7358
|
+
mediaType: string;
|
|
7359
|
+
}>;
|
|
7360
|
+
};
|
|
7361
|
+
|
|
7362
|
+
/**
|
|
7363
|
+
The configuration of a tool that is defined by the provider.
|
|
7364
|
+
*/
|
|
7365
|
+
type LanguageModelV2ProviderDefinedTool = {
|
|
7366
|
+
/**
|
|
7367
|
+
The type of the tool (always 'provider-defined').
|
|
7368
|
+
*/
|
|
7369
|
+
type: 'provider-defined';
|
|
7370
|
+
/**
|
|
7371
|
+
The ID of the tool. Should follow the format `<provider-name>.<unique-tool-name>`.
|
|
7372
|
+
*/
|
|
7373
|
+
id: `${string}.${string}`;
|
|
7374
|
+
/**
|
|
7375
|
+
The name of the tool that the user must use in the tool set.
|
|
7376
|
+
*/
|
|
7377
|
+
name: string;
|
|
7378
|
+
/**
|
|
7379
|
+
The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
|
|
7380
|
+
*/
|
|
7381
|
+
args: Record<string, unknown>;
|
|
7382
|
+
};
|
|
7383
|
+
|
|
7384
|
+
type LanguageModelV2ToolChoice = {
|
|
7385
|
+
type: 'auto';
|
|
7386
|
+
} | {
|
|
7387
|
+
type: 'none';
|
|
7388
|
+
} | {
|
|
7389
|
+
type: 'required';
|
|
7390
|
+
} | {
|
|
7391
|
+
type: 'tool';
|
|
7392
|
+
toolName: string;
|
|
7393
|
+
};
|
|
7394
|
+
|
|
7395
|
+
type LanguageModelV2CallOptions = {
|
|
7396
|
+
/**
|
|
7397
|
+
A language mode prompt is a standardized prompt type.
|
|
7398
|
+
|
|
7399
|
+
Note: This is **not** the user-facing prompt. The AI SDK methods will map the
|
|
7400
|
+
user-facing prompt types such as chat or instruction prompts to this format.
|
|
7401
|
+
That approach allows us to evolve the user facing prompts without breaking
|
|
7402
|
+
the language model interface.
|
|
7403
|
+
*/
|
|
7404
|
+
prompt: LanguageModelV2Prompt;
|
|
7405
|
+
/**
|
|
7406
|
+
Maximum number of tokens to generate.
|
|
7407
|
+
*/
|
|
7408
|
+
maxOutputTokens?: number;
|
|
7409
|
+
/**
|
|
7410
|
+
Temperature setting. The range depends on the provider and model.
|
|
7411
|
+
*/
|
|
7412
|
+
temperature?: number;
|
|
7413
|
+
/**
|
|
7414
|
+
Stop sequences.
|
|
7415
|
+
If set, the model will stop generating text when one of the stop sequences is generated.
|
|
7416
|
+
Providers may have limits on the number of stop sequences.
|
|
7417
|
+
*/
|
|
7418
|
+
stopSequences?: string[];
|
|
7419
|
+
/**
|
|
7420
|
+
Nucleus sampling.
|
|
7421
|
+
*/
|
|
7422
|
+
topP?: number;
|
|
7423
|
+
/**
|
|
7424
|
+
Only sample from the top K options for each subsequent token.
|
|
7425
|
+
|
|
7426
|
+
Used to remove "long tail" low probability responses.
|
|
7427
|
+
Recommended for advanced use cases only. You usually only need to use temperature.
|
|
7428
|
+
*/
|
|
7429
|
+
topK?: number;
|
|
7430
|
+
/**
|
|
7431
|
+
Presence penalty setting. It affects the likelihood of the model to
|
|
7432
|
+
repeat information that is already in the prompt.
|
|
7433
|
+
*/
|
|
7434
|
+
presencePenalty?: number;
|
|
7435
|
+
/**
|
|
7436
|
+
Frequency penalty setting. It affects the likelihood of the model
|
|
7437
|
+
to repeatedly use the same words or phrases.
|
|
7438
|
+
*/
|
|
7439
|
+
frequencyPenalty?: number;
|
|
7440
|
+
/**
|
|
7441
|
+
Response format. The output can either be text or JSON. Default is text.
|
|
7442
|
+
|
|
7443
|
+
If JSON is selected, a schema can optionally be provided to guide the LLM.
|
|
7444
|
+
*/
|
|
7445
|
+
responseFormat?: {
|
|
7446
|
+
type: 'text';
|
|
7447
|
+
} | {
|
|
7448
|
+
type: 'json';
|
|
7449
|
+
/**
|
|
7450
|
+
* JSON schema that the generated output should conform to.
|
|
7451
|
+
*/
|
|
7452
|
+
schema?: JSONSchema7;
|
|
7453
|
+
/**
|
|
7454
|
+
* Name of output that should be generated. Used by some providers for additional LLM guidance.
|
|
7455
|
+
*/
|
|
7456
|
+
name?: string;
|
|
7457
|
+
/**
|
|
7458
|
+
* Description of the output that should be generated. Used by some providers for additional LLM guidance.
|
|
7459
|
+
*/
|
|
7460
|
+
description?: string;
|
|
7461
|
+
};
|
|
7462
|
+
/**
|
|
7463
|
+
The seed (integer) to use for random sampling. If set and supported
|
|
7464
|
+
by the model, calls will generate deterministic results.
|
|
7465
|
+
*/
|
|
7466
|
+
seed?: number;
|
|
7467
|
+
/**
|
|
7468
|
+
The tools that are available for the model.
|
|
7469
|
+
*/
|
|
7470
|
+
tools?: Array<LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool>;
|
|
7471
|
+
/**
|
|
7472
|
+
Specifies how the tool should be selected. Defaults to 'auto'.
|
|
7473
|
+
*/
|
|
7474
|
+
toolChoice?: LanguageModelV2ToolChoice;
|
|
7475
|
+
/**
|
|
7476
|
+
Include raw chunks in the stream. Only applicable for streaming calls.
|
|
7477
|
+
*/
|
|
7478
|
+
includeRawChunks?: boolean;
|
|
7479
|
+
/**
|
|
7480
|
+
Abort signal for cancelling the operation.
|
|
7481
|
+
*/
|
|
7482
|
+
abortSignal?: AbortSignal;
|
|
7483
|
+
/**
|
|
7484
|
+
Additional HTTP headers to be sent with the request.
|
|
7485
|
+
Only applicable for HTTP-based providers.
|
|
7486
|
+
*/
|
|
7487
|
+
headers?: Record<string, string | undefined>;
|
|
7488
|
+
/**
|
|
7489
|
+
* Additional provider-specific options. They are passed through
|
|
7490
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
7491
|
+
* functionality that can be fully encapsulated in the provider.
|
|
7492
|
+
*/
|
|
7493
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
7494
|
+
};
|
|
7495
|
+
|
|
7496
|
+
/**
|
|
7497
|
+
Warning from the model provider for this call. The call will proceed, but e.g.
|
|
7498
|
+
some settings might not be supported, which can lead to suboptimal results.
|
|
7499
|
+
*/
|
|
7500
|
+
type LanguageModelV2CallWarning = {
|
|
7501
|
+
type: 'unsupported-setting';
|
|
7502
|
+
setting: Omit<keyof LanguageModelV2CallOptions, 'prompt'>;
|
|
7503
|
+
details?: string;
|
|
7504
|
+
} | {
|
|
7505
|
+
type: 'unsupported-tool';
|
|
7506
|
+
tool: LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool;
|
|
7507
|
+
details?: string;
|
|
7508
|
+
} | {
|
|
7509
|
+
type: 'other';
|
|
7510
|
+
message: string;
|
|
7511
|
+
};
|
|
7512
|
+
|
|
7513
|
+
/**
|
|
7514
|
+
A file that has been generated by the model.
|
|
7515
|
+
Generated files as base64 encoded strings or binary data.
|
|
7516
|
+
The files should be returned without any unnecessary conversion.
|
|
7517
|
+
*/
|
|
7518
|
+
type LanguageModelV2File = {
|
|
7519
|
+
type: 'file';
|
|
7520
|
+
/**
|
|
7521
|
+
The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
|
|
7522
|
+
|
|
7523
|
+
@see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
7524
|
+
*/
|
|
7525
|
+
mediaType: string;
|
|
7526
|
+
/**
|
|
7527
|
+
Generated file data as base64 encoded strings or binary data.
|
|
7528
|
+
|
|
7529
|
+
The file data should be returned without any unnecessary conversion.
|
|
7530
|
+
If the API returns base64 encoded strings, the file data should be returned
|
|
7531
|
+
as base64 encoded strings. If the API returns binary data, the file data should
|
|
7532
|
+
be returned as binary data.
|
|
7533
|
+
*/
|
|
7534
|
+
data: string | Uint8Array;
|
|
7535
|
+
};
|
|
7536
|
+
|
|
7537
|
+
/**
|
|
7538
|
+
Reasoning that the model has generated.
|
|
7539
|
+
*/
|
|
7540
|
+
type LanguageModelV2Reasoning = {
|
|
7541
|
+
type: 'reasoning';
|
|
7542
|
+
text: string;
|
|
7543
|
+
/**
|
|
7544
|
+
* Optional provider-specific metadata for the reasoning part.
|
|
7545
|
+
*/
|
|
7546
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7547
|
+
};
|
|
7548
|
+
|
|
7549
|
+
/**
|
|
7550
|
+
A source that has been used as input to generate the response.
|
|
7551
|
+
*/
|
|
7552
|
+
type LanguageModelV2Source = {
|
|
7553
|
+
type: 'source';
|
|
7554
|
+
/**
|
|
7555
|
+
* The type of source - URL sources reference web content.
|
|
7556
|
+
*/
|
|
7557
|
+
sourceType: 'url';
|
|
7558
|
+
/**
|
|
7559
|
+
* The ID of the source.
|
|
7560
|
+
*/
|
|
7561
|
+
id: string;
|
|
7562
|
+
/**
|
|
7563
|
+
* The URL of the source.
|
|
7564
|
+
*/
|
|
7565
|
+
url: string;
|
|
7566
|
+
/**
|
|
7567
|
+
* The title of the source.
|
|
7568
|
+
*/
|
|
7569
|
+
title?: string;
|
|
7570
|
+
/**
|
|
7571
|
+
* Additional provider metadata for the source.
|
|
7572
|
+
*/
|
|
7573
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7574
|
+
} | {
|
|
7575
|
+
type: 'source';
|
|
7576
|
+
/**
|
|
7577
|
+
* The type of source - document sources reference files/documents.
|
|
7578
|
+
*/
|
|
7579
|
+
sourceType: 'document';
|
|
7580
|
+
/**
|
|
7581
|
+
* The ID of the source.
|
|
7582
|
+
*/
|
|
7583
|
+
id: string;
|
|
7584
|
+
/**
|
|
7585
|
+
* IANA media type of the document (e.g., 'application/pdf').
|
|
7586
|
+
*/
|
|
7587
|
+
mediaType: string;
|
|
7588
|
+
/**
|
|
7589
|
+
* The title of the document.
|
|
7590
|
+
*/
|
|
7591
|
+
title: string;
|
|
7592
|
+
/**
|
|
7593
|
+
* Optional filename of the document.
|
|
7594
|
+
*/
|
|
7595
|
+
filename?: string;
|
|
7596
|
+
/**
|
|
7597
|
+
* Additional provider metadata for the source.
|
|
7598
|
+
*/
|
|
7599
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7600
|
+
};
|
|
7601
|
+
|
|
7602
|
+
/**
|
|
7603
|
+
Text that the model has generated.
|
|
7604
|
+
*/
|
|
7605
|
+
type LanguageModelV2Text = {
|
|
7606
|
+
type: 'text';
|
|
7607
|
+
/**
|
|
7608
|
+
The text content.
|
|
7609
|
+
*/
|
|
7610
|
+
text: string;
|
|
7611
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7612
|
+
};
|
|
7613
|
+
|
|
7614
|
+
/**
|
|
7615
|
+
Tool calls that the model has generated.
|
|
7616
|
+
*/
|
|
7617
|
+
type LanguageModelV2ToolCall = {
|
|
7618
|
+
type: 'tool-call';
|
|
7619
|
+
toolCallId: string;
|
|
7620
|
+
toolName: string;
|
|
7621
|
+
/**
|
|
7622
|
+
Stringified JSON object with the tool call arguments. Must match the
|
|
7623
|
+
parameters schema of the tool.
|
|
7624
|
+
*/
|
|
7625
|
+
input: string;
|
|
7626
|
+
/**
|
|
7627
|
+
* Whether the tool call will be executed by the provider.
|
|
7628
|
+
* If this flag is not set or is false, the tool call will be executed by the client.
|
|
7629
|
+
*/
|
|
7630
|
+
providerExecuted?: boolean;
|
|
7631
|
+
/**
|
|
7632
|
+
* Additional provider-specific metadata for the tool call.
|
|
7633
|
+
*/
|
|
7634
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7635
|
+
};
|
|
7636
|
+
|
|
7637
|
+
/**
|
|
7638
|
+
Result of a tool call that has been executed by the provider.
|
|
7639
|
+
*/
|
|
7640
|
+
type LanguageModelV2ToolResult = {
|
|
7641
|
+
type: 'tool-result';
|
|
7642
|
+
/**
|
|
7643
|
+
* The ID of the tool call that this result is associated with.
|
|
7644
|
+
*/
|
|
7645
|
+
toolCallId: string;
|
|
7646
|
+
/**
|
|
7647
|
+
* Name of the tool that generated this result.
|
|
7648
|
+
*/
|
|
7649
|
+
toolName: string;
|
|
7650
|
+
/**
|
|
7651
|
+
* Result of the tool call. This is a JSON-serializable object.
|
|
7652
|
+
*/
|
|
7653
|
+
result: unknown;
|
|
7654
|
+
/**
|
|
7655
|
+
* Optional flag if the result is an error or an error message.
|
|
7656
|
+
*/
|
|
7657
|
+
isError?: boolean;
|
|
7658
|
+
/**
|
|
7659
|
+
* Whether the tool result was generated by the provider.
|
|
7660
|
+
* If this flag is set to true, the tool result was generated by the provider.
|
|
7661
|
+
* If this flag is not set or is false, the tool result was generated by the client.
|
|
7662
|
+
*/
|
|
7663
|
+
providerExecuted?: boolean;
|
|
7664
|
+
/**
|
|
7665
|
+
* Additional provider-specific metadata for the tool result.
|
|
7666
|
+
*/
|
|
7667
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7668
|
+
};
|
|
7669
|
+
|
|
7670
|
+
type LanguageModelV2Content = LanguageModelV2Text | LanguageModelV2Reasoning | LanguageModelV2File | LanguageModelV2Source | LanguageModelV2ToolCall | LanguageModelV2ToolResult;
|
|
7671
|
+
|
|
7672
|
+
/**
|
|
7673
|
+
Reason why a language model finished generating a response.
|
|
7674
|
+
|
|
7675
|
+
Can be one of the following:
|
|
7676
|
+
- `stop`: model generated stop sequence
|
|
7677
|
+
- `length`: model generated maximum number of tokens
|
|
7678
|
+
- `content-filter`: content filter violation stopped the model
|
|
7679
|
+
- `tool-calls`: model triggered tool calls
|
|
7680
|
+
- `error`: model stopped because of an error
|
|
7681
|
+
- `other`: model stopped for other reasons
|
|
7682
|
+
- `unknown`: the model has not transmitted a finish reason
|
|
7683
|
+
*/
|
|
7684
|
+
type LanguageModelV2FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown';
|
|
7685
|
+
|
|
7686
|
+
interface LanguageModelV2ResponseMetadata {
|
|
7687
|
+
/**
|
|
7688
|
+
ID for the generated response, if the provider sends one.
|
|
7689
|
+
*/
|
|
7690
|
+
id?: string;
|
|
7691
|
+
/**
|
|
7692
|
+
Timestamp for the start of the generated response, if the provider sends one.
|
|
7693
|
+
*/
|
|
7694
|
+
timestamp?: Date;
|
|
7695
|
+
/**
|
|
7696
|
+
The ID of the response model that was used to generate the response, if the provider sends one.
|
|
7697
|
+
*/
|
|
7698
|
+
modelId?: string;
|
|
7699
|
+
}
|
|
7700
|
+
|
|
7701
|
+
/**
|
|
7702
|
+
Usage information for a language model call.
|
|
7703
|
+
|
|
7704
|
+
If your API return additional usage information, you can add it to the
|
|
7705
|
+
provider metadata under your provider's key.
|
|
7706
|
+
*/
|
|
7707
|
+
type LanguageModelV2Usage = {
|
|
7708
|
+
/**
|
|
7709
|
+
The number of input (prompt) tokens used.
|
|
7710
|
+
*/
|
|
7711
|
+
inputTokens: number | undefined;
|
|
7712
|
+
/**
|
|
7713
|
+
The number of output (completion) tokens used.
|
|
7714
|
+
*/
|
|
7715
|
+
outputTokens: number | undefined;
|
|
7716
|
+
/**
|
|
7717
|
+
The total number of tokens as reported by the provider.
|
|
7718
|
+
This number might be different from the sum of `inputTokens` and `outputTokens`
|
|
7719
|
+
and e.g. include reasoning tokens or other overhead.
|
|
7720
|
+
*/
|
|
7721
|
+
totalTokens: number | undefined;
|
|
7722
|
+
/**
|
|
7723
|
+
The number of reasoning tokens used.
|
|
7724
|
+
*/
|
|
7725
|
+
reasoningTokens?: number | undefined;
|
|
7726
|
+
/**
|
|
7727
|
+
The number of cached input tokens.
|
|
7728
|
+
*/
|
|
7729
|
+
cachedInputTokens?: number | undefined;
|
|
7730
|
+
};
|
|
7731
|
+
|
|
7732
|
+
type LanguageModelV2StreamPart = {
|
|
7733
|
+
type: 'text-start';
|
|
7734
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7735
|
+
id: string;
|
|
7736
|
+
} | {
|
|
7737
|
+
type: 'text-delta';
|
|
7738
|
+
id: string;
|
|
7739
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7740
|
+
delta: string;
|
|
7741
|
+
} | {
|
|
7742
|
+
type: 'text-end';
|
|
7743
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7744
|
+
id: string;
|
|
7745
|
+
} | {
|
|
7746
|
+
type: 'reasoning-start';
|
|
7747
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7748
|
+
id: string;
|
|
7749
|
+
} | {
|
|
7750
|
+
type: 'reasoning-delta';
|
|
7751
|
+
id: string;
|
|
7752
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7753
|
+
delta: string;
|
|
7754
|
+
} | {
|
|
7755
|
+
type: 'reasoning-end';
|
|
7756
|
+
id: string;
|
|
7757
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7758
|
+
} | {
|
|
7759
|
+
type: 'tool-input-start';
|
|
7760
|
+
id: string;
|
|
7761
|
+
toolName: string;
|
|
7762
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7763
|
+
providerExecuted?: boolean;
|
|
7764
|
+
} | {
|
|
7765
|
+
type: 'tool-input-delta';
|
|
7766
|
+
id: string;
|
|
7767
|
+
delta: string;
|
|
7768
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7769
|
+
} | {
|
|
7770
|
+
type: 'tool-input-end';
|
|
7771
|
+
id: string;
|
|
7772
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7773
|
+
} | LanguageModelV2ToolCall | LanguageModelV2ToolResult | LanguageModelV2File | LanguageModelV2Source | {
|
|
7774
|
+
type: 'stream-start';
|
|
7775
|
+
warnings: Array<LanguageModelV2CallWarning>;
|
|
7776
|
+
} | ({
|
|
7777
|
+
type: 'response-metadata';
|
|
7778
|
+
} & LanguageModelV2ResponseMetadata) | {
|
|
7779
|
+
type: 'finish';
|
|
7780
|
+
usage: LanguageModelV2Usage;
|
|
7781
|
+
finishReason: LanguageModelV2FinishReason;
|
|
7782
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7783
|
+
} | {
|
|
7784
|
+
type: 'raw';
|
|
7785
|
+
rawValue: unknown;
|
|
7786
|
+
} | {
|
|
7787
|
+
type: 'error';
|
|
7788
|
+
error: unknown;
|
|
7789
|
+
};
|
|
7790
|
+
|
|
7791
|
+
/**
|
|
7792
|
+
Specification for a language model that implements the language model interface version 2.
|
|
7793
|
+
*/
|
|
7794
|
+
type LanguageModelV2 = {
|
|
7795
|
+
/**
|
|
7796
|
+
The language model must specify which language model interface version it implements.
|
|
7797
|
+
*/
|
|
7798
|
+
readonly specificationVersion: 'v2';
|
|
7799
|
+
/**
|
|
7800
|
+
Name of the provider for logging purposes.
|
|
7801
|
+
*/
|
|
7802
|
+
readonly provider: string;
|
|
7803
|
+
/**
|
|
7804
|
+
Provider-specific model ID for logging purposes.
|
|
7805
|
+
*/
|
|
7806
|
+
readonly modelId: string;
|
|
7807
|
+
/**
|
|
7808
|
+
Supported URL patterns by media type for the provider.
|
|
7809
|
+
|
|
7810
|
+
The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`).
|
|
7811
|
+
and the values are arrays of regular expressions that match the URL paths.
|
|
7812
|
+
|
|
7813
|
+
The matching should be against lower-case URLs.
|
|
7814
|
+
|
|
7815
|
+
Matched URLs are supported natively by the model and are not downloaded.
|
|
7816
|
+
|
|
7817
|
+
@returns A map of supported URL patterns by media type (as a promise or a plain object).
|
|
7818
|
+
*/
|
|
7819
|
+
supportedUrls: PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
|
7820
|
+
/**
|
|
7821
|
+
Generates a language model output (non-streaming).
|
|
7822
|
+
|
|
7823
|
+
Naming: "do" prefix to prevent accidental direct usage of the method
|
|
7824
|
+
by the user.
|
|
7825
|
+
*/
|
|
7826
|
+
doGenerate(options: LanguageModelV2CallOptions): PromiseLike<{
|
|
7827
|
+
/**
|
|
7828
|
+
Ordered content that the model has generated.
|
|
7829
|
+
*/
|
|
7830
|
+
content: Array<LanguageModelV2Content>;
|
|
7831
|
+
/**
|
|
7832
|
+
Finish reason.
|
|
7833
|
+
*/
|
|
7834
|
+
finishReason: LanguageModelV2FinishReason;
|
|
7835
|
+
/**
|
|
7836
|
+
Usage information.
|
|
7837
|
+
*/
|
|
7838
|
+
usage: LanguageModelV2Usage;
|
|
7839
|
+
/**
|
|
7840
|
+
Additional provider-specific metadata. They are passed through
|
|
7841
|
+
from the provider to the AI SDK and enable provider-specific
|
|
7842
|
+
results that can be fully encapsulated in the provider.
|
|
7843
|
+
*/
|
|
7844
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
7845
|
+
/**
|
|
7846
|
+
Optional request information for telemetry and debugging purposes.
|
|
7847
|
+
*/
|
|
7848
|
+
request?: {
|
|
7849
|
+
/**
|
|
7850
|
+
Request HTTP body that was sent to the provider API.
|
|
7851
|
+
*/
|
|
7852
|
+
body?: unknown;
|
|
7853
|
+
};
|
|
7854
|
+
/**
|
|
7855
|
+
Optional response information for telemetry and debugging purposes.
|
|
7856
|
+
*/
|
|
7857
|
+
response?: LanguageModelV2ResponseMetadata & {
|
|
7858
|
+
/**
|
|
7859
|
+
Response headers.
|
|
7860
|
+
*/
|
|
7861
|
+
headers?: SharedV2Headers;
|
|
7862
|
+
/**
|
|
7863
|
+
Response HTTP body.
|
|
7864
|
+
*/
|
|
7865
|
+
body?: unknown;
|
|
7866
|
+
};
|
|
7867
|
+
/**
|
|
7868
|
+
Warnings for the call, e.g. unsupported settings.
|
|
7869
|
+
*/
|
|
7870
|
+
warnings: Array<LanguageModelV2CallWarning>;
|
|
7871
|
+
}>;
|
|
7872
|
+
/**
|
|
7873
|
+
Generates a language model output (streaming).
|
|
7874
|
+
|
|
7875
|
+
Naming: "do" prefix to prevent accidental direct usage of the method
|
|
7876
|
+
by the user.
|
|
7877
|
+
*
|
|
7878
|
+
@return A stream of higher-level language model output parts.
|
|
7879
|
+
*/
|
|
7880
|
+
doStream(options: LanguageModelV2CallOptions): PromiseLike<{
|
|
7881
|
+
stream: ReadableStream<LanguageModelV2StreamPart>;
|
|
7882
|
+
/**
|
|
7883
|
+
Optional request information for telemetry and debugging purposes.
|
|
7884
|
+
*/
|
|
7885
|
+
request?: {
|
|
7886
|
+
/**
|
|
7887
|
+
Request HTTP body that was sent to the provider API.
|
|
7888
|
+
*/
|
|
7889
|
+
body?: unknown;
|
|
7890
|
+
};
|
|
7891
|
+
/**
|
|
7892
|
+
Optional response data.
|
|
7893
|
+
*/
|
|
7894
|
+
response?: {
|
|
7895
|
+
/**
|
|
7896
|
+
Response headers.
|
|
7897
|
+
*/
|
|
7898
|
+
headers?: SharedV2Headers;
|
|
7899
|
+
};
|
|
7900
|
+
}>;
|
|
7901
|
+
};
|
|
7902
|
+
|
|
7903
|
+
type SpeechModelV2ProviderOptions = Record<string, Record<string, JSONValue>>;
|
|
7904
|
+
type SpeechModelV2CallOptions = {
|
|
7905
|
+
/**
|
|
7906
|
+
* Text to convert to speech.
|
|
7907
|
+
*/
|
|
7908
|
+
text: string;
|
|
7909
|
+
/**
|
|
7910
|
+
* The voice to use for speech synthesis.
|
|
7911
|
+
* This is provider-specific and may be a voice ID, name, or other identifier.
|
|
7912
|
+
*/
|
|
7913
|
+
voice?: string;
|
|
7914
|
+
/**
|
|
7915
|
+
* The desired output format for the audio e.g. "mp3", "wav", etc.
|
|
7916
|
+
*/
|
|
7917
|
+
outputFormat?: string;
|
|
7918
|
+
/**
|
|
7919
|
+
* Instructions for the speech generation e.g. "Speak in a slow and steady tone".
|
|
7920
|
+
*/
|
|
7921
|
+
instructions?: string;
|
|
7922
|
+
/**
|
|
7923
|
+
* The speed of the speech generation.
|
|
7924
|
+
*/
|
|
7925
|
+
speed?: number;
|
|
7926
|
+
/**
|
|
7927
|
+
* The language for speech generation. This should be an ISO 639-1 language code (e.g. "en", "es", "fr")
|
|
7928
|
+
* or "auto" for automatic language detection. Provider support varies.
|
|
7929
|
+
*/
|
|
7930
|
+
language?: string;
|
|
7931
|
+
/**
|
|
7932
|
+
* Additional provider-specific options that are passed through to the provider
|
|
7933
|
+
* as body parameters.
|
|
7934
|
+
*
|
|
7935
|
+
* The outer record is keyed by the provider name, and the inner
|
|
7936
|
+
* record is keyed by the provider-specific metadata key.
|
|
7937
|
+
* ```ts
|
|
7938
|
+
* {
|
|
7939
|
+
* "openai": {}
|
|
7940
|
+
* }
|
|
7941
|
+
* ```
|
|
7942
|
+
*/
|
|
7943
|
+
providerOptions?: SpeechModelV2ProviderOptions;
|
|
7944
|
+
/**
|
|
7945
|
+
* Abort signal for cancelling the operation.
|
|
7946
|
+
*/
|
|
7947
|
+
abortSignal?: AbortSignal;
|
|
7948
|
+
/**
|
|
7949
|
+
* Additional HTTP headers to be sent with the request.
|
|
7950
|
+
* Only applicable for HTTP-based providers.
|
|
7951
|
+
*/
|
|
7952
|
+
headers?: Record<string, string | undefined>;
|
|
7953
|
+
};
|
|
7954
|
+
|
|
7955
|
+
/**
|
|
7956
|
+
* Warning from the model provider for this call. The call will proceed, but e.g.
|
|
7957
|
+
* some settings might not be supported, which can lead to suboptimal results.
|
|
7958
|
+
*/
|
|
7959
|
+
type SpeechModelV2CallWarning = {
|
|
7960
|
+
type: 'unsupported-setting';
|
|
7961
|
+
setting: keyof SpeechModelV2CallOptions;
|
|
7962
|
+
details?: string;
|
|
7963
|
+
} | {
|
|
7964
|
+
type: 'other';
|
|
7965
|
+
message: string;
|
|
7966
|
+
};
|
|
7967
|
+
|
|
7968
|
+
/**
|
|
7969
|
+
* Speech model specification version 2.
|
|
7970
|
+
*/
|
|
7971
|
+
type SpeechModelV2 = {
|
|
7972
|
+
/**
|
|
7973
|
+
* The speech model must specify which speech model interface
|
|
7974
|
+
* version it implements. This will allow us to evolve the speech
|
|
7975
|
+
* model interface and retain backwards compatibility. The different
|
|
7976
|
+
* implementation versions can be handled as a discriminated union
|
|
7977
|
+
* on our side.
|
|
7978
|
+
*/
|
|
7979
|
+
readonly specificationVersion: 'v2';
|
|
7980
|
+
/**
|
|
7981
|
+
* Name of the provider for logging purposes.
|
|
7982
|
+
*/
|
|
7983
|
+
readonly provider: string;
|
|
7984
|
+
/**
|
|
7985
|
+
* Provider-specific model ID for logging purposes.
|
|
7986
|
+
*/
|
|
7987
|
+
readonly modelId: string;
|
|
7988
|
+
/**
|
|
7989
|
+
* Generates speech audio from text.
|
|
7990
|
+
*/
|
|
7991
|
+
doGenerate(options: SpeechModelV2CallOptions): PromiseLike<{
|
|
7992
|
+
/**
|
|
7993
|
+
* Generated audio as an ArrayBuffer.
|
|
7994
|
+
* The audio should be returned without any unnecessary conversion.
|
|
7995
|
+
* If the API returns base64 encoded strings, the audio should be returned
|
|
7996
|
+
* as base64 encoded strings. If the API returns binary data, the audio
|
|
7997
|
+
* should be returned as binary data.
|
|
7998
|
+
*/
|
|
7999
|
+
audio: string | Uint8Array;
|
|
8000
|
+
/**
|
|
8001
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
8002
|
+
*/
|
|
8003
|
+
warnings: Array<SpeechModelV2CallWarning>;
|
|
8004
|
+
/**
|
|
8005
|
+
* Optional request information for telemetry and debugging purposes.
|
|
8006
|
+
*/
|
|
8007
|
+
request?: {
|
|
8008
|
+
/**
|
|
8009
|
+
* Response body (available only for providers that use HTTP requests).
|
|
8010
|
+
*/
|
|
8011
|
+
body?: unknown;
|
|
8012
|
+
};
|
|
8013
|
+
/**
|
|
8014
|
+
* Response information for telemetry and debugging purposes.
|
|
8015
|
+
*/
|
|
8016
|
+
response: {
|
|
8017
|
+
/**
|
|
8018
|
+
* Timestamp for the start of the generated response.
|
|
8019
|
+
*/
|
|
8020
|
+
timestamp: Date;
|
|
8021
|
+
/**
|
|
8022
|
+
* The ID of the response model that was used to generate the response.
|
|
8023
|
+
*/
|
|
8024
|
+
modelId: string;
|
|
8025
|
+
/**
|
|
8026
|
+
* Response headers.
|
|
8027
|
+
*/
|
|
8028
|
+
headers?: SharedV2Headers;
|
|
8029
|
+
/**
|
|
8030
|
+
* Response body.
|
|
8031
|
+
*/
|
|
8032
|
+
body?: unknown;
|
|
8033
|
+
};
|
|
8034
|
+
/**
|
|
8035
|
+
* Additional provider-specific metadata. They are passed through
|
|
8036
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
8037
|
+
* results that can be fully encapsulated in the provider.
|
|
8038
|
+
*/
|
|
8039
|
+
providerMetadata?: Record<string, Record<string, JSONValue>>;
|
|
8040
|
+
}>;
|
|
8041
|
+
};
|
|
8042
|
+
|
|
8043
|
+
type TranscriptionModelV2ProviderOptions = Record<string, Record<string, JSONValue>>;
|
|
8044
|
+
type TranscriptionModelV2CallOptions = {
|
|
8045
|
+
/**
|
|
8046
|
+
Audio data to transcribe.
|
|
8047
|
+
Accepts a `Uint8Array` or `string`, where `string` is a base64 encoded audio file.
|
|
8048
|
+
*/
|
|
8049
|
+
audio: Uint8Array | string;
|
|
8050
|
+
/**
|
|
8051
|
+
The IANA media type of the audio data.
|
|
8052
|
+
|
|
8053
|
+
@see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
8054
|
+
*/
|
|
8055
|
+
mediaType: string;
|
|
8056
|
+
/**
|
|
8057
|
+
Additional provider-specific options that are passed through to the provider
|
|
8058
|
+
as body parameters.
|
|
8059
|
+
|
|
8060
|
+
The outer record is keyed by the provider name, and the inner
|
|
8061
|
+
record is keyed by the provider-specific metadata key.
|
|
8062
|
+
```ts
|
|
8063
|
+
{
|
|
8064
|
+
"openai": {
|
|
8065
|
+
"timestampGranularities": ["word"]
|
|
8066
|
+
}
|
|
8067
|
+
}
|
|
8068
|
+
```
|
|
8069
|
+
*/
|
|
8070
|
+
providerOptions?: TranscriptionModelV2ProviderOptions;
|
|
8071
|
+
/**
|
|
8072
|
+
Abort signal for cancelling the operation.
|
|
8073
|
+
*/
|
|
8074
|
+
abortSignal?: AbortSignal;
|
|
8075
|
+
/**
|
|
8076
|
+
Additional HTTP headers to be sent with the request.
|
|
8077
|
+
Only applicable for HTTP-based providers.
|
|
8078
|
+
*/
|
|
8079
|
+
headers?: Record<string, string | undefined>;
|
|
8080
|
+
};
|
|
8081
|
+
|
|
8082
|
+
/**
|
|
8083
|
+
Warning from the model provider for this call. The call will proceed, but e.g.
|
|
8084
|
+
some settings might not be supported, which can lead to suboptimal results.
|
|
8085
|
+
*/
|
|
8086
|
+
type TranscriptionModelV2CallWarning = {
|
|
8087
|
+
type: 'unsupported-setting';
|
|
8088
|
+
setting: keyof TranscriptionModelV2CallOptions;
|
|
8089
|
+
details?: string;
|
|
8090
|
+
} | {
|
|
8091
|
+
type: 'other';
|
|
8092
|
+
message: string;
|
|
8093
|
+
};
|
|
8094
|
+
|
|
8095
|
+
/**
|
|
8096
|
+
Transcription model specification version 2.
|
|
8097
|
+
*/
|
|
8098
|
+
type TranscriptionModelV2 = {
|
|
8099
|
+
/**
|
|
8100
|
+
The transcription model must specify which transcription model interface
|
|
8101
|
+
version it implements. This will allow us to evolve the transcription
|
|
8102
|
+
model interface and retain backwards compatibility. The different
|
|
8103
|
+
implementation versions can be handled as a discriminated union
|
|
8104
|
+
on our side.
|
|
8105
|
+
*/
|
|
8106
|
+
readonly specificationVersion: 'v2';
|
|
8107
|
+
/**
|
|
8108
|
+
Name of the provider for logging purposes.
|
|
8109
|
+
*/
|
|
8110
|
+
readonly provider: string;
|
|
8111
|
+
/**
|
|
8112
|
+
Provider-specific model ID for logging purposes.
|
|
8113
|
+
*/
|
|
8114
|
+
readonly modelId: string;
|
|
8115
|
+
/**
|
|
8116
|
+
Generates a transcript.
|
|
8117
|
+
*/
|
|
8118
|
+
doGenerate(options: TranscriptionModelV2CallOptions): PromiseLike<{
|
|
8119
|
+
/**
|
|
8120
|
+
* The complete transcribed text from the audio.
|
|
8121
|
+
*/
|
|
8122
|
+
text: string;
|
|
8123
|
+
/**
|
|
8124
|
+
* Array of transcript segments with timing information.
|
|
8125
|
+
* Each segment represents a portion of the transcribed text with start and end times.
|
|
8126
|
+
*/
|
|
8127
|
+
segments: Array<{
|
|
8128
|
+
/**
|
|
8129
|
+
* The text content of this segment.
|
|
8130
|
+
*/
|
|
8131
|
+
text: string;
|
|
8132
|
+
/**
|
|
8133
|
+
* The start time of this segment in seconds.
|
|
8134
|
+
*/
|
|
8135
|
+
startSecond: number;
|
|
8136
|
+
/**
|
|
8137
|
+
* The end time of this segment in seconds.
|
|
8138
|
+
*/
|
|
8139
|
+
endSecond: number;
|
|
8140
|
+
}>;
|
|
8141
|
+
/**
|
|
8142
|
+
* The detected language of the audio content, as an ISO-639-1 code (e.g., 'en' for English).
|
|
8143
|
+
* May be undefined if the language couldn't be detected.
|
|
8144
|
+
*/
|
|
8145
|
+
language: string | undefined;
|
|
8146
|
+
/**
|
|
8147
|
+
* The total duration of the audio file in seconds.
|
|
8148
|
+
* May be undefined if the duration couldn't be determined.
|
|
8149
|
+
*/
|
|
8150
|
+
durationInSeconds: number | undefined;
|
|
8151
|
+
/**
|
|
8152
|
+
Warnings for the call, e.g. unsupported settings.
|
|
8153
|
+
*/
|
|
8154
|
+
warnings: Array<TranscriptionModelV2CallWarning>;
|
|
8155
|
+
/**
|
|
8156
|
+
Optional request information for telemetry and debugging purposes.
|
|
8157
|
+
*/
|
|
8158
|
+
request?: {
|
|
8159
|
+
/**
|
|
8160
|
+
Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
|
|
8161
|
+
Non-HTTP(s) providers should not set this.
|
|
8162
|
+
*/
|
|
8163
|
+
body?: string;
|
|
8164
|
+
};
|
|
8165
|
+
/**
|
|
8166
|
+
Response information for telemetry and debugging purposes.
|
|
8167
|
+
*/
|
|
8168
|
+
response: {
|
|
8169
|
+
/**
|
|
8170
|
+
Timestamp for the start of the generated response.
|
|
8171
|
+
*/
|
|
8172
|
+
timestamp: Date;
|
|
8173
|
+
/**
|
|
8174
|
+
The ID of the response model that was used to generate the response.
|
|
8175
|
+
*/
|
|
8176
|
+
modelId: string;
|
|
8177
|
+
/**
|
|
8178
|
+
Response headers.
|
|
8179
|
+
*/
|
|
8180
|
+
headers?: SharedV2Headers;
|
|
8181
|
+
/**
|
|
8182
|
+
Response body.
|
|
8183
|
+
*/
|
|
8184
|
+
body?: unknown;
|
|
8185
|
+
};
|
|
8186
|
+
/**
|
|
8187
|
+
Additional provider-specific metadata. They are passed through
|
|
8188
|
+
from the provider to the AI SDK and enable provider-specific
|
|
8189
|
+
results that can be fully encapsulated in the provider.
|
|
8190
|
+
*/
|
|
8191
|
+
providerMetadata?: Record<string, Record<string, JSONValue>>;
|
|
8192
|
+
}>;
|
|
8193
|
+
};
|
|
8194
|
+
|
|
8195
|
+
/**
|
|
8196
|
+
* Provider for language, text embedding, and image generation models.
|
|
8197
|
+
*/
|
|
8198
|
+
interface ProviderV2 {
|
|
8199
|
+
/**
|
|
8200
|
+
Returns the language model with the given id.
|
|
8201
|
+
The model id is then passed to the provider function to get the model.
|
|
8202
|
+
|
|
8203
|
+
@param {string} modelId - The id of the model to return.
|
|
8204
|
+
|
|
8205
|
+
@returns {LanguageModel} The language model associated with the id
|
|
8206
|
+
|
|
8207
|
+
@throws {NoSuchModelError} If no such model exists.
|
|
8208
|
+
*/
|
|
8209
|
+
languageModel(modelId: string): LanguageModelV2;
|
|
8210
|
+
/**
|
|
8211
|
+
Returns the text embedding model with the given id.
|
|
8212
|
+
The model id is then passed to the provider function to get the model.
|
|
8213
|
+
|
|
8214
|
+
@param {string} modelId - The id of the model to return.
|
|
8215
|
+
|
|
8216
|
+
@returns {LanguageModel} The language model associated with the id
|
|
8217
|
+
|
|
8218
|
+
@throws {NoSuchModelError} If no such model exists.
|
|
8219
|
+
*/
|
|
8220
|
+
textEmbeddingModel(modelId: string): EmbeddingModelV2<string>;
|
|
8221
|
+
/**
|
|
8222
|
+
Returns the image model with the given id.
|
|
8223
|
+
The model id is then passed to the provider function to get the model.
|
|
8224
|
+
|
|
8225
|
+
@param {string} modelId - The id of the model to return.
|
|
8226
|
+
|
|
8227
|
+
@returns {ImageModel} The image model associated with the id
|
|
8228
|
+
*/
|
|
8229
|
+
imageModel(modelId: string): ImageModelV2;
|
|
8230
|
+
/**
|
|
8231
|
+
Returns the transcription model with the given id.
|
|
8232
|
+
The model id is then passed to the provider function to get the model.
|
|
8233
|
+
|
|
8234
|
+
@param {string} modelId - The id of the model to return.
|
|
8235
|
+
|
|
8236
|
+
@returns {TranscriptionModel} The transcription model associated with the id
|
|
8237
|
+
*/
|
|
8238
|
+
transcriptionModel?(modelId: string): TranscriptionModelV2;
|
|
8239
|
+
/**
|
|
8240
|
+
Returns the speech model with the given id.
|
|
8241
|
+
The model id is then passed to the provider function to get the model.
|
|
8242
|
+
|
|
8243
|
+
@param {string} modelId - The id of the model to return.
|
|
8244
|
+
|
|
8245
|
+
@returns {SpeechModel} The speech model associated with the id
|
|
8246
|
+
*/
|
|
8247
|
+
speechModel?(modelId: string): SpeechModelV2;
|
|
8248
|
+
}
|
|
8249
|
+
|
|
8250
|
+
declare global {
|
|
8251
|
+
interface File {
|
|
8252
|
+
}
|
|
8253
|
+
}
|
|
8254
|
+
|
|
8255
|
+
type Warning = LanguageModelV2CallWarning | ImageModelV2CallWarning | SpeechModelV2CallWarning | TranscriptionModelV2CallWarning;
|
|
8256
|
+
type LogWarningsFunction = (warnings: Warning[]) => void;
|
|
8257
|
+
|
|
8258
|
+
declare global {
|
|
8259
|
+
/**
|
|
8260
|
+
* The default provider to use for the AI SDK.
|
|
8261
|
+
* String model ids are resolved to the default provider and model id.
|
|
8262
|
+
*
|
|
8263
|
+
* If not set, the default provider is the Vercel AI gateway provider.
|
|
8264
|
+
*
|
|
8265
|
+
* @see https://ai-sdk.dev/docs/ai-sdk-core/provider-management#global-provider-configuration
|
|
8266
|
+
*/
|
|
8267
|
+
var AI_SDK_DEFAULT_PROVIDER: ProviderV2 | undefined;
|
|
8268
|
+
/**
|
|
8269
|
+
* The warning logger to use for the AI SDK.
|
|
8270
|
+
*
|
|
8271
|
+
* If not set, the default logger is the console.warn function.
|
|
8272
|
+
*
|
|
8273
|
+
* If set to false, no warnings are logged.
|
|
8274
|
+
*/
|
|
8275
|
+
var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
|
|
8276
|
+
}
|
|
8277
|
+
|
|
6672
8278
|
type ContentType = 'askAI' | 'content' | 'lvl0' | 'lvl1' | 'lvl2' | 'lvl3' | 'lvl4' | 'lvl5' | 'lvl6';
|
|
6673
8279
|
interface DocSearchHitAttributeHighlightResult {
|
|
6674
8280
|
value: string;
|
|
@@ -6751,6 +8357,21 @@ type InternalDocSearchHit = DocSearchHit & {
|
|
|
6751
8357
|
__docsearch_parent: InternalDocSearchHit | null;
|
|
6752
8358
|
};
|
|
6753
8359
|
|
|
8360
|
+
interface KeyboardShortcuts {
|
|
8361
|
+
/**
|
|
8362
|
+
* Enable/disable the Ctrl/Cmd+K shortcut to toggle the search modal.
|
|
8363
|
+
*
|
|
8364
|
+
* @default true
|
|
8365
|
+
*/
|
|
8366
|
+
'Ctrl/Cmd+K'?: boolean;
|
|
8367
|
+
/**
|
|
8368
|
+
* Enable/disable the / shortcut to open the search modal.
|
|
8369
|
+
*
|
|
8370
|
+
* @default true
|
|
8371
|
+
*/
|
|
8372
|
+
'/'?: boolean;
|
|
8373
|
+
}
|
|
8374
|
+
|
|
6754
8375
|
type StoredDocSearchHit = Omit<DocSearchHit, '_highlightResult' | '_snippetResult'>;
|
|
6755
8376
|
|
|
6756
8377
|
type DocSearchTranslations = Partial<{
|
|
@@ -6789,6 +8410,10 @@ type DocSearchAskAi = {
|
|
|
6789
8410
|
facetFilters?: SearchParamsObject['facetFilters'];
|
|
6790
8411
|
};
|
|
6791
8412
|
};
|
|
8413
|
+
interface DocSearchIndex {
|
|
8414
|
+
name: string;
|
|
8415
|
+
searchParameters?: SearchParamsObject;
|
|
8416
|
+
}
|
|
6792
8417
|
interface DocSearchProps$1 {
|
|
6793
8418
|
/**
|
|
6794
8419
|
* Algolia application id used by the search client.
|
|
@@ -6800,8 +8425,16 @@ interface DocSearchProps$1 {
|
|
|
6800
8425
|
apiKey: string;
|
|
6801
8426
|
/**
|
|
6802
8427
|
* Name of the algolia index to query.
|
|
8428
|
+
*
|
|
8429
|
+
* @deprecated `indexName` will be removed in a future version. Please use `indices` property going forward.
|
|
6803
8430
|
*/
|
|
6804
|
-
indexName
|
|
8431
|
+
indexName?: string;
|
|
8432
|
+
/**
|
|
8433
|
+
* List of indices and _optional_ searchParameters to be used for search.
|
|
8434
|
+
*
|
|
8435
|
+
* @see {@link https://docsearch.algolia.com/docs/api#indices}
|
|
8436
|
+
*/
|
|
8437
|
+
indices?: Array<DocSearchIndex | string>;
|
|
6805
8438
|
/**
|
|
6806
8439
|
* Configuration or assistant id to enable ask ai mode. Pass a string assistant id or a full config object.
|
|
6807
8440
|
*/
|
|
@@ -6816,6 +8449,8 @@ interface DocSearchProps$1 {
|
|
|
6816
8449
|
placeholder?: string;
|
|
6817
8450
|
/**
|
|
6818
8451
|
* Additional algolia search parameters to merge into each query.
|
|
8452
|
+
*
|
|
8453
|
+
* @deprecated `searchParameters` will be removed in a future version. Please use `indices` property going forward.
|
|
6819
8454
|
*/
|
|
6820
8455
|
searchParameters?: SearchParamsObject;
|
|
6821
8456
|
/**
|
|
@@ -6885,6 +8520,10 @@ interface DocSearchProps$1 {
|
|
|
6885
8520
|
* @default 4
|
|
6886
8521
|
*/
|
|
6887
8522
|
recentSearchesWithFavoritesLimit?: number;
|
|
8523
|
+
/**
|
|
8524
|
+
* Configuration for keyboard shortcuts. Allows enabling/disabling specific shortcuts.
|
|
8525
|
+
*/
|
|
8526
|
+
keyboardShortcuts?: KeyboardShortcuts;
|
|
6888
8527
|
}
|
|
6889
8528
|
|
|
6890
8529
|
type ButtonTranslations = Partial<{
|