Input path: /home/debian/html/nutritwin/output_llm/67fe9c0be19c8/input.json
Output path: /home/debian/html/nutritwin/output_llm/67fe9c0be19c8/output.json
Input text:
DB path: __deriveddata__/DerivedObjects/Data/KcalMeDB_fr.sl3
Picto path: __deriveddata__/DerivedObjects/Data/PictoMatcherNetNG_fr.json
Sport grounding path: __deriveddata__/DerivedObjects/Data/DerivedSportMET.json
==================================================================================================================================
Prompt from user:
==================================================================================================================================
Image to be analyzed: /home/debian/html/nutritwin/output_llm/67fe9c0be19c8/capture.jpg
##############################################################################################
# For image extraction, pixtral-large-2411 is used #
##############################################################################################
==================================== Prompt =============================================
In the image, identify all the foods and beverages, convert them into an array of JSON with consumed foods.
Ignore what it is not connected to nutrition, beverage or food.
When a food or a beverage has several instances unify them on a single food or beverage and add the quantities of each.
The attribute name must remain in English but the result, so the attribute value, must be in french, and only in french.
Provide a solution without explanation.
Use only the food & beverage ontology described in this Turtle/RDF model:
"""
@prefix food: .
@prefix rdfs: .
@prefix xsd: .
@prefix owl: .
@prefix prov: .
food: a owl:Ontology ;
rdfs:comment "Definition of the food archetype"@en .
food:name a owl:DatatypeProperty;
rdfs:label "name"@en;
rdfs:comment """Food or beverage identifier, the name should not contain information related to quantity or container (like glass...).
Ignore food or beverage when it is not consumed in the past, now or in the future.
The cooking mode is not in the name. The name is only in french."""@en;
rdfs:range xsd:string.
food:quantity a owl:DatatypeProperty ;
rdfs:label "quantity"@en;
rdfs:comment "The quantity of food or drink that is or was consumed. Quantity is only in french. Here are examples: 'un quignon', 'un cornet', 'un verre', 'une tranche', 'une boule', 'un', 'deux', 'trois',... Keep the same language."@en;
rdfs:range xsd:string.
food:cookingMethod a owl:DatatypeProperty ;
rdfs:label "cooking method"@en;
rdfs:comment "The cooking method of food. The cooking method is in french."@en;
rdfs:range xsd:string.
food:type a owl:DatatypeProperty ;
rdfs:label "type of food"@en;
rdfs:comment "Identify the type of food."@en;
rdfs:range xsd:string.
food:food a food:type ;
rdfs:label "food" .
food:beverage a food:type ;
rdfs:label "beverage" .
food:timeOfTheDay a owl:DatatypeProperty ;
rdfs:label "time of the day"@en;
rdfs:comment "Time of the day when food or drink was consumed."@en;
rdfs:range xsd:string.
food:breakfast a food:timeOfTheDay ;
rdfs:label "breakfast" .
food:lunch a food:timeOfTheDay ;
rdfs:label "lunch" .
food:snacking a food:timeOfTheDay ;
rdfs:label "snacking" .
food:dinner a food:timeOfTheDay ;
rdfs:label "dinner" .
food:brand a owl:DatatypeProperty ;
rdfs:label "Brand"@en;
rdfs:comment """Food or beverage brand. The restaurants are not brand.
When the name is very known (ex: Activia, Coca) and the brand is not mentioned, guess the brand."""@en;
rdfs:range xsd:string.
food:company a owl:DatatypeProperty ;
rdfs:label "Company"@en;
rdfs:comment "Product company."@en;
rdfs:range xsd:string.
food:enumEvent a rdfs:Class .
food:event a owl:DatatypeProperty ;
rdfs:label "event"@en;
rdfs:comment "Event of eating or drinking. Each must have an event"@en;
rdfs:range food:enumEvent.
food:intent a food:enumEvent ;
rdfs:label "intent" .
rdfs:comment "When the event should happen"@en.
food:declaration a food:enumEvent ;
rdfs:label "declaration" .
rdfs:comment "When the event has already occured"@en.
food:unknownEvent a food:enumEvent ;
rdfs:label "unknown" ;
rdfs:comment "When the event is unknown in the day"@en.
food:event a owl:DatatypeProperty ;
rdfs:label "event"@en;
rdfs:comment "Event of eating or drinking. Each must have an event"@en;
rdfs:range food:enumEvent.
food:intent a food:enumEvent ;
rdfs:label "intent" .
rdfs:comment "When the event should happen"@en.
food:declaration a food:enumEvent ;
rdfs:label "declaration" .
rdfs:comment "When the event has already occured"@en.
food:unknownEvent a food:enumEvent ;
rdfs:label "unknown" ;
rdfs:comment "When the event is unknown in the day"@en.
"""
Here is an example of result:
[
{
"name": "blanquette de veau",
"quantity": "un plat",
"cookingMethod": "mijot\u00e9",
"timeOfTheDay": "lunch",
"company": "Leclerc",
"type": "food",
"event": "declaration"
},
{
"name": "eau",
"brand": "Evian",
"company": "Danone",
"timeOfTheDay": "breakfast",
"quantity": "un verre",
"type": "beverage",
"event": "intent"
}
]
=========================================================================================
------------------------------ LLM Raw response -----------------------------
[
{
"name": "tartines",
"quantity": "une",
"type": "food",
"event": "unknownEvent"
},
{
"name": "farine d'avoine",
"quantity": "une",
"type": "food",
"event": "unknownEvent"
},
{
"name": "riz",
"quantity": "une",
"type": "food",
"event": "unknownEvent"
}
]
-----------------------------------------------------------------------------
----------------- Make it compliant ------------------
[
{
"name": "tartines",
"quantity": "une",
"type": "food",
"event": "unknownEvent"
},
{
"name": "farine d'avoine",
"quantity": "une",
"type": "food",
"event": "unknownEvent"
},
{
"name": "riz",
"quantity": "une",
"type": "food",
"event": "unknownEvent"
}
]
------------------------------------------------------
------------------------ After simplification ------------------------
[
{
"name": "tartines",
"quantity": "une",
"type": "food",
"event": "unknownEvent"
},
{
"name": "farine d'avoine",
"quantity": "une",
"type": "food",
"event": "unknownEvent"
},
{
"name": "riz",
"quantity": "une",
"type": "food",
"event": "unknownEvent"
}
]
----------------------------------------------------------------------
--------------------------------- LLM result -----------------------------------
{'response': [{'name': 'tartines', 'quantity': 'une', 'type': 'food', 'event': 'unknownEvent'}, {'name': "farine d'avoine", 'quantity': 'une', 'type': 'food', 'event': 'unknownEvent'}, {'name': 'riz', 'quantity': 'une', 'type': 'food', 'event': 'unknownEvent'}], 'cost': 0.0}
--------------------------------------------------------------------------------
----------- result to be analyzed -----------
{'name': 'tartines', 'quantity': 'une', 'type': 'food', 'event': 'unknownEvent'}
First try:
SELECT V_Name,V_Comment,V_NormName,V_NormComment,V_PackType,V_GTIN,V_GTINRef,V_ID,V_GlobalCount,V_NormTrademark,V_Trademark,V_NormAggr FROM KCALME_TABLE WHERE V_NormName LIKE '% tartine %' AND (V_NormTrademark = '' OR V_NormTrademark IS NULL)
------------- Found solution (max 20) --------------
Tartine - tartine - 50g pain, 30g pâte à tartiner - - 850 - - - KCA#4dea84eda45b1bb9527b4b39d474cacc
Tartine - tartine - 50g pain, 10g Beurre, 30g confiture - - 7418 - - - KCA#021bd6fe85becd19fab9b68620d61c71
Tartine de Miel - tartine de miel - de miel - - 0 - - - KCA#f1120bad0f1824670c66545c12c253b8
Tartine Sarrasin - tartine sarrasin - tartine sarrasin - - 0 - - - KCA#b669c214d32d4f79a42a01ca6d4e8bd0
Tartine Craquante - tartine craquante - extrudée et grillée - - 0 - - - CIQ#b0f8ac9e031af58a2e32774b534cbd6e
Tartine de Confiture - tartine de confiture - de confiture - - 0 - - - KCA#6c5c28a4f42a6ca22e6e6d39dc7c28dc
Tartine de Beurre Doux - tartine de beurre dou - beurre doux - - 0 - - - KCA#73ab96821f0df4bf67f8d4d45dc538ef
----------------------------------------------------
----------- result to be analyzed -----------
{'name': "farine d'avoine", 'quantity': 'une', 'type': 'food', 'event': 'unknownEvent'}
First try:
SELECT V_Name,V_Comment,V_NormName,V_NormComment,V_PackType,V_GTIN,V_GTINRef,V_ID,V_GlobalCount,V_NormTrademark,V_Trademark,V_NormAggr FROM KCALME_TABLE WHERE V_NormName LIKE '% farine avoine %' AND (V_NormTrademark = '' OR V_NormTrademark IS NULL)
--> CPU time in DB: 0.1406 seconds
Word: Farine d'Avoine Complète - dist: 0.4654722809791565 - row: 40753
Word: Farine d'Épeautre - dist: 0.5714553594589233 - row: 1184
Word: Farine - dist: 0.5816138386726379 - row: 40573
Word: Farine de Froment - dist: 0.5822468400001526 - row: 9344
Word: Flocon d'Avoine - dist: 0.5904420018196106 - row: 1201
Found embedding word: Farine d'Avoine Complète
Traceback (most recent call last):
File "/home/debian/html/nutritwin/resources/KCALLMMainService.py", line 71, in
omess = KCALLMMain.runEvent(event)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/debian/html/nutritwin/resources/KCALLMMain.py", line 132, in runEvent
resp = KCALLMMainSpeechToData.execute(speech, imagePath, image64, comment, appId, device, version, age, gender, longitude, latitude, test)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/debian/html/nutritwin/resources/KCALLMMainSpeechToData.py", line 39, in execute
omess = executeLLMSingle(text, imagePath, image64, comment, model)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/debian/html/nutritwin/resources/KCALLMMainSpeechToData.py", line 195, in executeLLMSingle
sols = KCALLMNutritionUtilities.getBestSolutions(jresult["response"], dbPath, dbEmbeddingPath, jVoca)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/debian/html/nutritwin/resources/KCALLMNutritionUtilities.py", line 395, in getBestSolutions
dbCursor.execute(q)
sqlite3.OperationalError: near "Avoine": syntax error