LogoLogo
Visit Contextual.ioSign Up
  • Getting Started
    • Welcome
    • Tour: Hello, AI World!
  • TRAINING
    • Basic Developer Training Course
      • Lesson 1: HTTP Agent Introduction
      • Lesson 2: Logging and Error Handling Basics
      • Lesson 3: Event Processing Agent Introduction
  • Services Catalog
    • What's in the Catalog?
      • Intro Patterns
      • Object Type Bundles
    • Browse by Platform
    • All Intro Patterns
      • Anthropic Claude Image Analysis
      • Mistral AI Prompt and Response
      • xAI Grok Prompt and Response
      • DeepSeek Chat Prompt and Response
      • Qwen Chat Prompt and Response
      • Perplexity AI Search and Response
      • Firecrawl Website Scraper
      • Groq Prompt and Response
      • Nyckel Dog Breed Classification
      • RapidAPI ClassifyAI Text Classification
      • RapidAPI YouTube AI Video Summary
      • UnifyAI Model Comparison
      • WebPilot URL Analysis and Summarization
      • OpenAI Assistants Prompt and Response
      • OpenAI Sync
    • All Prebuilt Solutions
      • Invoice AI
      • Lead Generation Form
    • All Object Type Bundles
      • Work Order Management System ITIL Object Type Bundle
        • Work Order
        • User
        • Role
        • Permission
        • Asset
        • Task
        • Action
        • Attachment
        • Comment
        • Notification
        • Audit Log
        • Service Level Agreement
        • Custom Fields
        • Work Order Template
        • Work Order Transition
        • Escalation Policy
        • Tag
  • Components & Data
    • Object Types
      • Data in Contextual
        • Secrets
        • Validation
        • Versioning
      • Examples
      • Creating an Object Type
      • Object Type Details
        • Definition
        • Data Schema
          • Automatic Record Metadata
          • Generated Values
            • Dates and Times
            • UUIDs
          • Frequently Used Validation
          • Disallowing Null Property Values
          • Disallowing Undefined Properties
          • Secrets
          • AI Assistant
          • ID and PrimaryKey Permanence
        • UI Schemas
        • Features
        • Triggers
        • Actions
        • Audit Trail
        • Versions
        • Templates
        • Records
      • Using Object Types in Flows
      • Records
        • Records and Your Tenant API
        • Record Import
    • Flows
      • Nodes
      • Wires
      • Message Object
      • Flow Editor
        • Basics
        • Saving Changes
        • In-Flow Testing with Debugger
        • Restart Agents to Make Changes Active
        • Config
      • Node Reference
        • Common
          • Log Tap
          • Inject
          • Debug
          • Complete
          • Catch
          • Status
          • Link In
          • Link Call
          • Link Out
          • Comment
        • Event
          • Prepare Event
          • Event Start
          • Event End
          • Event Error
        • Object
          • Search Object
          • Get Object
          • Create Object
          • Patch Object
          • Put Object
          • Delete Object
          • Run Action
        • Request
          • Send to Agent
          • HTTP GET
          • HTTP PATCH
          • HTTP PUT
          • HTTP DELETE
          • HTTP POST
          • GQL
          • Produce Message
        • Function
          • Function
          • Switch
          • Change
          • Range
          • Template
          • Delay
          • Trigger
          • Exec
          • Filter
          • Loop
        • Models
          • ML Predict
        • Network
          • MQTT In
          • MQTT Out
          • HTTP In
          • HTTP Response
          • HTTP Request
          • WebSocket In
          • WebSocket Out
          • TCP In
          • TCP Out
          • TCP Request
          • UDP In
          • UDP Out
        • Sequence
          • Split
          • Join
          • Sort
          • Batch
        • Parser
          • csv
          • html
          • json
          • xml
          • yaml
    • Agents
      • Creating an Agent
      • Types of Agents
        • Event to Flow
        • HTTP to Flow
          • Custom Domains
      • How Agents Work
        • Flow Execution
        • HTTP Load Balancing
        • Event Routing
      • Scale and Performance
        • Flow execution
        • Parallel Instances
        • Event Lag Scaling
        • Compute Threshold Scaling
        • Instance Compute Sizing
      • Agent Details
        • Definition
        • Operations
        • Logs
          • Session Log
          • Message Log
        • Audit Trail
        • Versions
      • Using Agents in Flows
    • Connections
      • Creating a Connection
      • Types of Connections
        • Basic
        • Bearer
        • Client Grant
        • Kafka
        • Password Grant
        • Public
        • Pulsar
      • Using Connections in Flows
    • JWKS Profiles
      • Using JWKS Profiles in Your Solution
  • PATTERNS
    • Solution Architecture
      • Events, Messages, Queues
    • Working with Data
      • Search Object Node & Pagination
      • Message Payload Content - Triggers and Actions
    • Industry Cookbooks
      • Field Services
  • Tenants
    • Tenant Workspace
    • Tenant Logs
      • Contextual Log Query Language (CLQL)
        • String Searches
        • Keyword Searches
        • Advanced Operators
    • Tenant API
      • API Keys
        • API Key Settings
        • API Key Permissions
      • Documentation
  • Release Notes
    • 2024
      • 2024.12.09
Powered by GitBook
On this page
  • What's Included
  • What You'll Need
  • Ideas for Using the Nyckel Dog Breed Image Classification Flow
  • Flow Overview
  • Nyckel Dog Breed Image Classification Flow Details
  • Summary of Flow

Was this helpful?

  1. Services Catalog
  2. All Intro Patterns

Nyckel Dog Breed Classification

PreviousGroq Prompt and ResponseNextRapidAPI ClassifyAI Text Classification

Last updated 9 months ago

Was this helpful?

The Nyckel Dog Breed Image Classification Flow is designed to automatically classify the breed of a dog from an image URL and provide fun facts about the breed. This flow simplifies the process of sending an image to the Nyckel API for classification, retrieving the breed information, and then enhancing it with fun facts using OpenAI's API. The results are then formatted and stored as records for further use.

This flow is particularly useful in applications such as image analysis, educational content creation, and automated content enrichment.

You can find this template in the Services Catalog under these categories:

  • AI, Contextual Basics, Enrichment

What's Included

  • 1 Flow

  • 1 Object Type

  • 2 Connections

What You'll Need

  • No need for an API Key for Nyckel for this demo - we've got an endpoint configured for you

  • to get your own access to the Nyckel API and ability to host and train your own models for integration into your Contextual projects

  • Access to the OpenAI API

  • API Key for the OpenAI service

Ideas for Using the Nyckel Dog Breed Image Classification Flow

Image Analysis and Classification

Use this flow to automatically classify the breed of dogs from images. This can be particularly helpful for developers building applications in the pet industry or for educational purposes.

Content Enrichment

Generate fun and engaging content based on dog breed classifications. For example, this flow can be used to enrich articles, blogs, or social media posts with interesting facts about various dog breeds.

Educational Tools

Create an interactive learning tool where users can upload dog images and receive detailed information about the breed, including fun facts. This can be a valuable addition to educational apps and websites.

Flow Overview

Flow Start

The flow begins by receiving an image URL, which is for demo and testing, injected as an input when editing the flow or received from an external event.

Convert Image URL to Binary Buffer

The image URL is converted to a binary buffer, preparing it for classification by the Nyckel API.

Send Image URL and Receive Breed Classification

The flow sends the binary image data to the Nyckel API, which processes the image and returns the breed classification.

Send Breed Classification to OpenAI and Receive Fun Facts

The classified breed information is sent to the OpenAI API, which generates fun facts about the breed. The response includes interesting and engaging facts formatted for easy display.

Format Classification and Fun Facts then Create Record

The classification result and the fun facts are combined into a structured format and stored as a new record in Contextual. This ensures that the information is readily accessible for future reference or display.

Error Handling

Any errors encountered during the flow are captured and logged, ensuring that issues can be quickly identified and resolved.

Flow End

The flow concludes once the records have been successfully created or any errors have been logged.

Nyckel Dog Breed Image Classification Flow Details

Inbound Send to Agent Events

  • Nodes: contextual-start

  • Purpose: The flow begins by receiving an image URL, either injected directly or received from an external source.

In-Editor Testing

  • Nodes: Test Prompt, Convert Image URL to Binary Buffer

  • Purpose: Allows for testing the image URL directly within the editor. The image URL is converted to a binary format that is suitable for the Nyckel API.

Code Example: Convert Image URL to Binary Buffer Function

codemsg.payload = {
    // URL of the dog image to be classified
    dogImage: "https://images.pexels.com/photos/3763313/pexels-photo-3763313.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2"
};
return msg;

Explanation: This function assigns the image URL to msg.payload, preparing it for processing by the flow. The image URL is the input that will be classified by the Nyckel API.

Send Image URL and Receive Breed Classification

  • Nodes: Prepare Classification Request, Prompt Nyckel, Nyckel Response

  • Purpose: The binary image is sent to the Nyckel API, which returns a breed classification. This information is logged and passed on for further processing.

Code Example: Prepare Classification Request Function

codemsg.payload = {
    // Set the 'data' field to the image URL for classification
    data: msg.event.dogImage
};
return msg;

Explanation: This function prepares the payload by assigning the image URL to the data field, which is required by the Nyckel API to classify the image.

Send Breed Classification and Receive Fun Facts

  • Nodes: Prepare "Fun Facts" Request, Prompt OpenAI Chat, OpenAI Chat Response

  • Purpose: The breed classification is sent to the OpenAI API, which generates fun facts about the breed. The response is logged and formatted for record creation.

Code Example: Prepare "Fun Facts" Request Function

codemsg.payload = {
    model: "gpt-4o-mini",
    messages: [
        {
            role: "system",
            content: "You are an expert on dog breeds. Provide three fun and interesting facts in bulletpoint format."
        },
        {
            role: "user",
            content: `Tell me three fun facts about this dog breed: ${msg.breedClassification.labelName}`
        }
    ]
};
return msg;

Explanation: This function constructs the payload for the OpenAI API, specifying the model and the messages required to generate fun facts about the classified dog breed.

Format Classification and Fun Facts then Create Record

  • Nodes: Prepare AI Response Data, Create AI Response Record, Create AI Classification Record Log

  • Purpose: The classification result and fun facts are combined into a structured object and stored as a record. This ensures that the information is easily accessible for further use.

Code Example: Prepare AI Response Data Function

codelet body = {
    dogImage: msg.responseUrl,
    dogBreed: msg.breedClassification.labelName,
    funFacts: msg.funFacts.choices[0].message.content
};
msg.payload = body;
return msg;

Explanation: This function formats the classification and fun facts into a single object, which is then saved as a record. The object includes the image URL, the breed name, and the fun facts.

Error Handling

  • Nodes: catch, Error Catch Log, contextual-error

  • Purpose: Captures any errors during the flow, logs them for troubleshooting, and ensures that issues can be promptly addressed.

Flow End

  • Nodes: contextual-end

  • Purpose: Completes the flow after the records have been created or any errors have been logged.

Summary of Flow

  • Flow Start: Begin the flow with an image URL for dog breed classification.

  • Data Preparation: Convert the image URL to a binary buffer for API interaction.

  • API Interaction: Send the image to Nyckel for classification and then send the classification to OpenAI for fun facts.

  • Record Creation: Format and store the classification and fun facts as records.

  • Error Handling: Capture and log any errors that occur during the process.

  • Flow End: Conclude the flow after records are created or errors are logged.

This help article provides a comprehensive guide to using the Nyckel Dog Breed Image Classification Flow, detailing the flow's functionality and providing code examples for each major step.

Sign up for Nyckel
Page cover image