Well itās quite complicated, Iām used langchain and it doesnāt support it natively so Iāve tried my best
Iāll share an example of memory history (itās in italian)
MESSAGES: {
"history": [
{
"id": [
"HumanMessage"
],
"kwargs": {
"content": "Buonasera, vorrei prenotare un tavolo per stasera alle 21 fuori.",
"additional_kwargs": {}
}
},
{
"id": [
"AIMessage"
],
"kwargs": {
"content": "",
"additional_kwargs": {
"function_call": {
"name": "selezione_azione",
"arguments": "{\n \"selezione\": \"prenotazione\"\n}"
}
}
}
},
{
"id": [
"FunctionMessage"
],
"kwargs": {
"content": "{azione:\"prenotazione\"}",
"name": "selezione_azione",
"additional_kwargs": {
"name": "selezione_azione"
}
}
},
{
"id": [
"HumanMessage"
], "kwargs": {
"content": "",
"additional_kwargs": {}
}
},
{
"id": [
"AIMessage"
],
"kwargs": {
"content": "",
"additional_kwargs": {
"function_call": {
"name": "prenotazione",
"arguments": "{\n \"data\": {\n \"giorno\": \"oggi\",\n \"orario\": \"21:00\"\n },\n \"extra\": {\n \"zona\": \"fuori\"\n }\n}"
}
}
}
}
]
}
After this i remove the last Function Message and the last empty Human Message leaving AIMessage only.
Now the AI should be able to detect that an answer is possible to be given, but it replay the function another time
MESSAGES: {
"history": [
{
"id": [
"HumanMessage"
],
"kwargs": {
"content": "Buonasera, vorrei prenotare un tavolo per stasera alle 21 fuori.",
"additional_kwargs": {}
}
},
{
"id": [
"AIMessage"
],
"kwargs": {
"content": "",
"additional_kwargs": {
"function_call": {
"name": "selezione_azione",
"arguments": "{\n \"selezione\": \"prenotazione\"\n}"
}
}
}
},
{
"id": [
"AIMessage"
],
"kwargs": {
"content": "",
"additional_kwargs": {
"function_call": {
"name": "prenotazione",
"arguments": "{\n \"data\": {\n \"giorno\": \"oggi\",\n \"orario\": \"21:00\"\n },\n \"extra\": {\n \"zona\": \"fuori\"\n }\n}"
}
}
}
}, {
"id": [
"FunctionMessage"
],
"kwargs": {
"content": "{tavolo_disponibile:true}",
"name": "prenotazione",
"additional_kwargs": {
"name": "prenotazione"
}
}
},
{
"id": [
"HumanMessage"
],
"kwargs": {
"content": "",
"additional_kwargs": {}
}
},
{
"id": [
"AIMessage"
],
"kwargs": {
"content": "",
"additional_kwargs": {
"function_call": {
"name": "prenotazione",
"arguments": "{\n \"data\": {\n \"giorno\": \"oggi\",\n \"orario\": \"21:00\"\n },\n \"extra\": {\n \"zona\": \"fuori\"\n }\n}"
}
}
}
}
]
}
And it goes over in the same loop. If instead of asking āStasera alle 21 fuoriā I just ask āStasera alle 21ā it works as it should