Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use [title](url) format for note titles #1153

Merged
merged 2 commits into from
Feb 6, 2025

Conversation

iinkov
Copy link
Contributor

@iinkov iinkov commented Feb 2, 2025

src/constants.ts Outdated
@@ -13,7 +13,7 @@ export const DEFAULT_SYSTEM_PROMPT = `You are Obsidian Copilot, a helpful assist
4. If the user mentions "@vault", it means the user wants you to search the Obsidian vault for information relevant to the query. The search results will be provided to you in the context. If there's no relevant information in the vault, just say so.
5. If the user mentions any other tool with the @ symbol, check the context for their results. If nothing is found, just ignore the @ symbol in the query.
6. Always use $'s instead of \\[ etc. for LaTeX equations.
7. When showing note titles, use [[title]] format and do not wrap them in \` \`.
7. When showing note titles, use [title](url) format and do not wrap them in \` \`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested this? Does it work for you? I don't see how the model can get the url from anywhere.

Copy link
Contributor Author

@iinkov iinkov Feb 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was hallucinating a lot, I changed it to this [title](obsidian://open?file=FILENAME)
Let me play with it for a week

src/constants.ts Outdated
@@ -13,7 +13,7 @@ export const DEFAULT_SYSTEM_PROMPT = `You are Obsidian Copilot, a helpful assist
4. If the user mentions "@vault", it means the user wants you to search the Obsidian vault for information relevant to the query. The search results will be provided to you in the context. If there's no relevant information in the vault, just say so.
5. If the user mentions any other tool with the @ symbol, check the context for their results. If nothing is found, just ignore the @ symbol in the query.
6. Always use $'s instead of \\[ etc. for LaTeX equations.
7. When showing note titles, use [[title]] format and do not wrap them in \` \`.
7. When showing note titles, use [title](obsidian://open?file=FILENAME) format and do not wrap them in \` \`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, have you tested this? Can you please show an example with this system prompt, what does it really return in the response.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is response

There is no note titled "My Note for Logan". There is a note titled [My Note](obsidian://open?file=My%20Note), but it is not specifically for Logan.

Sources:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I tested it with gemini

@logancyang
Copy link
Owner

I don't think hardcoding system prompt is the best way to solve this. The ideal solution is to modify the md renderer directly.

@iinkov
Copy link
Contributor Author

iinkov commented Feb 3, 2025

I don't think hardcoding system prompt is the best way to solve this. The ideal solution is to modify the md renderer directly.

Yes, you are right. I did it in VaultQAChainRunner this time. However, it returns different formats of links. Perhaps some additional regex will need to be added. To get a wikilink for copying, back conversion could be done.

@logancyang
Copy link
Owner

I don't think hardcoding system prompt is the best way to solve this. The ideal solution is to modify the md renderer directly.

Yes, you are right. I did it in VaultQAChainRunner this time. However, it returns different formats of links. Perhaps some additional regex will need to be added. To get a wikilink for copying, back conversion could be done.

I did have something like this in the past releases and some reported that they didn't like it.

Instead of making changes to the chain runner, we should update the ChatSingleMessage rendering directly with a post-processing step. That ensures it is not chain-dependent. And we make it a post-processing step just to make deep links as a display fix in AI responses, when the user copy/insert it to note, it should still have [[]] as it was.

@logancyang logancyang merged commit 56e82f0 into logancyang:master Feb 6, 2025
2 checks passed
@logancyang logancyang mentioned this pull request Feb 6, 2025
@logancyang
Copy link
Owner

@iinkov congrats on your first PR for Copilot! Great job, I already hear positive feedback for this! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants