Tailwinds - The UI for AI
  • Welcome to Tailwinds
    • Chatflows
      • LangChain
        • Agents
          • Airtable Agent
          • AutoGPT
          • BabyAGI
          • CSV Agent
          • Conversational Agent
          • OpenAI Assistant
            • Threads
          • ReAct Agent Chat
          • ReAct Agent LLM
          • Tool Agent
          • XML Agent
        • Cache
          • InMemory Cache
          • InMemory Embedding Cache
          • Momento Cache
          • Redis Cache
          • Redis Embeddings Cache
          • Upstash Redis Cache
        • Chains
          • GET API Chain
          • OpenAPI Chain
          • POST API Chain
          • Conversation Chain
          • Conversational Retrieval QA Chain
          • LLM Chain
          • Multi Prompt Chain
          • Multi Retrieval QA Chain
          • Retrieval QA Chain
          • Sql Database Chain
          • Vectara QA Chain
          • VectorDB QA Chain
        • Chat Models
          • AWS ChatBedrock
          • Azure ChatOpenAI
          • NIBittensorChat
          • ChatAnthropic
          • ChatCohere
          • Chat Fireworks
          • ChatGoogleGenerativeAI
          • ChatGooglePaLM
          • Google VertexAI
          • ChatHuggingFace
          • ChatMistralAI
          • ChatOllama
          • ChatOllama Funtion
          • ChatOpenAI
          • ChatOpenAI Custom
          • ChatTogetherAI
          • GroqChat
        • Document Loaders
          • API Loader
          • Airtable
          • Apify Website Content Crawler
          • Cheerio Web Scraper
          • Confluence
          • Csv File
          • Custom Document Loader
          • Document Store
          • Docx File
          • Figma
          • FireCrawl
          • Folder with Files
          • GitBook
          • Github
          • Json File
          • Json Lines File
          • Notion Database
          • Notion Folder
          • Notion Page
          • PDF Files
          • Plain Text
          • Playwright Web Scraper
          • Puppeteer Web Scraper
          • AWS S3 File Loader
          • SearchApi For Web Search
          • SerpApi For Web Search
          • Spider Web Scraper/Crawler
          • Text File
          • Unstructured File Loader
          • Unstructured Folder Loader
          • VectorStore To Document
        • Embeddings
          • AWS Bedrock Embeddings
          • Azure OpenAI Embeddings
          • Cohere Embeddings
          • Google GenerativeAI Embeddings
          • Google PaLM Embeddings
          • Google VertexAI Embeddings
          • HuggingFace Inference Embeddings
          • MistralAI Embeddings
          • Ollama Embeddings
          • OpenAI Embeddings
          • OpenAI Embeddings Custom
          • TogetherAI Embedding
          • VoyageAI Embeddings
        • LLMs
          • AWS Bedrock
          • Azure OpenAI
          • NIBittensorLLM
          • Cohere
          • GooglePaLM
          • GoogleVertex AI
          • HuggingFace Inference
          • Ollama
          • OpenAI
          • Replicate
        • Memory
          • Buffer Memory
          • Buffer Window Memory
          • Conversation Summary Memory
          • Conversation Summary Buffer Memory
          • DynamoDB Chat Memory
          • MongoDB Atlas Chat Memory
          • Redis-Backed Chat Memory
          • Upstash Redis-Backed Chat Memory
        • Moderation
          • OpenAI Moderation
          • Simple Prompt Moderation
        • Output Parsers
          • CSV Output Parser
          • Custom List Output Parser
          • Structured Output Parser
          • Advanced Structured Output Parser
        • Prompts
          • Chat Prompt Template
          • Few Shot Prompt Template
          • Prompt Template
        • Record Managers
        • Retrievers
          • Cohere Rerank Retriever
          • Embeddings Filter Retriever
          • HyDE Retriever
          • LLM Filter Retriever
          • Multi Query Retriever
          • Prompt Retriever
          • Reciprocal Rank Fusion Retriever
          • Similarity Score Threshold Retriever
          • Vector Store Retriever
          • Voyage AI Rerank Retriever
        • Text Splitters
          • Character Text Splitter
          • Code Text Splitter
          • Html-To-Markdown Text Splitter
          • Markdown Text Splitter
          • Recursive Character Text Splitter
          • Token Text Splitter
        • Tools
          • BraveSearch API
          • Calculator
          • Chain Tool
          • Chatflow Tool
          • Custom Tool
          • Exa Search
          • Google Custom Search
          • OpenAPI Toolkit
          • Python Interpreter
          • Read File
          • Request Get
          • Request Post
          • Retriever Tool
          • SearchApi
          • SearXNG
          • Serp API
          • Serper
          • Web Browser
          • Write File
        • Vector Stores
          • AstraDB
          • Chroma
          • Elastic
          • Faiss
          • In-Memory Vector Store
          • Milvus
          • MongoDB Atlas
          • OpenSearch
          • Pinecone
          • Postgres
          • Qdrant
          • Redis
          • SingleStore
          • Supabase
          • Upstash Vector
          • Vectara
          • Weaviate
          • Zep Collection - Open Source
          • Zep Collection - Cloud
      • LlamaIndex
        • Agents
          • OpenAI Tool Agent
          • Anthropic Tool Agent
        • Chat Models
          • AzureChatOpenAI
          • ChatAnthropic
          • ChatMistral
          • ChatOllama
          • ChatOpenAI
          • ChatTogetherAI
          • ChatGroq
        • Embeddings
          • Azure OpenAI Embeddings
          • OpenAI Embedding
        • Engine
          • Query Engine
          • Simple Chat Engine
          • Context Chat Engine
          • Sub-Question Query Engine
        • Response Synthesizer
          • Refine
          • Compact And Refine
          • Simple Response Builder
          • Tree Summarize
        • Tools
          • Query Engine Tool
        • Vector Stores
          • Pinecone
          • SimpleStore
    • Agentflows
      • Multi-Agents (Supervisor/Worker)
      • Sequential Agents
    • API
      • Chatflows and APIs
    • Document Stores
    • Embed
      • Rate Limit
    • API Streaming
    • Analytics
    • Credentials
      • Amazon Bedrock Credential Setup
      • IBM Watsonx.AI Credential Setup
    • Variables
    • Utilities
      • Custom JS Function
      • Set/Get Variable
      • If Else
      • Sticky Note
    • Example Flows
      • Calling Children Flows
      • Calling Webhook
      • Interacting with API
      • Multiple Documents QnA
      • SQL QnA
      • Upserting Data
      • Web Scrape QnA
    • Monitoring & Auditing
      • Configuring Monitoring and Traces
    • Tailwinds Security and Deployment
  • Release Notes
    • 12/17/2024 - v2.2.1
    • 10/11/2024 - v2.1.2
    • 9/27/2024- v2.1
    • 8/16/2024 - v2.0.5
  • Demos and Use-cases
    • Create a Basic Chatbot
    • Build an AI-Powered Translator
    • Create research-powered call scripts
    • Extract information from Medical Documents
    • Identify ICD10 medical codes
  • GenAI University
    • Syllabus
    • 101-Prompt Engineering
    • 101-System Prompts
    • 101-Human (User) Prompts
    • 101-Context Window
    • 101-Prompt Chains
    • 201-Documents and Vector Databases (RAG)
    • 301-AI Agents
    • 301-Agent Tools
    • 401-Multi-Agent
