References provide information about the source of data retrieved by a tool call. When a tool call is triggered, you can add references to the context and later use these entries in a plugin to provide users with referenced pages or other relevant information. References are part of the context.
References are not automatically added for the AI. You need to implement this functionality if needed.
Let's create middleware that adds relevant weather information to the context.
In this example, the AI receives information about the requested city, and the context includes information about the source of this data.
The references
object provides two functions: getReferences
and addReference
.
If you want to present users with information about references, you need to manually add them to the response.
By using these functions, you can ensure that users are informed about the sources of the information they receive.