pi-media-models 0.1.7 → 0.1.8
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 +1 -1
- package/package.json +1 -1
- package/src/adapters/google.ts +6 -2
package/README.md
CHANGED
|
@@ -101,7 +101,7 @@ Create or edit `~/.pi/agent/media-models.json`:
|
|
|
101
101
|
}
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
> **Note**: You only need to fill in the providers you plan to use. Unused providers can simply be omitted. Vertex reads `project_id` from the service-account JSON when `project` is omitted or still set to a placeholder such as `my-gcp-project`; an explicit real project ID remains supported.
|
|
104
|
+
> **Note**: You only need to fill in the providers you plan to use. Unused providers can simply be omitted. Vertex reads `project_id` from the service-account JSON when `project` is omitted or still set to a placeholder such as `my-gcp-project`; an explicit real project ID remains supported. Set `location` to `global` to use Vertex's global endpoint for models that support it.
|
|
105
105
|
|
|
106
106
|
### Custom OpenAI-Compatible Providers
|
|
107
107
|
|
package/package.json
CHANGED
package/src/adapters/google.ts
CHANGED
|
@@ -212,7 +212,7 @@ export class GoogleMediaAdapter extends BaseAdapter {
|
|
|
212
212
|
const models: ModelDescriptor[] = []
|
|
213
213
|
let pageToken: string | undefined
|
|
214
214
|
do {
|
|
215
|
-
const url = new URL(
|
|
215
|
+
const url = new URL(`${vertexApiOrigin(location)}/v1beta1/publishers/google/models`)
|
|
216
216
|
url.searchParams.set('pageSize', '100')
|
|
217
217
|
url.searchParams.set('listAllVersions', 'true')
|
|
218
218
|
if (pageToken) url.searchParams.set('pageToken', pageToken)
|
|
@@ -247,7 +247,7 @@ export class GoogleMediaAdapter extends BaseAdapter {
|
|
|
247
247
|
return { url: `${base}/models/${encodeURIComponent(model)}:${method}`, headers: { 'x-goog-api-key': key }, operationsBase: base }
|
|
248
248
|
}
|
|
249
249
|
const { auth, project, location } = await this.vertexSettings(options)
|
|
250
|
-
const base =
|
|
250
|
+
const base = `${vertexApiOrigin(location)}/v1`
|
|
251
251
|
const resource = `projects/${encodeURIComponent(project)}/locations/${encodeURIComponent(location)}/publishers/google/models/${encodeURIComponent(model)}`
|
|
252
252
|
const url = `${base}/${resource}:${method}`
|
|
253
253
|
const authHeaders = await auth.getRequestHeaders(url)
|
|
@@ -286,6 +286,10 @@ export class GoogleMediaAdapter extends BaseAdapter {
|
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
+
export function vertexApiOrigin(location: string): string {
|
|
290
|
+
return location === 'global' ? 'https://aiplatform.googleapis.com' : `https://${location}-aiplatform.googleapis.com`
|
|
291
|
+
}
|
|
292
|
+
|
|
289
293
|
function googleCapabilities(id: string, declared: ModelDescriptor[]): Capability[] {
|
|
290
294
|
const known = declared.find(model => model.id === id)
|
|
291
295
|
if (known) return known.capabilities
|