Powered by GitBook
On this page
  • 1. Prediction API
  • Override Config
  • History
  • Persists Memory
  • Image Uploads
  • Speech to Text
  • Authentication
  • 2. Vector Upsert API
  • Document Loaders with Upload
  • Document Loaders without Upload
  • Authentication
  • 3. Message API
  • Authentication

Was this helpful?

  1. Welcome to Tailwinds

API

Learn how to use the Prediction, Vector Upsert and Message API

PreviousSequential AgentsNextChatflows and APIs

Last updated 9 months ago

Was this helpful?


1. Prediction API

  • POST /api/v1/prediction/{your-chatflowid}

Request Body

Key
Description
Type
Required

question

User's question

string

Yes

overrideConfig

Override existing flow configuration

object

No

history

Prepend history messages at the start of conversation

array

No

You can use the chatflow as API and connect to frontend applications.

Override Config

You also have the flexibility to override input configuration with overrideConfig property.

import requests
API_URL = "http://<yourtenant>.tailwinds.innovativesol.com/api/v1/prediction/&#x3C;chatlfowid>"

def query(payload):
    response = requests.post(API_URL, json=payload)
    return response.json()
    
output = query({
    "question": "Hey, how are you?",
    "overrideConfig": {
        "sessionId": "123",
        "returnSourceDocuments": true
    }
})
async function query(data) {
    const response = await fetch(
        "http://<yourtenant>.tailwinds.innovativesol.com/api/v1/prediction/<chatlfowid>",
        {
            method: "POST",
            headers: {
                "Content-Type": "application/json"
            },
            body: JSON.stringify(data)
        }
    );
    const result = await response.json();
    return result;
}

