pi-meta-oauth 0.2.3 → 0.3.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/extensions/media.ts +1446 -0
- package/extensions/meta.ts +43 -8
- package/package.json +2 -1
package/extensions/meta.ts
CHANGED
|
@@ -13,6 +13,7 @@ export const META_API_BASE_URL = "https://api.meta.ai/v1";
|
|
|
13
13
|
export const META_MODEL_CATALOG_URL = "https://api.meta.ai/v1/models";
|
|
14
14
|
export const META_AUTH_BASE_URL = "https://auth.meta.com";
|
|
15
15
|
export const META_CLIENT_ID = "1031625952748946";
|
|
16
|
+
export const META_FILES_URL = `${META_API_BASE_URL}/files`;
|
|
16
17
|
|
|
17
18
|
const DEVICE_AUTHORIZATION_URL = `${META_AUTH_BASE_URL}/oidc/device/authorization/`;
|
|
18
19
|
const DEVICE_TOKEN_URL = `${META_AUTH_BASE_URL}/oidc/device/token/`;
|
|
@@ -72,6 +73,10 @@ interface MetaCatalogModel {
|
|
|
72
73
|
};
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
// Media capabilities kept as "text"+"image" for pi-ai type compat (pi-ai 0.83/0.84 only allows those),
|
|
77
|
+
// with "video"/"audio" advertised via cast so future pi-ai that expands the union picks them up.
|
|
78
|
+
// See media.ts for the before_provider_request rewrite that makes @video/@audio work today
|
|
79
|
+
// despite UserMessage.content being string | (TextContent | ImageContent)[] .
|
|
75
80
|
const FALLBACK_MODELS: MetaProviderModel[] = [
|
|
76
81
|
{
|
|
77
82
|
id: "muse-spark-1.2",
|
|
@@ -86,7 +91,12 @@ const FALLBACK_MODELS: MetaProviderModel[] = [
|
|
|
86
91
|
xhigh: "xhigh",
|
|
87
92
|
max: null,
|
|
88
93
|
},
|
|
89
|
-
input: [
|
|
94
|
+
input: [
|
|
95
|
+
"text",
|
|
96
|
+
"image",
|
|
97
|
+
"video",
|
|
98
|
+
"audio",
|
|
99
|
+
] as unknown as MetaProviderModel["input"],
|
|
90
100
|
cost: { input: 1.25, output: 4.25, cacheRead: 0.15, cacheWrite: 0 },
|
|
91
101
|
contextWindow: 1_048_576,
|
|
92
102
|
maxTokens: 256_000,
|
|
@@ -105,7 +115,12 @@ const FALLBACK_MODELS: MetaProviderModel[] = [
|
|
|
105
115
|
xhigh: "xhigh",
|
|
106
116
|
max: null,
|
|
107
117
|
},
|
|
108
|
-
input: [
|
|
118
|
+
input: [
|
|
119
|
+
"text",
|
|
120
|
+
"image",
|
|
121
|
+
"video",
|
|
122
|
+
"audio",
|
|
123
|
+
] as unknown as MetaProviderModel["input"],
|
|
109
124
|
cost: { input: 0.1, output: 0.2, cacheRead: 0.002, cacheWrite: 0 },
|
|
110
125
|
contextWindow: 1_048_576,
|
|
111
126
|
maxTokens: 256_000,
|
|
@@ -124,7 +139,12 @@ const FALLBACK_MODELS: MetaProviderModel[] = [
|
|
|
124
139
|
xhigh: "xhigh",
|
|
125
140
|
max: null,
|
|
126
141
|
},
|
|
127
|
-
input: [
|
|
142
|
+
input: [
|
|
143
|
+
"text",
|
|
144
|
+
"image",
|
|
145
|
+
"video",
|
|
146
|
+
"audio",
|
|
147
|
+
] as unknown as MetaProviderModel["input"],
|
|
128
148
|
cost: { input: 1.25, output: 4.25, cacheRead: 0.15, cacheWrite: 0 },
|
|
129
149
|
contextWindow: 1_048_576,
|
|
130
150
|
maxTokens: 256_000,
|
|
@@ -332,6 +352,25 @@ function displayName(id: string): string {
|
|
|
332
352
|
.join(" ");
|
|
333
353
|
}
|
|
334
354
|
|
|
355
|
+
function modalitiesToInput(
|
|
356
|
+
modalities: string[] | undefined,
|
|
357
|
+
fallback: MetaProviderModel["input"] | undefined,
|
|
358
|
+
): MetaProviderModel["input"] {
|
|
359
|
+
if (!modalities)
|
|
360
|
+
return fallback ?? (["text"] as unknown as MetaProviderModel["input"]);
|
|
361
|
+
const input: string[] = ["text"];
|
|
362
|
+
if (modalities.includes("image")) input.push("image");
|
|
363
|
+
// Advertised via cast until pi-ai expands Model.input union beyond text|image.
|
|
364
|
+
// The before_provider_request hook in media.ts rewrites these to input_video/input_audio at request time.
|
|
365
|
+
if (modalities.includes("video")) input.push("video");
|
|
366
|
+
if (modalities.includes("audio")) input.push("audio");
|
|
367
|
+
// Some catalogs expose "document"/"pdf" as a modality for PDF handling.
|
|
368
|
+
if (modalities.includes("document") || modalities.includes("pdf")) {
|
|
369
|
+
if (!input.includes("image")) input.push("image"); // PDFs count toward image budget
|
|
370
|
+
}
|
|
371
|
+
return input as unknown as MetaProviderModel["input"];
|
|
372
|
+
}
|
|
373
|
+
|
|
335
374
|
export function toProviderModels(
|
|
336
375
|
catalog: CatalogResponse,
|
|
337
376
|
): MetaProviderModel[] {
|
|
@@ -359,11 +398,7 @@ export function toProviderModels(
|
|
|
359
398
|
name: catalogName || fallback?.name || displayName(entry.id),
|
|
360
399
|
reasoning: metadata?.reasoning ?? fallback?.reasoning ?? true,
|
|
361
400
|
thinkingLevelMap,
|
|
362
|
-
input: metadata
|
|
363
|
-
? metadata.modalities?.input?.includes("image")
|
|
364
|
-
? ["text", "image"]
|
|
365
|
-
: ["text"]
|
|
366
|
-
: (fallback?.input ?? ["text"]),
|
|
401
|
+
input: modalitiesToInput(metadata?.modalities?.input, fallback?.input),
|
|
367
402
|
cost: {
|
|
368
403
|
input: numericCost(metadata?.cost?.input, fallback?.cost.input ?? 0),
|
|
369
404
|
output: numericCost(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-meta-oauth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Meta Model API OAuth provider and Muse-style voice dictation for pi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"pi": {
|
|
30
30
|
"extensions": [
|
|
31
31
|
"./extensions/meta.ts",
|
|
32
|
+
"./extensions/media.ts",
|
|
32
33
|
"./extensions/voice.ts"
|
|
33
34
|
],
|
|
34
35
|
"image": "https://raw.githubusercontent.com/BlockedPath/pi-meta-oauth/main/preview.png"
|