How to make it so that when answering, he also gave links to the pages of the knowledge base?

We developed a bot for the knowledge base with the help of embending, the question is how to make it so that when answering, it also gives links to the pages of the knowledge base, how to properly integrate these links into its answers?

Hi @Kostarica

You’ll have to map the individual pages to the links, so that when the relevant pages are retrieved, you can pass along the links mapped to them as response.

You can use dictionaries to do that.

1 Like

For each paragraph you add to the vector database, you can also add the corresponding page link for that paragraph in the meta data. So when you retrieve the most relevant paragraphs for a query, you will also get their page links. Then you can pass these links to ChatGPT, and tell it to list the relevant page links in its response.

1 Like

Would you be able to elaborate a bit on what you mean by “tell it to list the relevant links”? How do you do that?

Sure. You can use this as a starting point for your prompt:

You will answer a question based on a knowledge base in the given format.

KNOWLEGE BASE

Source: [the information from a relevant paragraph returned from vector db]
Link: [link for the paragraph above]

Source: [the information from a relevant paragraph returned from vector db]
Link: [link for the paragraph above]

Source: [the information from a relevant paragraph returned from vector db]
Link: [link for the paragraph above]


USER QUESTION
[user question]


OUTPUT FORMAT
In your answer, include a *reference* section at the bottom. For every source from the knowledge base you are using, add its link to the reference section.

Thanks @CreatiCode :bowing_man:

Perhaps I misunderstood OPs question — I guess I’m wondering how to get ChatGPT to include the link to a relevant page—in a response to users input which triggers a query ChatGPT makes to a plugin API endpoint.

In other words, if the ChatGPT Plugin’s API returns something like:

{ "source": "Some text or whatever", "link": "https://example.com/or/whatever" }

How can ChatGPT be controlled to include the link as a citation in it’s response to the user? Since, in this context, we’re not exactly doing any prompt engineering, but instead just giving back a JSON object to ChatGPT.

You can also just remember the links and snippets and then do a similarity comparison of the models answer to the original snippets to identify which snippets (and therefore links) most contributed to the models answer. There’s no real need to pass the source links in as part of the prompt.

For ChatGPT, the user facing service, they’re switching to using Bing to ground all of ChatGPT’s answers so this feature will be coming for free very soon. You’ll get more realtime answers from ChatGPT as they’ll be using to semantic search over the Bing index to ground queries so you’ll get back source citations as well. I believe they’ve trained a classifier to identify which queries need grounding and which ones don’t but not 100% sure on that… Just something I heard in passing.

This may work sometimes, but it may fail when ChatGPT rephrases the source knowledge, or composes it using a few sources. If you are concerned about token count and response time due to the links included, you can use a shorter form of the links, like “L1”, “L2”, then convert them back to full links after you get the response from ChatGPT.

1 Like

If I understand correctly, you are developing a plugin that returns data and source links to ChatGPT, and you want ChatGPT to show them to the user as references, right? It is indeed a prompt engineering task. You can tell ChatGPT to do so either in the model description or your API description. Just tell ChatGPT to show these links as references at the end of its response to the user. It will help to include an example output in the description as well. That is how we show the link to the feedback form at the end of our plugin “CreatiCode Scratch”.

Thanks @CreatiCode! Yes that’s exactly right — ChatGPT Plugin.

Do you mean, in the OpenAPI definition file for your plugin, in a endpoint resource path, you put instructions for ChatGPT? Do you perhaps have an example you could share?

(Thank you for taking the time to respond to these messages! :bowing_man: )

Sure. You can easily find out in our API response.

If you enable our plugin “CreatiCode Scratch”, and ask a question like “show me how to move in a circle”, you will get the API response in the dropdown like this:

thanks thats
I guess I’m wondering how to get ChatGPT to include the link to a relevant page
https://chat.openai.com/