query({
    "question": "Hey, how are you?",
    "overrideConfig": {
        "sessionId": "123",
        "returnSourceDocuments": true
    }
}).then((response) => {
    console.log(response);
});

History

You can prepend history messages to give some context to LLM. For example, if you want the LLM to remember user's name:

import requests
API_URL = "http://localhost:3000/api/v1/prediction/&#x3C;chatlfowid>"

def query(payload):
    response = requests.post(API_URL, json=payload)
    return response.json()
    
output = query({
    "question": "Hey, how are you?",
    "history": [
        {
            "role": "apiMessage",
            "content": "Hello how can I help?"
        },
        {
            "role": "userMessage",
            "content": "Hi my name is Brian"
        },
        {
            "role": "apiMessage",
            "content": "Hi Brian, how can I help?"
        },
    ]
})
async function query(data) {
    const response = await fetch(
        "http://localhost:3000/api/v1/prediction/<chatlfowid>",
        {
            method: "POST",
            headers: {
                "Content-Type": "application/json"
            },
            body: JSON.stringify(data)
        }
    );
    const result = await response.json();
    return result;
}

query({
    "question": "Hey, how are you?",
    "history": [
        {
            "role": "apiMessage",
            "content": "Hello how can I help?"
        },
        {
            "role": "userMessage",
            "content": "Hi my name is Brian"
        },
        {
            "role": "apiMessage",
            "content": "Hi Brian, how can I help?"
        },
    ]
}).then((response) => {
    console.log(response);
});

Persists Memory

import requests
API_URL = "http://<yourtenant>.tailwinds.innovativesol.com/api/v1/prediction/&#x3C;chatlfowid>"

def query(payload):
    response = requests.post(API_URL, json=payload)
    return response.json()
    
output = query({
    "question": "Hey, how are you?",
    "overrideConfig": {
        "sessionId": "123"
    } 
})
async function query(data) {
    const response = await fetch(
        "http://<yourtenant>.tailwinds.innovativesol.com/api/v1/prediction/<chatlfowid>",
        {
            method: "POST",
            headers: {
                "Content-Type": "application/json"
            },
            body: JSON.stringify(data)
        }
    );
    const result = await response.json();
    return result;
}

query({
    "question": "Hey, how are you?",
    "overrideConfig": {
        "sessionId": "123"
    }
}).then((response) => {
    console.log(response);
});

Image Uploads

When Allow Image Upload is enabled, images can be uploaded from chat interface.

import requests
API_URL = "http://<yourtenant>.tailwinds.innovativesol.com/api/v1/prediction/&#x3C;chatlfowid>"

def query(payload):
    response = requests.post(API_URL, json=payload)
    return response.json()
    
output = query({
    "question": "Can you describe the image?",
    "uploads": [
        {
            "data": 'data:image/png;base64,iVBORw0KGgdM2uN0', # base64 string or url
            "type": 'file', # file | url
            "name": 'image.png',
            "mime": 'image/png'
        }
    ]
})
async function query(data) {
    const response = await fetch(
        "http://<yourtenant>.tailwinds.innovativesol.com/api/v1/prediction/<chatlfowid>",
        {
            method: "POST",
            headers: {
                "Content-Type": "application/json"
            },
            body: JSON.stringify(data)
        }
    );
    const result = await response.json();
    return result;
}

query({
    "question": "Can you describe the image?",
    "uploads": [
        {
            "data": 'data:image/png;base64,iVBORw0KGgdM2uN0', //base64 string or url
            "type": 'file', //file | url
            "name": 'Flowise.png',
            "mime": 'image/png'
        }
    ]
}).then((response) => {
    console.log(response);
});

Speech to Text

When Speech to Text is enabled, users can speak directly into microphone and speech will be transcribed into text.

import requests
API_URL = "http://<yourtenant>.tailwinds.innovativesol.com/api/v1/prediction/&#x3C;chatlfowid>"

def query(payload):
    response = requests.post(API_URL, json=payload)
    return response.json()
    
output = query({
    "uploads": [
        {
            "data": 'data:audio/webm;codecs=opus;base64,GkXf', #base64 string
            "type": 'audio',
            "name": 'audio.wav',
            "mime": 'audio/webm'
        }
    ]
})
async function query(data) {
    const response = await fetch(
        "http://<yourtenant>.tailwinds.innovativesol.com/api/v1/prediction/<chatlfowid>",
        {
            method: "POST",
            headers: {
                "Content-Type": "application/json"
            },
            body: JSON.stringify(data)
        }
    );
    const result = await response.json();
    return result;
}

