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

Qwen Chat Prompt and Response

The Qwen Chat Prompt Example Flow demonstrates how to interact with the Qwen Chat API to send prompts and retrieve AI-generated responses. This flow covers the entire process from sending user-defined prompts to receiving, formatting, and storing the responses as structured records. It includes robust error handling and testing capabilities, making it an ideal starting point for integrating AI-driven chat functionality into your applications.

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

  • AI, Contextual Basics


What's Included:

  1. 1 Flow: Pre-configured for prompt-response interactions with Qwen Chat.

  2. 1 Object Type: To store structured prompt-response records.

  3. 1 Connection Template: For integrating with the Qwen Chat API.


What You'll Need:

  • Access to the Qwen Chat API.

  • API Key or credentials for authentication.

  • Sample prompts or use cases for testing.


Ideas for Using the Qwen Chat Prompt Flow:

  1. Conversational AI: Automate chat-based interactions for virtual assistants or customer support bots.

  2. Content Creation: Generate creative content or responses based on tailored prompts.

  3. Decision Support: Process complex queries to retrieve insights for decision-making.

  4. Education: Leverage AI-generated explanations for teaching or self-learning purposes.


Flow Overview

Flow Start

  • Node: contextual-start

  • Purpose: Triggers the flow, initiated by an external event, agent, or the Inject node for testing.


In-Editor Testing

  • Nodes: Test Prompt, Prepare Prompt

  • Purpose: Enables in-editor testing with a sample prompt. Modify the provided sample prompt, such as "How many 'r's are in Strawberry?" to explore different interactions with the Qwen Chat API.

Code Example: Prepare Prompt Function

msg.payload = {
    model: "qwen-max-2025-01-25", // Specify model here
    messages: [
        { role: "system", content: "You are a helpful assistant." },
        { role: "user", content: msg.payload.prompt }
    ]
};
return msg;

Send Prompt and Receive Response

  • Nodes: Prompt Qwen Chat, Qwen Chat Response

  • Purpose: Sends the prepared payload to the Qwen Chat API. Logs the response for review and passes it for further processing.

Code Example: Response Logging

msg.payload.response = {
    aiResponse: msg.payload.response.choices[0].message.content
};
return msg;

Format Response & Create Record

  • Nodes: Prepare Record Data, Create AI Response Record

  • Purpose: Formats the API response and creates a structured record containing the original prompt and the AI-generated response.

Code Example: Prepare Record Data

let body = {
    prompt: msg.payload.messages[1].content,
    aiResponse: msg.payload.response.choices[0].message.content
};
msg.payload = body;
return msg;

Error Handling

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

  • Purpose: Captures and logs any errors during the flow execution, ensuring efficient debugging and troubleshooting.


Flow End

  • Node: contextual-end

  • Purpose: Concludes the flow after records are successfully created or errors are logged.


Summary of Flow Steps:

  1. Start: Trigger the flow manually or externally.

  2. Data Preparation: Format the prompt for API interaction.

  3. API Interaction: Submit the prompt and process the AI response.

  4. Record Creation: Structure and store the prompt-response data.

  5. Error Handling: Log and manage any issues that arise.

  6. Completion: Conclude the flow.


Key Features:

  • Flexibility: Easily adaptable to various use cases.

  • Scalability: Integrates seamlessly into broader workflows.

  • Customization: Modify prompts, response handling, and storage as needed.

This flow serves as a robust template for leveraging AI-powered chat functionality, providing clear examples and extensibility for diverse applications.

PreviousDeepSeek Chat Prompt and ResponseNextPerplexity AI Search and Response

Last updated 3 months ago

Was this helpful?

Page cover image