Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Using DataStore Response in Dialogflow Prompt/Generator

How do I use response from connected datastores: $request.knowledge.answers[0] in a generator/prompt in dialogflow cx.

The reason I want to do this is because sometimes the datastore response have incomplete sentences or wrong phrases at the end.

Solved Solved
0 11 3,095
1 ACCEPTED SOLUTION

xavidop_0-1699013650119.png

the image that was not attached

View solution in original post

11 REPLIES 11

Hi!

To do that you have to set in your generator a variable, to add a variable
you just need to use the $symbol. For example:

Tell a joke about whatever. you have this useful information $information.

Once you add that in the generator, whenever you use the generator, you
will see a box to fill the $information parameter. There you just need to
set that to $request.knowledge.answers[0]. Something like this;
[image: image.png]

Best,
Xavi

xavidop_0-1699013650119.png

the image that was not attached

Tried this already. It is not picking up the value.

Screenshot 2023-11-03 at 5.57.23 PM.png

Make sure that saved the generator, if not it will not show up

Working now, I was using the wrong variable it should have been $request.knowledge.answers[0]

@xavidop or @SrikantaHexa  Did your generator hallucinate?  I have my generator take the datastore response, go into the generator (very similar to your prompt above) however it hallucinates on the website link portion.  

My prompt is :
Assume you are an intelligent and polite assistant. The user has asked $last-user-utterance, answer it considering $conversation as the context. We got the response from our own datastore is: $datastoredefault. Make sure use these details in your response. Be sure to include any links provided from the datastore response and be sure to include the entire link. Do not make up any website links, only provide the link if it came from the datastore. Make sure you keep the response below 500 characters & it shouldn't have any incomplete words or sentences.

However when it provides the link, 50% its not a real link

For example if i ask my cybersecurity bot, 'I think i have a computer virus'  It gives a great response but then says go to link: https://www.companyname.com/i-think-have-computer-viurs

which is not a real page location.  This link is not seen in the original datastore response too.

All LLMs hallucinate! you should add some guardrails to avoid that but it is something not easy. With langchain, there are more useful options

What guard rails can I add with the generator? I have been doing prompt injection but still same results.  And do you have an examples or documentation related to langchain and Dialogflow CX?

the only way to use langchain and dialogflow CX is in a webhook.

Look at this article: https://medium.com/@bijit211987/advanced-prompt-engineering-for-reducing-hallucination-bb2c8ce62fc6 ti is going to be very useful for you

@xavidop 

Thank you for that.  The main reason I doing this is to reference the url links from the data store response feature.  I am using ujet as the SDK and it does not support this function.

Do you know how to reference the rich content payload into the agent response?

request.knowledge.richconten.actionLink[0]?

you can use:

$sys.func.GET_FIELD($sys.func.GET($request.knowledge.sources[0], 0), "uri")

$sys.func.GET_FIELD($sys.func.GET($request.knowledge.sources[0], 0), "title")

I get it from here: https://www.googlecloudcommunity.com/gc/AI-ML/DialogFlow-CX-Data-stores-with-custom-payload/m-p/6994...