mirror of
https://github.com/bitsofchris/openaugi-obsidian-plugin.git
synced 2026-07-22 05:46:42 +00:00
It works
This commit is contained in:
parent
8b291621f5
commit
278643845a
2 changed files with 19 additions and 5 deletions
18
main.ts
18
main.ts
|
|
@ -127,7 +127,23 @@ Transcript:\n${content}`;
|
|||
throw new Error('No response content received from OpenAI');
|
||||
}
|
||||
|
||||
const structuredData = JSON.parse(messageContent);
|
||||
// Clean up the response content in case it contains markdown formatting
|
||||
let cleanedContent = messageContent;
|
||||
|
||||
// Remove markdown code blocks if present (```json or just ```)
|
||||
const codeBlockMatch = cleanedContent.match(/```(?:json)?\s*([\s\S]*?)```/);
|
||||
if (codeBlockMatch) {
|
||||
cleanedContent = codeBlockMatch[1].trim();
|
||||
}
|
||||
|
||||
// Parse the JSON
|
||||
let structuredData;
|
||||
try {
|
||||
structuredData = JSON.parse(cleanedContent);
|
||||
} catch (parseError) {
|
||||
console.error('Failed to parse JSON response:', cleanedContent);
|
||||
throw new Error(`Failed to parse JSON response: ${parseError.message}`);
|
||||
}
|
||||
|
||||
// Output Summary
|
||||
await this.app.vault.create(`Parsed_Notes/summaries/${filename}_summary.md`, structuredData.summary);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "obsidian-sample-plugin",
|
||||
"name": "open-augi",
|
||||
"version": "1.0.0",
|
||||
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
|
||||
"description": "",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"dev": "node esbuild.config.mjs",
|
||||
|
|
@ -22,7 +22,5 @@
|
|||
"typescript": "^4.7.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^16.5.0",
|
||||
"openai": "^4.94.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue