5.0
关注
AI SCORE
工具产品2025-05-04 06:29
Google Gemini API 设计缺陷分析
Hacker News · venki.dev#Google#API设计
Editor brief · 编辑速览
批评 Gemini API 的易用性和设计问题。对选型 API 有参考价值,但主要是吐槽评论。
批评 Gemini API 的易用性和设计问题。对选型 API 有参考价值,但主要是吐槽评论。
你必须手动部署 endpoint,而不能只训练模型然后直接使用。
如果给部署的 endpoint 设置默认名称以外的任何名称,似乎都会抛出错误:“Internal error occurred. Contact Vertex AI”。
调用时只能使用可读性较差的 18 位 endpoint ID,而不是带有可配置后缀、易于辨识的模型名称。
Provider 会自动缓存 LLM completion 请求中发现的前缀,并重复使用。
Developer 在 LLM completion 请求中标记应当缓存的部分,Provider 随后会缓存这些部分,并在之后的请求中重复使用。
Developer 将需要缓存的前缀发送到一个单独的 API endpoint,并获得 cache ID。之后,如果某个请求应该使用该缓存条目,Developer 就在请求中附带 cache ID,Provider 则使用对应的缓存前缀。
// Patch Vercel AI SDK
function patchedFetchForFinetune(
requestInfo: RequestInfo | URL,
requestInit?: RequestInit
): Promise<Response> {
function patchString(str: string) {
return str.replace(`/publishers/google/models`, `/endpoints`)
}
if (requestInfo instanceof URL) {
let patchedUrl = new URL(requestInfo)
patchedUrl.pathname = patchString(patchedUrl.pathname)
return fetch(patchedUrl, requestInit)
}
if (requestInfo instanceof Request) {
let patchedUrl = patchString(requestInfo.url)
let patchedRequest = new Request(patchedUrl, requestInfo)
return fetch(patchedRequest, requestInit)
}
if (typeof requestInfo === 'string') {
let patchedUrl = patchString(requestInfo)
return fetch(patchedUrl, requestInit)
}
// Should never happen
throw new Error('Unexpected requestInfo type: ' + typeof requestInfo)
}
const vertexFinetuned = createVertex({
project: VERTEX_PROJECT,
location: VERTEX_LOCATION,
fetch: patchedFetchForFinetune as unknown as typeof globalThis.fetch,
})
const model = vertexFinetuned(VERTEX_ENDPOINT_ID)
喜欢这篇文章?订阅邮件,及时获取新文章。