query({
    "uploads": [
        {
            "data": 'data:audio/webm;codecs=opus;base64,GkXf', //base64 string
            "type": 'audio',
            "name": 'audio.wav',
            "mime": 'audio/webm'
        }
    ]
}).then((response) => {
    console.log(response);
});

Authentication

You can assign an API key to the prediction API from the UI. Refer Chatflows and APIs for more details.

The Authorization header must be provided with the correct API key specified during a HTTP call.

"Authorization": "Bearer <your-api-key>"

2. Vector Upsert API

  • POST /api/v1/vector/upsert/{your-chatflowid}

Request Body

Key
Description
Type
Required

overrideConfig

Override existing flow configuration

object

No

stopNodeId

Node ID of the vector store. When you have multiple vector stores in a flow, you might not want to upsert all of them. Specifying stopNodeId will ensure only that specific vector store node is upserted.

array

No

Document Loaders with Upload

Some document loaders in Tailwinds allow user to upload files:

It is user's responsibility to make sure the file type is compatible with the expected file type from document loader. For example, if a Text File Loader is being used, you should only upload file with .txt extension.

import requests

API_URL = "http://<yourtenant>.tailwinds.innovativesol.com/api/v1/vector/upsert/<chatlfowid>"

# use form data to upload files
form_data = {
    "files": ('state_of_the_union.txt', open('state_of_the_union.txt', 'rb'))
}

body_data = {
    "returnSourceDocuments": True
}

def query(form_data):
    response = requests.post(API_URL, files=form_data, data=body_data)
    print(response)
    return response.json()

output = query(form_data)
print(output)
// use FormData to upload files
let formData = new FormData();
formData.append("files", input.files[0]);
formData.append("returnSourceDocuments", true);

async function query(formData) {
    const response = await fetch(
        "http://localhost:3000/api/v1/vector/upsert/<chatlfowid>",
        {
            method: "POST",
            body: formData
        }
    );
    const result = await response.json();
    return result;
}

query(formData).then((response) => {
    console.log(response);
});

Document Loaders without Upload

import requests

API_URL = "http://<yourtenant>.tailwinds.innovativesol.com/api/v1/vector/upsert/<chatlfowid>"

def query(form_data):
    response = requests.post(API_URL, json=payload)
    print(response)
    return response.json()

output = query({
    "overrideConfig": { # optional
        "returnSourceDocuments": true
    }
})
print(output)
async function query(data) {
    const response = await fetch(
        "http://localhost:3000/api/v1/vector/upsert/<chatlfowid>",
        {
            method: "POST",
            headers: {
                "Content-Type": "application/json"
            },
            body: JSON.stringify(data)
        }
    );
    const result = await response.json();
    return result;
}

query({
    "overrideConfig": { // optional
        "returnSourceDocuments": true
    }
}).then((response) => {
    console.log(response);
});

Authentication

You can assign an API key to the prediction API from the UI. Refer Chatflows and APIs for more details.

The Authorization header must be provided with the correct API key specified during a HTTP call.

"Authorization": "Bearer <your-api-key>"

3. Message API

  • GET /api/v1/chatmessage/{your-chatflowid}

  • DELETE /api/v1/chatmessage/{your-chatflowid}

Query Parameters

Param
Type
Value

sessionId

string

sort

enum

ASC or DESC

startDate

string

endDate

string

Authentication

Message API is restricted to only Tailwinds admin user. Basic authentication must be provided in the headers if Tailwinds instance has been configured with USERNAME and PASSWORD. Refer https://github.com/innovativeSol/tailwinds-docs/blob/main/using-tailwinds/broken-reference/README.md for more details.

"Authorization": "Basic " + Buffer.from(username + ":" + password).toString('base64')
'"Authorization": "Basic " + btoa(username + ":" + password)
import requests

from requests.auth import HTTPBasicAuth
res = requests.get('http://<yourtenant>.tailwinds.innovativesol.com/api/v1/chatmessage/{your-chatflowid}', auth=HTTPBasicAuth(username, password))

If the chatflow contains nodes, you can pass a sessionId to persists the state of the conversation, so the every subsequent API calls will have context about previous conversation. Otherwise, a new session will be generated each time.

If the flow contains with Upload File functionality, the API looks slightly different. Instead of passing body as JSON, form-data is being used. This allows you to upload any files to the API.

For other nodes without Upload File functionality, the API body is in JSON format similar to .

Document Loaders
Document Loaders
Prediction API
Memory