|
| 1 | +require "langchain" |
| 2 | + |
| 3 | +class ImageClassifier |
| 4 | + extend Langchain::ToolDefinition |
| 5 | + |
| 6 | + define_function :classify, description: "Classify photo" do |
| 7 | + property :main_subject, |
| 8 | + description: "Primary subject of the photo", |
| 9 | + type: "string", |
| 10 | + required: true |
| 11 | + property :scene_type, |
| 12 | + description: "Scene setting in the photo", |
| 13 | + type: "string", |
| 14 | + required: true, |
| 15 | + enum: ["urban", "rural", "indoor", "outdoor"] |
| 16 | + property :colors, |
| 17 | + description: "Dominant colors in the photo", |
| 18 | + type: "array", |
| 19 | + required: true do |
| 20 | + item type: "string" |
| 21 | + end |
| 22 | + property :objects, |
| 23 | + description: "List of key objects visible in the image", |
| 24 | + type: "array", |
| 25 | + required: true do |
| 26 | + item type: "string" |
| 27 | + end |
| 28 | + property :actions, |
| 29 | + description: "Activities or movements captured", |
| 30 | + type: "array", |
| 31 | + required: true do |
| 32 | + item type: "string" |
| 33 | + end |
| 34 | + property :number_of_humans, |
| 35 | + description: "Number of people if present", |
| 36 | + type: "number", |
| 37 | + required: true |
| 38 | + property :weather_conditions, |
| 39 | + description: "Weather conditions", |
| 40 | + type: "string", |
| 41 | + required: true, |
| 42 | + enum: ["sunny", "cloudy", "rainy", "snowy", "foggy"] |
| 43 | + property :time_of_day, |
| 44 | + description: "Time of day", |
| 45 | + type: "string", |
| 46 | + required: true, |
| 47 | + enum: ["morning", "afternoon", "evening", "night"] |
| 48 | + property :mood, |
| 49 | + description: "Overall feeling conveyed by the photo", |
| 50 | + type: "string", |
| 51 | + required: true |
| 52 | + end |
| 53 | +end |
| 54 | + |
0 commit comments