Skip to content

Commit

Permalink
Fix ai binding get logs encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
G4brym committed Apr 22, 2024
1 parent ec539a3 commit 1d2eafe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cloudflare/internal/ai-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class Ai {
try {
const logHeader = res.headers.get("cf-ai-logs")
if (logHeader) {
parsedLogs = (JSON.parse(atob(logHeader)) as string[]);
parsedLogs = (JSON.parse(decodeURIComponent(atob(logHeader))) as string[]);
}
} catch {
/* empty */
Expand Down
2 changes: 1 addition & 1 deletion src/cloudflare/internal/test/ai/ai-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default {

const respHeaders = {
'cf-ai-req-id': '3a1983d7-1ddd-453a-ab75-c4358c91b582',
'cf-ai-logs': (data.options.debug) ? btoa(JSON.stringify(["Model started", "Model run successfully"])) : null
'cf-ai-logs': (data.options.debug) ? btoa(encodeURIComponent(JSON.stringify(["Model started", "Model run successfully"]))) : null
}

if (modelName === 'blobResponseModel') {
Expand Down

0 comments on commit 1d2eafe

Please sign in to comment.