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

Was this helpful?

  1. Services Catalog
  2. All Intro Patterns

OpenAI Sync

OpenAI Sync Flow

The OpenAI Sync Service Flow is a robust solution for synchronizing your data with OpenAI vector stores and managing assistant data seamlessly. Perfect for applications requiring constant updates and well-organized, accessible information, this flow automates the entire sync process, covering event-based triggers, file operations, assistant management, and cache updates. By providing structured data handling and flexible event management, this flow ensures that your AI applications have consistent, real-time access to current data and assistants, enhancing retrieval and response capabilities for end users.

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

  • Data Warehouse, Workflow Management, Enrichment

What's Included:

  • 1 Flow

  • 1 Connection

  • 1 Agent

  • 5 Object Types

What You’ll Need:

  • OpenAI API Key

Ideas for Using the OpenAI Sync Service Flow:

  • Automated Data Consistency: Keep vector stores and assistants synchronized with your local data in real time, ideal for applications needing up-to-date data and conversational context.

  • Intelligent Data Routing: Automate the handling of add, update, and delete operations for both vector store entries and assistant data, triggered by live events or scheduled updates.

  • Enhanced AI Retrieval & Assistant Responses: Organize data within vector stores and keep assistant data current, supporting efficient, context-aware responses that improve user experience in AI-driven applications.


Flow Overview

Flow Start

The flow initiates with a configurable test or external trigger, beginning the sync process with defined settings for data and assistants. This ensures that sync operations are controlled and activated only when required, providing on-demand or scheduled updates.

Code Example: Event Initialization

// Initialize sync event with data type
msg.payload = {
    eventType: "add",  // or "update", "delete"
    dataType: "vectorStore"  // or "assistant"
};
return msg;

Explanation: Initializes the sync event for either vector store data or assistant data, setting the flow to handle specified operations.


Sync Settings Application

The flow configures itself based on specific sync settings, ensuring all data updates and assistant operations align with your current configurations. This step ensures that both vector store and assistant sync processes follow optimal parameters.

Code Example: Set Sync Configuration

// Apply sync settings for vector store and assistants
msg.syncConfig = {
    retryCount: 3,
    updateFrequency: "daily",
    cacheRefresh: true
};
return msg;

Explanation: Sets retry counts, update intervals, and cache settings for both data and assistants to optimize sync performance.


Event-Based Data & Assistant Management

The flow dynamically manages events based on type—such as add, update, or delete—for vector store data and assistant configurations. This flexible handling ensures both types of resources stay current without manual updates.

Code Example: Event Type Router

// Route event based on data and type
if (msg.eventType === "add" && msg.dataType === "vectorStore") {
    return [msg, null, null];
} else if (msg.eventType === "update" && msg.dataType === "assistant") {
    return [null, msg, null];
} else if (msg.eventType === "delete" && msg.dataType === "vectorStore") {
    return [null, null, msg];
}

Explanation: Routes each event type to a designated process, adapting to both vector store and assistant updates.


File Operations for Vector Stores and Assistant Data

The flow supports the creation, updating, and deletion of files for vector stores and assistant configurations, ensuring both types of data are properly managed with OpenAI’s API.

Code Example: Build File Request for Vector Store

// Build payload for vector store file operation
msg.payload = {
    content: msg.fileData,
    purpose: "vector-store-sync"
};
return msg;

Explanation: Constructs the payload for vector store file operations, specifying data and purpose.

Assistant Configuration Example

// Set up assistant configuration payload
msg.payload = {
    assistantId: msg.assistantData.id,
    configuration: msg.assistantData.config
};
return msg;

Explanation: Prepares assistant data for update, including configuration specifics to keep assistants in sync with current data requirements.


Data and Assistant Sync Verification

After each sync operation, the flow verifies success and records it in a summary log, capturing all relevant details of both data and assistant syncs for streamlined management and traceability.

Code Example: Sync Confirmation Log

// Log sync success with operation details
msg.payload = {
    status: "success",
    dataType: msg.dataType,
    operation: msg.eventType,
    timestamp: new Date().toISOString()
};
return msg;

Explanation: Logs successful syncs for both vector store and assistant data, providing a clear history of sync activities.


Flow Completion

The flow concludes with a final log summarizing all completed operations, ensuring continuity in data management and assistant configuration updates across applications.


Detailed Flow Structure

  • Event Trigger Initialization

    • Nodes: contextual-start

    • Purpose: Initiates sync based on incoming events, supporting vector store and assistant data.

  • Apply Sync Settings

    • Nodes: Sync Configuration

    • Purpose: Configures flow behavior, ensuring optimal sync parameters for vector store and assistant updates.

  • Data & Assistant Management

    • Nodes: Add, Update, Delete Handlers

    • Purpose: Routes events for both vector store and assistant configurations, ensuring dynamic data and assistant updates.

  • File & Assistant Config Handling

    • Nodes: Create File, Update Assistant Config

    • Purpose: Manages data and assistant configurations, using structured operations to maintain consistency.

  • Sync Verification & Logging

    • Nodes: Confirmation Log

    • Purpose: Logs successful syncs of vector store entries and assistant configurations.

  • Flow Completion

    • Nodes: contextual-end

    • Purpose: Finalizes the flow with a summary log of all data and assistant sync activities.


Summary of Flow

  • Flow Start: Start with a test or external trigger.

  • Sync Settings: Configure settings for both vector store and assistant updates.

  • Event Handling: Route data and assistant changes based on event type.

  • File Operations & Assistant Updates: Perform file or configuration updates for vector stores and assistants.

  • Sync Verification: Confirm successful syncs and log results.

  • Flow Completion: End with a detailed log for ongoing traceability.

The OpenAI Sync Service Flow is a powerful, automated solution for managing both vector store data and assistant configurations, delivering consistent, up-to-date data and enhanced AI-driven performance across applications.

PreviousOpenAI Assistants Prompt and ResponseNextAll Prebuilt Solutions

Last updated 6 months ago

Was this helpful?

Page cover image