Skip to content

Commit

Permalink
Make it work on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
brokensandals committed Jul 6, 2024
1 parent 752f963 commit fa6855c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 10 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"typescript": "4.7.4"
},
"dependencies": {
"@anthropic-ai/sdk": "^0.24.3"
"@anthropic-ai/sdk": "^0.24.3",
"base64-arraybuffer": "^1.0.2"
}
}
3 changes: 2 additions & 1 deletion src/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Anthropic, ClientOptions } from "@anthropic-ai/sdk";
import { AutoImageAltSettings } from "./settings";
import { RequestUrlParam, RequestUrlResponse, requestUrl } from "obsidian";
import { TextBlock } from "@anthropic-ai/sdk/resources";
import { encode } from "base64-arraybuffer";

export class AltGen {
anthropic: Anthropic;
Expand Down Expand Up @@ -83,7 +84,7 @@ export class AltGen {
{
type: 'image',
// @ts-ignore
source: { type: 'base64', media_type: mediaType, data: Buffer.from(imageData).toString('base64') },
source: { type: 'base64', media_type: mediaType, data: encode(imageData) },
},
{
type: 'text',
Expand Down

0 comments on commit fa6855c

Please sign in to comment.