Predicción
Predicción
Enviar mensaje al flujo y obtener respuesta de la IA
post /prediction/{id}
Envía un mensaje a tu flujo y recibe una respuesta generada por la IA. Este es el endpoint principal para interactuar con tus flujos y asistentes.
Authentication: Es posible que se requiera una clave API, dependiendo de la configuración del flujo.
- HTTP
- cURL
- JavaScript
- Python
POST /prediction/{id} HTTP/1.1
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 628
{
"question": "What is artificial intelligence?",
"form": {
"title": "Example",
"count": 1
},
"streaming": false,
"overrideConfig": {
"sessionId": "user-session-123",
"temperature": 0.7,
"maxTokens": 500,
"vars": {
"user_name": "Alice"
}
},
"history": [
{
"role": "apiMessage",
"content": "Hello! I'm an AI assistant. How can I help you today?"
},
{
"role": "userMessage",
"content": "Hi, my name is Sarah and I'm learning about AI"
}
],
"uploads": [
{
"type": "file",
"name": "example.png",
"data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAABjElEQVRIS+2Vv0oDQRDG",
"mime": "image/png"
}
],
"humanInput": {
"type": "reject",
"feedback": "Include more emoji"
}
}
curl -L \
--request POST \
--url '/prediction/{id}' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
--header 'Content-Type: application/json' \
--data @- <<'EOF'
{
"question": "What is artificial intelligence?",
"form": {
"title": "Example",
"count": 1
},
"streaming": false,
"overrideConfig": {
"sessionId": "user-session-123",
"temperature": 0.7,
"maxTokens": 500,
"vars": {
"user_name": "Alice"
}
},
"history": [
{
"role": "apiMessage",
"content": "Hello! I'm an AI assistant. How can I help you today?"
},
{
"role": "userMessage",
"content": "Hi, my name is Sarah and I'm learning about AI"
}
],
"uploads": [
{
"type": "file",
"name": "example.png",
"data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAABjElEQVRIS+2Vv0oDQRDG",
"mime": "image/png"
}
],
"humanInput": {
"type": "reject",
"feedback": "Include more emoji"
}
}
const response = await fetch('/prediction/{id}', {
method: 'POST',
headers: {
"Authorization": "Bearer YOUR_SECRET_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"question": "What is artificial intelligence?",
"form": {
"title": "Example",
"count": 1
},
"streaming": false,
"overrideConfig": {
"sessionId": "user-session-123",
"temperature": 0.7,
"maxTokens": 500,
"vars": {
"user_name": "Alice"
}
},
"history": [
{
"role": "apiMessage",
"content": "Hello! I'm an AI assistant. How can I help you today?"
},
{
"role": "userMessage",
"content": "Hi, my name is Sarah and I'm learning about AI"
}
],
"uploads": [
{
"type": "file",
"name": "example.png",
"data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAABjElEQVRIS+2Vv0oDQRDG",
"mime": "image/png"
}
],
"humanInput": {
"type": "reject",
"feedback": "Include more emoji"
}
})
});
const data = await response.json();
import json
import requests
response = requests.post(
"/tools",
headers={"Authorization":"Bearer YOUR_SECRET_TOKEN","Content-Type":"application/json"},
data=json.dumps({
"id": "cfd531e0-82fc-11e9-bc42-526af7764f64",
"name": "date_time_tool",
"description": "A tool used for date and time operations",
"color": "#FF5733",
"iconSrc": "https://example.com/icons/date.png",
"schema": "text",
"func": "text",
"createdDate": "2024-08-24T14:15:22Z",
"updatedDate": "2024-08-24T14:15:22Z"
})
)
data = response.json()