feat: adding events and locations to json schema

This commit is contained in:
2025-03-19 09:46:42 +00:00
parent 072eebc0bf
commit 56d423d261
2 changed files with 164 additions and 34 deletions

82
backend/ai_response.json Normal file
View File

@ -0,0 +1,82 @@
{
"name": "schema_description",
"schema": {
"type": "object",
"properties": {
"tags": {
"type": "array",
"description": "A list of tags you think the image is relevant to.",
"items": {
"type": "string"
}
},
"text": {
"type": "array",
"description": "A list of sentences the image contains.",
"items": {
"type": "string"
}
},
"links": {
"type": "array",
"description": "A list of all the links you can find in the image.",
"items": {
"type": "string"
}
},
"events": {
"type": "array",
"description": "A list of events you see on the image, mostly there usually only 1 or 0 events",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"location": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"coordinates": {
"type": ["string", "null"]
},
"address": {
"type": ["string", "null"]
},
"description": {
"type": ["string", "null"]
}
}
}
}
}
},
"locations": {
"type": "array",
"description": "A list of locations you see on the image, usually theres only 1 or 0 locations",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"coordinates": {
"type": ["string", "null"]
},
"address": {
"type": ["string", "null"]
},
"description": {
"type": ["string", "null"]
}
}
}
}
},
"required": ["tags", "text", "links", "events", "locations"],
"additionalProperties": false
},
"strict": true
}

View File

@ -173,13 +173,59 @@ const RESPONSE_FORMAT = `
"items": {
"type": "string"
}
},
"events": {
"type": "array",
"description": "A list of events you see on the image, mostly there usually only 1 or 0 events",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"location": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"coordinates": {
"type": ["string", "null"]
},
"address": {
"type": ["string", "null"]
},
"description": {
"type": ["string", "null"]
}
}
}
}
}
},
"required": [
"tags",
"text",
"links"
],
"locations": {
"type": "array",
"description": "A list of locations you see on the image, usually theres only 1 or 0 locations",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"coordinates": {
"type": ["string", "null"]
},
"address": {
"type": ["string", "null"]
},
"description": {
"type": ["string", "null"]
}
}
}
}
},
"required": ["tags", "text", "links", "events", "locations"],
"additionalProperties": false
},
"strict": true
@ -319,5 +365,7 @@ func (client OpenAiClient) GetImageInfo(imageName string, imageData []byte) (Ima
return ImageInfo{}, err
}
log.Println(string(response))
return parseOpenAiResponse(response)
}