Page cover image

DeepSeek Chat Prompt and Response

The DeepSeek Chat Prompt Example Flow demonstrates how to interact with the DeepSeek API to send prompts and retrieve AI-generated chat responses. This flow showcases a complete process, from sending user-defined prompts to receiving, formatting, and storing responses for further use or integration. It includes robust error handling and testing capabilities, making it an ideal solution for incorporating AI-driven chat functionality into various applications.

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

  • AI, Contextual Basics


What's Included:

  • 1 Flow: Pre-configured for prompt-response interactions with DeepSeek.

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

  • 1 Connection Template: For integrating with the DeepSeek API.


What You'll Need:

  • Access to the DeepSeek API.

  • API Key or credentials for authentication.

  • Sample prompts or use cases for testing.


Ideas for Using the DeepSeek Chat Prompt Flow:

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

  2. Content Generation: Create engaging content by generating responses to tailored prompts.

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

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


Flow Overview

Flow Start

  • Node: contextual-start

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

In-Editor Testing

  • Nodes: Test Prompt, Prepare Prompt

  • Purpose: Enables in-editor testing with a sample prompt. Modify the sample prompt directly to explore different interactions with the DeepSeek API.

Code Example: Prepare Prompt Function

msg.payload = {
    model: "deepseek-chat",
    messages: [
        { role: "system", content: "You are a helpful assistant" },
        { role: "user", content: msg.payload.prompt }
    ],
    max_tokens: 4096
};
return msg;

Send Prompt and Receive Response

  • Nodes: Prompt DeepSeek Chat, DeepSeek Chat Response

  • Purpose: Sends the prepared payload to the DeepSeek 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, including the original prompt and 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 to ensure efficient debugging and troubleshooting.

Flow End

  • Node: contextual-end

  • Purpose: Successfully concludes the process after records are 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 receive the response.

  4. Record Creation: Structure and store the response.

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

  6. Completion: Conclude the flow after creating records or logging errors.


Key Features

  • Flexibility: Can be easily adapted to various use cases.

  • Scalability: Integrates seamlessly into broader workflows.

  • Customization: Modify prompts, response handling, and storage to suit specific requirements.

This flow is a robust starting point for leveraging AI-powered chat functionality within your workflows, providing clear examples and extensibility for diverse applications.

Last updated

Was this helpful?