logancyang / obsidian-copilot

THE Copilot in Obsidian
https://www.obsidiancopilot.com/
GNU Affero General Public License v3.0
2.82k stars 193 forks source link

[FR] Use specified files to build a dedicated Q&A robot for similar questions #278

Closed wwjCMP closed 7 months ago

wwjCMP commented 8 months ago

Build a custom question-answering bot using specific combinations of files and a custom prompt, similar to a simple plugin or GPTs. This is furthering the prompt template.

For example, using the documentation of a software + custom prompt, you can build a dedicated bot to answer questions related to that software. This way, every time I want to inquire about knowledge about the software, I can just call up this bot.

When using locally deployed large models, there are also similar mature workflows. Taking ChatGLM3 as an example, such as ChatGLM3+M3E+FastGPT. https://www.bilibili.com/video/BV1Ug4y1o7gb/?spm_id_from=333.337.search-card.all.click&vd_source=4da716c2c9e733b14045d5c5b12eb8c1 (in Chinese)

logancyang commented 8 months ago

I'm working on an upgraded custom prompt that

This way you can compose your own complex long prompt using your vault.

wwjCMP commented 8 months ago

I'm working on an upgraded custom prompt that

  • Allow more variables, not just with selection.
  • {} means selection. If no {}, no selection is inserted
  • {noteName} means replace with note content
  • {noteFolderPath} means replace with the whole folder of notes

This way you can compose your own complex long prompt using your vault.

Is it possible to integrate with dataview/dataviewjs? Or provide similar query syntax.

https://github.com/logancyang/obsidian-copilot/issues/262#issuecomment-1914570343

logancyang commented 8 months ago

@wwjCMP right, that would be the endgame, the most powerful way to filter notes. From a little bit of searching it seems here's the reference https://blacksmithgu.github.io/obsidian-dataview/resources/develop-against-dataview/

I'm still going to build the above first since it doesn't have a learning curve. I think even with this simple setup, one can have a note that has dataview query in it, and use the note as {noteName} in the custom prompt so that Copilot constructs the prompt using the result from dataview (when Copilot can get dataview results in notes, it currently can't). That way, there's no need to write dataview query directly inside the custom prompt modal.

logancyang commented 8 months ago

I know this FR is mostly geared toward a QA (RAG) scenario, but please also try the new advanced custom prompts in v2.4.16 released earlier, using notes and folder paths along with optional selected text to compose complex long prompts for models with a big context window!

wwjCMP commented 8 months ago

Manually setting the format of multiple files can be optimized a bit. {[[A]] [[B]] [[C]]}

Now I need to use multiple {}.

wwjCMP commented 8 months ago

One more question. Is the new updated feature still based on Chat mode?

logancyang commented 8 months ago

Manually setting the format of multiple files can be optimized a bit. {[[A]] [[B]] [[C]]}

Now I need to use multiple {}.

Is using multiple {} really that much worse? You still use multiple [[]] anyway. I mean, allowing {[[x]] [[y]], [[z]]} opens way more possible combinations people can put there, it will become way more complex unnecessarily.

logancyang commented 8 months ago

One more question. Is the new updated feature still based on Chat mode?

Yes. You can technically still use it in QA mode but it will trigger RAG and make the conversation more about the context it retrieved. It is best consumed with a long context window model in Chat mode.

wwjCMP commented 8 months ago

How do I use it in QA mode? Would it be more effective in QA mode when the reference information provided in the template is too long and scattered (like a knowledgeable robot)?

logancyang commented 8 months ago

How do I use it in QA mode? Would it be more effective in QA mode when the reference information provided in the template is too long and scattered (like a knowledgeable robot)?

It could, but it will likely exceed your context window much faster even if you have a big-window model (since now you are essentially sending a super long prompt + retrieved docs to a model). My personal opinion is to use Advanced Custom Prompt mainly in Chat mode, i.e. directly send your notes to the model, it is essentially a QA session but without being in QA mode (and it's likely more effective than QA mode because the Retrieval in RAG is sometimes unreliable).

My goal of having this Advanced Custom Prompt feature is to make people use Chat model with a big-window model more than QA mode for questions about a set of note that is not too big. Now we have free / local models like Mixtral 8x7B by OpenRouter that has 32k window, it usually does a good job if you just send your notes in a batch to it directly in Chat mode, and it would outperform QA mode in cases where retrieval fails.

You would only need QA mode for super long stuff, more than 32k tokens (like a super long book or a big vault), where you cannot plug them directly into the model. In that case QA mode (RAG) is essential.

logancyang commented 7 months ago

Closing as the advanced custom prompt should be covering this.

wwjCMP commented 5 months ago

Manually setting the format of multiple files can be optimized a bit. {[[A]] [[B]] [[C]]} Now I need to use multiple {}.

Is using multiple {} really that much worse? You still use multiple [[]] anyway. I mean, allowing {[[x]] [[y]], [[z]]} opens way more possible combinations people can put there, it will become way more complex unnecessarily.

I don't quite understand what you're saying, but I can directly obtain [] from the search results.