### Text to SQL Node Example Pipeline Source: https://docs.vectorshift.ai/platform/pipelines/logic/text-to-sql This example demonstrates a pipeline using the Text to SQL node. It includes a Text node for the natural language query, the Text to SQL node itself, and an Output node to display the generated SQL query. ```text 1. Text Node: Stores the natural language query * Text: `Summarize the data` 2. Text to SQL Node: Generates the SQL query * SQL Database: MySQL * Natural language query: `{{input_0.text}}` * Schema: `CREATE TABLE Person ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, phone_number VARCHAR(20), email VARCHAR(100) UNIQUE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );` 3. Output Node: Outputs the SQL query * Output: `{{nl_to_sql_0.sql_query}}` ``` -------------------------------- ### Start and Continue Conversation in Python Source: https://docs.vectorshift.ai/platform/interfaces/chatbots/api Demonstrates how to initiate a new conversation by omitting the conversation_id and then continue an existing one by including it in subsequent requests. ```python import requests API_KEY = "your_api_key" CHATBOT_ID = "your_chatbot_id" url = "https://api.vectorshift.ai/api/chatbots/run" headers = { "Content-Type": "application/json", "Api-Key": API_KEY, } # First message (no conversation_id) payload = { "input": "Where is my order #12345?", "chatbot_id": CHATBOT_ID, } response = requests.post(url, json=payload, headers=headers) data = response.json() print(data["output"]) conversation_id = data["conversation_id"] # Follow-up message (with conversation_id) payload = { "input": "Can I change the shipping address?", "chatbot_id": CHATBOT_ID, "conversation_id": conversation_id, } response = requests.post(url, json=payload, headers=headers) data = response.json() print(data["output"]) ``` -------------------------------- ### Sentence Segmentation Example Source: https://docs.vectorshift.ai/platform/pipelines/knowledge/text-chunking Illustrates splitting text into sentences using punctuation and grammatical rules. This method is effective for preserving complete thoughts. ```text Text splitting is useful. It helps AI process information. ``` -------------------------------- ### Paragraph Segmentation Example Source: https://docs.vectorshift.ai/platform/pipelines/knowledge/text-chunking Shows how to segment text into paragraphs, where blocks of text separated by blank lines are treated as individual units. This preserves topic coherence within paragraphs. ```text Text splitting is useful. It helps AI process information. Another key concept is chunk overlap. ``` -------------------------------- ### Start and Continue Conversation in JavaScript Source: https://docs.vectorshift.ai/platform/interfaces/chatbots/api Shows how to start a new conversation without a conversation ID and then continue it by passing the conversation ID from the initial response. ```javascript const API_KEY = "your_api_key"; const CHATBOT_ID = "your_chatbot_id"; const url = "https://api.vectorshift.ai/api/chatbots/run"; // First message (no conversation_id) const firstResponse = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json", "Api-Key": API_KEY, }, body: JSON.stringify({ input: "Where is my order #12345?", chatbot_id: CHATBOT_ID, }), }); const firstData = await firstResponse.json(); console.log(firstData.output); const conversationId = firstData.conversation_id; // Follow-up message (with conversation_id) const followUpResponse = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json", "Api-Key": API_KEY, }, body: JSON.stringify({ input: "Can I change the shipping address?", chatbot_id: CHATBOT_ID, conversation_id: conversationId, }), }); const followUpData = await followUpResponse.json(); console.log(followUpData.output); ``` -------------------------------- ### Create Knowledge Base Source: https://docs.vectorshift.ai/api-reference/knowledge-bases/create Creates a new knowledge base with specified configurations. Authentication is required. ```APIDOC ## POST /knowledge-base ### Description Creates a new knowledge base. ### Method POST ### Endpoint /knowledge-base ### Request Body - **name** (string) - Required - Name of the knowledge base - **description** (string) - Optional - Description of the knowledge base - **file_processing_implementation** (string) - Optional - Specifies the file processing method. Enum: Default, Textract, Unstructured, LlamaParse, Other. - **chunk_size** (integer) - Optional - Size of document chunks. - **chunk_overlap** (integer) - Optional - Overlap between document chunks. - **analyze_documents** (boolean) - Optional - Whether to analyze documents. - **apify_key** (string) - Optional - Apify API key. ### Request Example ```json { "name": "My New Knowledge Base", "description": "This is a test knowledge base.", "file_processing_implementation": "Default", "chunk_size": 1000, "chunk_overlap": 200, "analyze_documents": true, "apify_key": "your-apify-key" } ``` ### Response #### Success Response (200) - **status** (string) - Enum: success, failed - Status of the operation. - **id** (string) - ID of the created knowledge base. #### Response Example ```json { "status": "success", "id": "kb_12345abcde" } ``` #### Error Response (400) - **status** (string) - Enum: failed - Status of the operation. - **error** (string) - Description of the error. #### Error Response Example ```json { "status": "failed", "error": "Invalid input provided." } ``` ``` -------------------------------- ### Cron Trigger Node Example: Send Email Every Minute Source: https://docs.vectorshift.ai/platform/pipelines/start/trigger/cron-trigger This example demonstrates a pipeline that sends an email every minute. It uses a Cron Trigger Node with a cron expression set to '* * * * *' to achieve minute-level scheduling. The pipeline also includes Text, LLM, and Gmail nodes to construct and send the email. ```pipeline 1. Cron Trigger Node: The cron trigger node * Cron Expression: `* * * * *` * Enable Automation: `true` 2. Text Node: Question to answer with the current timestamp * Text: `What is the tallest builiding in NY? {{trigger_0.timestamp}}` 3. LLM Node: Uses the LLM to answer the query and write the email body * System (Instruction): `Write an email answers the question based on Context. Only write the email body, not the subject` * Prompt: `Question: {{text_0.text}}` 4. Gmail Node: Sends the generated email * Action: `Send Email` * To: `sample@vectorshift.ai` * Subject: `{{trigger_0.timestamp}}` * Body: `{{openai_0.response}}` ``` -------------------------------- ### Run Knowledge Base Search (HTTP) Source: https://docs.vectorshift.ai/platform/knowledge/api This is a raw HTTP request example for calling the knowledge base search endpoint. Ensure you replace 'YOUR_API_TOKEN' with your Bearer JWT token and '{id}' with your knowledge base ID. ```http POST /search/{id}/run HTTP/1.1 Host: api.vectorshift.ai Authorization: Bearer YOUR_API_TOKEN Content-Type: application/json { "input_message": "Sample input message here", "conversation_id": "text", "is_deployed": true, "alpha": 0.5 } ``` -------------------------------- ### Configure LLM System Prompt Source: https://docs.vectorshift.ai/quickstart Provide instructions to the LLM on how to respond, such as answering questions based on provided context. ```text Answer the Question based on Context ``` -------------------------------- ### Non-Streaming Chatbot Response Source: https://docs.vectorshift.ai/platform/interfaces/chatbots/api Example of a successful JSON response from the chatbot API when not using streaming. ```json { "status": "success", "output": "Your order #12345 is currently in transit and expected to arrive by Friday.", "conversation_id": "abc123def456" } ``` -------------------------------- ### Configure LLM Prompt with Context Source: https://docs.vectorshift.ai/quickstart Pass the user's question and relevant data from the knowledge base to the LLM. Labeling the data as 'Question' and 'Context' helps the LLM understand its role. ```text Question: {{input_0.text}} Context: {{knowledge_base_0.chunks}} ``` -------------------------------- ### Run Chatbot Source: https://docs.vectorshift.ai/platform/interfaces/chatbots/api Send a message to a chatbot to get a response. Include a `conversation_id` to continue an existing conversation. ```APIDOC ## POST /api/chatbots/run ### Description Sends a message to a specified chatbot and returns a response. If `conversation_id` is provided, the conversation continues from the previous state. If `stream` is set to `true`, the response will be delivered as Server-Sent Events. ### Method POST ### Endpoint /api/chatbots/run ### Request Body - **input** (string) - Required - The user's message to the chatbot. - **chatbot_id** (string) - Required - The ID of the chatbot to interact with. - **conversation_id** (string) - Optional - The ID of the conversation to continue. - **stream** (boolean) - Optional - If true, the response will be streamed as Server-Sent Events. ### Request Example ```json { "input": "Where is my order #12345?", "chatbot_id": "your_chatbot_id", "conversation_id": "abc123def456" } ``` ### Response #### Success Response (200) - **output** (string) - The chatbot's response. - **conversation_id** (string) - The ID of the conversation. #### Response Example ```json { "output": "Your order #12345 is currently in transit and expected to arrive by Friday.", "conversation_id": "abc123def456" } ``` ### Streaming Response Example (Server-Sent Events) ```json {"output": "Your order", "conversation_id": "abc123def456"} {"output": "Your order #12345 is currently", "conversation_id": "abc123def456"} {"output": "Your order #12345 is currently in transit and expected to arrive by Friday.", "conversation_id": "abc123def456"} ``` ``` -------------------------------- ### Word Segmentation Example Source: https://docs.vectorshift.ai/platform/pipelines/knowledge/text-chunking Demonstrates splitting text into individual words. This is a basic method that may lose sentence meaning. ```text Text splitting is useful. ```