Unlock the Power of AI with 4D AIKit: Automate, Create, and Innovate

We’re excited to introduce 4D AIKit, the first in a series of AI-powered features designed to bring intelligent capabilities directly into your 4D projects. As a built-in component, AIKit enables seamless integration of OpenAI’s state-of-the-art models into your development environment reinforcing our commitment to putting AI at the heart of innovation in 4D.

With just a few lines of code, you can enrich your applications with intelligent features like image generation, content moderation, advanced visual analysis, and conversational chatbots. This is just the beginning! The possibilities are wide open, enabling you to create smarter, more dynamic, and more responsive solutions than ever before.

Showcase: Automate Image Tagging and Searching

Imagine uploading an image and having it automatically analyzed and tagged with relevant keywords, ready to be searched or categorized. With the 4D AIKit component, this is just one of many groundbreaking AI features at your fingertips.

Example: Automatically Tagging and Organizing Images

var $client := cs.AIKit.OpenAI.new("YourApiKey") 
$getKeywords:=cs.getKeywords.new()
$prompt:="Generate between 10 and 20 relevant keywords about this picture.\
The keywords must be separated by a single space with no other text."
var $result:=$client.chat.vision.create($imageUrl).prompt($prompt).choice.message.content
// Process the keywords and save them to the database for fast and accurate image search
$getKeywords.GetKeywordsFromContent($result)

With just a few lines of code, your application can automatically tag and organize images, showcasing the seamless integration of AI into your projects.

DEMO_AIKIT_IMAGETAG

Note : To run this demo, you’ll need an OpenAI API key. You can create one from your OpenAI account https://platform.openai.com/account/api-keys.

Recommendations for using your API key:

  • Keep your key private and never expose it in client-side code or public repositories.
  • Monitor your usage regularly in your OpenAI dashboard to avoid unexpected charges.
  • Set usage limits or quotas if you’re integrating this into a production environment.
  • If your key is ever compromised, revoke it immediately and generate a new one.

What Can You Do with the 4D AIKit Component?

The 4D AIKit component is built directly into 4D, providing seamless access to OpenAI’s powerful AI models, each offering unique possibilities to enhance your applications with intelligent, next-generation features.

Here’s a closer look at what you can build:

1. Text Generation and Chat: Build Conversational Interfaces

OpenAI’s language models excel at understanding context and generating human-like responses.

Examples of What You Can Build:
– Chatbots for Customer Support: Automate responses to FAQs and improve user engagement.
– Content Drafting Tools: Help users write emails, articles, or reports.
– Language Translation and Summarization: Quickly translate documents or condense lengthy texts.

Example: FAQ Bot for E-Commerce

var $client := cs.AIKit.OpenAI.new("YourApiKey") 
var $faqBot := $client.chat.create("You are an AI assistant specialized in answering e-commerce customer questions.") 
var $question := "What is your return policy?" 
var $response := $faqBot.prompt($question) 
ALERT("FAQ Bot Response: " + $response) 

2. Vision Analysis: Automate Image Recognition

Use AI to “see” and interpret images.

Examples of What You Can Build:
– Automatic Image Tagging: Analyze uploaded photos and generate descriptive keywords.
– Visual Inspection Systems: Detect defects in manufacturing or monitor products in warehouses.
– Accessibility Tools: Generate image descriptions for visually impaired users.

Example: Categorizing a Photo Library

var $client := cs.AIKit.OpenAI.new("YourApiKey") 
$userPrompt:= "Describe the objects and context of this image in English.")
var $result:=$client.chat.vision.create($imageUrl).prompt($userPrompt).choice.message.content
ALERT("Tags: " + $result)

3. Image Generation: Create Unique Visual

Design visuals from scratch using simple text prompts.

Examples of What You Can Build:
– Creative Design Tools: Generate placeholders, concept art, or graphic assets.
– Marketing Content: Quickly produce engaging visuals for campaigns.
– Game Development: Create character concepts or environments on the fly.

Example: Dynamic Visual Content for Blog Posts

var $client := cs.AIKit.OpenAI.new("YourApiKey") 
$userPrompt := "A cozy coffee shop with modern decor and warm lighting."
var $images:=$client.images.generate($userPrompt; {size: "1024x1024"}).image.url
ALERT("Image URL: " + $image)

4. Text Moderation: Ensure Safe User Interactions

Monitor and moderate content to ensure safer environments.

Examples of What You Can Build:
– Community Moderation: Automatically flag offensive or rule-breaking posts.
– Content Review Tools: Ensure comments, reviews, or uploads meet your platform’s standards.
– Real-Time Chat Monitoring: Warn users about inappropriate language during live interactions.

Example: Flagging Inappropriate Comments

var $client := cs.AIKit.OpenAI.new("YourApiKey") 
var $moderation:=$client.moderations.create("This text contains inappropriate language and offensive behavior.").moderation

5. Advanced Workflows Combining Multiple Models

Combine text and vision models for more complex solutions:

Examples of What You Can Build:
– AI-Powered Research Assistants: Summarize research papers and analyze charts.
– Social Media Management Tools: Generate captions for images, moderate comments, and suggest hashtags.
– E-Learning Platforms: Create lesson materials, including text and illustrative visuals.

Example: AI-Driven Social Media Automation

var $client := cs.AIKit.OpenAI.new("YourApiKey") 
// Generate an image based on the user’s description in one click
var $image:=$client.images.generate($imageDescription; {size: "1024x1024"}).image.url

// Generate relevant tags automatically for the generated image
 $tagPrompt:="Generate between 10 and 20 relevant keywords about this picture"+\
" The keywords must be separated by a single space with no other text."
var $result:=$client.chat.vision.create($imageUrl).prompt( $tagPrompt).choice.message.content
// Save the tags to the database for easy search and fast sharing
$getKeywords.GetKeywordsFromContent($result)

Multi-provider support

While AIKit is designed with OpenAI in mind, it also supports a wide range of other AI providers offering OpenAI-compatible APIs. This gives you flexibility to choose the provider that best suits your needs whether for performance, privacy, cost, or specific capabilities.

Why Use the 4D AIKit Component?

Whether you’re developing applications for creative professionals, automating repetitive tasks, or leveraging data analysis, the 4D AIKit component provides the tools you need to turn your ideas into powerful features.

Check out the detailed documentation to explore the feature-rich component, which includes 30 classes.

This is just the beginning! upcoming blog posts will introduce new, business-oriented use cases designed to inspire you and help you enhance your applications with AI-driven capabilities.

We’ll continue to share ideas, examples, and tutorials to support your innovation journey.

Feel free to share your feedback or use cases, we’d be happy to feature your projects in future posts.

 

David Azancot
• 4D for iOS Product Owner •David Azancot joined the 4D Product team as a Product Owner in 2017. He's in charge of writing the user stories and translating them into functional specifications. His role also includes making sure that feature implementations meet customers' needs.David graduated with an MBA in Marketing, Internet and Mobility from the Leonard De Vinci Institute and began his career in 2011 with a mobile start-up company, later acquired by Madvertise (a mobile marketing group). Passionate about mobile interfaces, he was the natural choice to develop interactive mobile ad formats for the group in 2015. In parallel, David has been developing his own iOS and Android applications since 2012.