feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes
This commit is contained in:
parent
01ef3293cf
commit
66b6b45ba9
399 changed files with 17828 additions and 11330 deletions
|
|
@ -16,6 +16,7 @@
|
|||
// when the lease expired (or the claim predates the lease) and the allowance
|
||||
// is spent by then; that maps to markFailed('quota_exceeded') + 429.
|
||||
|
||||
import { isRecord } from '../_shared/core-contract.generated.ts'
|
||||
import { buildMeetingDocumentSystemPrompt } from '../_shared/generative-ai-safety.ts'
|
||||
import {
|
||||
type GenerateMeetingDocumentRequest,
|
||||
|
|
@ -101,9 +102,6 @@ export interface GenerationDeps {
|
|||
|
||||
export const PROVIDER_MAX_TOKENS = 4096
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
||||
}
|
||||
|
||||
function result(status: number, body: Record<string, unknown>): GenerationHttpResult {
|
||||
return { status, body }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { corsHeaders, handleCorsPreflightRequest } from '../_shared/cors.ts'
|
||||
import { authErrorResponse, requireUser, type AuthError } from '../_shared/auth.ts'
|
||||
import { createStatusJsonResponder, JsonBodyError, readJsonBody } from '../_shared/json-response.ts'
|
||||
import { createServiceRoleClient } from '../_shared/quota.ts'
|
||||
import {
|
||||
MeetingDocumentRequestError,
|
||||
|
|
@ -17,17 +18,8 @@ import {
|
|||
type ServiceClient = ReturnType<typeof createServiceRoleClient>
|
||||
|
||||
const PROVIDER_TIMEOUT_MS = 60_000
|
||||
|
||||
function json(status: number, body: Record<string, unknown>): Response {
|
||||
return new Response(JSON.stringify(body), {
|
||||
status,
|
||||
headers: {
|
||||
...corsHeaders,
|
||||
'Content-Type': 'application/json',
|
||||
'Cache-Control': 'no-store',
|
||||
},
|
||||
})
|
||||
}
|
||||
const MAX_REQUEST_BYTES = 16 * 1024
|
||||
const json = createStatusJsonResponder({ noStore: true })
|
||||
|
||||
const logError: GenerationLogger = (message, context) => {
|
||||
if (context === undefined) console.error(message)
|
||||
|
|
@ -119,8 +111,11 @@ Deno.serve(async (request: Request) => {
|
|||
|
||||
let rawBody: unknown
|
||||
try {
|
||||
rawBody = await request.json()
|
||||
} catch {
|
||||
rawBody = await readJsonBody(request, { maxBytes: MAX_REQUEST_BYTES })
|
||||
} catch (error) {
|
||||
if (error instanceof JsonBodyError && error.status === 413) {
|
||||
return json(413, { error: 'request_too_large' })
|
||||
}
|
||||
throw new MeetingDocumentRequestError('Invalid JSON body')
|
||||
}
|
||||
const body = parseGenerateMeetingDocumentRequest(rawBody)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue