feat(core): add embedded v2 session runtime and tool foundation (#30632)
This commit is contained in:
parent
c35267776a
commit
76ee87ead8
215 changed files with 31398 additions and 3332 deletions
|
|
@ -52,6 +52,18 @@ export const Api = Schema.Union([
|
|||
]).pipe(Schema.toTaggedUnion("type"))
|
||||
export type Api = typeof Api.Type
|
||||
|
||||
export const PublicApi = Schema.Union([
|
||||
Schema.Struct({
|
||||
id: ID,
|
||||
...ProviderV2.PublicAISDK.fields,
|
||||
}),
|
||||
Schema.Struct({
|
||||
id: ID,
|
||||
...ProviderV2.PublicNative.fields,
|
||||
}),
|
||||
]).pipe(Schema.toTaggedUnion("type"))
|
||||
export type PublicApi = typeof PublicApi.Type
|
||||
|
||||
export class Info extends Schema.Class<Info>("ModelV2.Info")({
|
||||
id: ID,
|
||||
providerID: ProviderV2.ID,
|
||||
|
|
@ -113,6 +125,64 @@ export class Info extends Schema.Class<Info>("ModelV2.Info")({
|
|||
}
|
||||
}
|
||||
|
||||
export class PublicInfo extends Schema.Class<PublicInfo>("ModelV2.PublicInfo")({
|
||||
id: ID,
|
||||
providerID: ProviderV2.ID,
|
||||
family: Family.pipe(Schema.optional),
|
||||
name: Schema.String,
|
||||
api: PublicApi,
|
||||
capabilities: Capabilities,
|
||||
variants: Schema.Struct({
|
||||
id: VariantID,
|
||||
}).pipe(Schema.Array),
|
||||
time: Schema.Struct({
|
||||
released: DateTimeUtcFromMillis,
|
||||
}),
|
||||
cost: Cost.pipe(Schema.Array),
|
||||
status: Schema.Literals(["alpha", "beta", "deprecated", "active"]),
|
||||
enabled: Schema.Boolean,
|
||||
limit: Schema.Struct({
|
||||
context: Schema.Int,
|
||||
input: Schema.Int.pipe(Schema.optional),
|
||||
output: Schema.Int,
|
||||
}),
|
||||
}) {}
|
||||
|
||||
export function toPublic(info: Info): PublicInfo {
|
||||
const api =
|
||||
info.api.type === "aisdk"
|
||||
? {
|
||||
id: info.api.id,
|
||||
type: info.api.type,
|
||||
package: info.api.package,
|
||||
url: ProviderV2.sanitizePublicUrl(info.api.url),
|
||||
}
|
||||
: { id: info.api.id, type: info.api.type, url: ProviderV2.sanitizePublicUrl(info.api.url) }
|
||||
return new PublicInfo({
|
||||
id: info.id,
|
||||
providerID: info.providerID,
|
||||
family: info.family,
|
||||
name: info.name,
|
||||
api,
|
||||
capabilities: {
|
||||
tools: info.capabilities.tools,
|
||||
input: [...info.capabilities.input],
|
||||
output: [...info.capabilities.output],
|
||||
},
|
||||
variants: info.variants.map((variant) => ({ id: variant.id })),
|
||||
time: { released: info.time.released },
|
||||
cost: info.cost.map((cost) => ({
|
||||
tier: cost.tier && { ...cost.tier },
|
||||
input: cost.input,
|
||||
output: cost.output,
|
||||
cache: { ...cost.cache },
|
||||
})),
|
||||
status: info.status,
|
||||
enabled: info.enabled,
|
||||
limit: { ...info.limit },
|
||||
})
|
||||
}
|
||||
|
||||
export function parse(input: string): { providerID: ProviderV2.ID; modelID: ID } {
|
||||
const [providerID, ...modelID] = input.split("/")
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue