You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried finding some more documentation but wasn't able to ...
basically when I have my plugin i find 3 times the entry in the block context menu. and when the plugin is run, it is run three times instead of just one...
I believe this is a bug, but honestly I'm not sure it's not something I actually wrote wrong
Menu Item
## Plugin execution adds 3 times the block afterwards
Code here:
import'@logseq/libs';constsettings={name: 'logseq-claude-prompt',description: 'Send text to Claude with a hardcoded prompt',key: 'MY_KEY',prompt: 'You are a helpful assistant. Please analyze the following text and provide a summary: do nod add anything else'};constcallClaudio=async(contents)=>{console.log("Sending to Claude...")constcontent=contents.join("\n\n")constresponse=awaitfetch('https://api.anthropic.com/v1/messages',{method: 'POST',headers: {'Content-Type': 'application/json','x-api-key': settings.key,'anthropic-version': '2023-06-01'},body: JSON.stringify({model: 'claude-3-5-sonnet-latest',messages: [{role: 'user',content: `${settings.prompt}\n\n${content}`}],max_tokens: 1500})});constdata=awaitresponse.json();returndata;}constmain=()=>{logseq.Editor.registerBlockContextMenuItem('Send to Claude Block and children',async({uuid})=>{letcontents=[]constblock=awaitlogseq.Editor.getBlock(uuid,{includeChildren: true})contents.push(block.content)for(constchildofblock.children){contents.push(child.content)}console.log("contents",contents)try{constdata=awaitcallClaudio(contents)console.log("data",data)if(data.content&&data.content[0]){// Insert Claude's response in a new block belowawaitlogseq.Editor.insertBlock(uuid,`${data.content[0].text}`,{sibling: false});}}catch(error){console.error('Error calling Claude:',error);logseq.UI.showMsg('Error calling Claude API','error');}})console.log(`${settings.name} plugin loaded`);}logseq.ready(main).catch(console.error)
`
The text was updated successfully, but these errors were encountered:
I tried finding some more documentation but wasn't able to ...
basically when I have my plugin i find 3 times the entry in the block context menu. and when the plugin is run, it is run three times instead of just one...
I believe this is a bug, but honestly I'm not sure it's not something I actually wrote wrong
Menu Item
## Plugin execution adds 3 times the block afterwards
Code here:
The text was updated successfully, but these errors were encountered: