Nyckel Dog Breed Classification
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
Sign up for Nyckel 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
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
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
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
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.
Last updated