Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
rpggio committed May 31, 2024
2 parents 76baf4f + 1fa9857 commit c3685ef
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"typescript": "4.7.4"
},
"dependencies": {
"js-tiktoken": "^1.0.10"
"js-tiktoken": "^1.0.12"
}
}
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

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

13 changes: 12 additions & 1 deletion src/noteGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,19 @@ export function noteGenerator(
const inputLimit = getTokenLimit(settings)

let shouldContinue = true
if (!nodeText) {
return shouldContinue
}

if (nodeText) {
if (nodeText.startsWith('data:image')) {
messages.unshift({
content: [{
'type': 'image_url',
'image_url': { 'url': nodeText }
}],
role: 'user'
})
} else {
if (isSystemPromptNode(nodeText)) return true

let nodeTokens = encoding.encode(nodeText)
Expand Down
6 changes: 5 additions & 1 deletion src/obsidian/fileUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ export async function readNodeContent(node: CanvasNode) {
case 'file':
const file = app.vault.getAbstractFileByPath(nodeData.file)
if (file instanceof TFile) {
const body = await app.vault.read(file)
const ext = file.extension
if (node.subpath) {
return await readFileContent(app, file, nodeData.subpath)
} else if (ext === 'png' || ext === 'jpg' || ext === 'jpeg') {
const fileBuffer = Buffer.from(await app.vault.adapter.readBinary(file.path))
return `data:image/${ext};base64,${fileBuffer.toString('base64')}`
} else {
const body = await app.vault.read(file)
return `## ${file.basename}\n${body}`
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/openai/chatGPT-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export namespace openai {
* @type {string}
* @memberof ChatCompletionRequestMessage
*/
content: string
content: string | [{}]
/**
* The name of the user in a multi-user chat
* @type {string}
Expand Down
4 changes: 4 additions & 0 deletions src/openai/chatGPT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export const CHAT_MODELS = {
name: 'gpt-3.5-turbo-1106',
tokenLimit: 16385
},
GPT_4o: {
name: 'gpt-4o',
tokenLimit: 128000
},
GPT_4: {
name: 'gpt-4',
tokenLimit: 8192
Expand Down

0 comments on commit c3685ef

Please sign in to comment.