FlowiseAI
Español
Español
  • Introduction
  • Partes
    • Parte 1: Introducción
      • Recursos
    • Parte 2: Chains Avanzadas
      • Desafío 1: Traductor de Lenguas Antiguas
    • Parte 3: Gestión de Documentos y Memoria
      • Desafío 2: Chatbot Nikola Tesla
    • Parte 4: Despliegue y API
    • Parte 5: Introducción a Agentes
      • Desafíos
    • Parte 6: Agentes Avanzados
      • Desafíos
    • Parte 7: Multi-Agentes
      • Desafíos
    • Parte 8: AgentFlows
      • Desafíos
    • Parte 9: Agentes Secuenciales
      • Desafíos
    • Parte 10: Sequential Agents Avanzados
  • Recursos
    • Enlaces Útiles
    • Documentación Oficial
    • Ejemplos de Código
    • Mejores Prácticas
  • Documentación Oficial
    • Introduction
    • Primeros Pasos
    • Guía de Contribución
      • Building Node
    • Referencia de API
      • Assistants
      • Attachments
      • Chat Message
      • Chatflows
      • Document Store
      • Feedback
      • Leads
      • Ping
      • Prediction
      • Tools
      • Upsert History
      • Variables
      • Vector Upsert
    • Usar Flowise
      • Agentflows
        • Multi-Agents
        • Sequential Agents
          • Tutoriales en Video
      • API
      • Analytic
      • Almacenes de Documentos
      • Embed
      • Monitoring
      • Streaming
      • Telemetry
      • Subidas
      • Variables
      • Workspaces
      • Evaluaciones
    • Configuración
      • Auth
        • Nivel de App
        • Nivel de Chatflow
      • Databases
      • Deployment
        • AWS
        • Azure
        • Alibaba Cloud
        • Digital Ocean
        • Elestio
        • GCP
        • Hugging Face
        • Kubernetes using Helm
        • Railway
        • Render
        • Replit
        • RepoCloud
        • Sealos
        • Zeabur
      • Variables de Entorno
      • Rate Limit
      • Ejecutar Flowise detrás de proxy corporativo
      • SSO
    • Integraciones
      • LangChain
        • Agents
          • Airtable Agent
          • AutoGPT
          • BabyAGI
          • CSV Agent
          • Conversational Agent
          • Conversational Retrieval Agent
          • MistralAI Tool Agent
          • OpenAI Assistant
            • Threads
          • OpenAI Function Agent
          • OpenAI Tool Agent
          • 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
          • NVIDIA NIM
          • ChatAnthropic
          • ChatCohere
          • Chat Fireworks
          • ChatGoogleGenerativeAI
          • Google VertexAI
          • ChatHuggingFace
          • ChatLocalAI
          • ChatMistralAI
          • IBM Watsonx
          • ChatOllama
          • ChatOpenAI
          • ChatTogetherAI
          • GroqChat
        • Document Loaders
          • API Loader
          • Airtable
          • Apify Website Content Crawler
          • Cheerio Web Scraper
          • Confluence
          • Csv File
          • Custom Document Loader
          • Document Store
          • Docx File
          • File Loader
          • 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
          • 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 VertexAI Embeddings
          • HuggingFace Inference Embeddings
          • LocalAI Embeddings
          • MistralAI Embeddings
          • Ollama Embeddings
          • OpenAI Embeddings
          • OpenAI Embeddings Custom
          • TogetherAI Embedding
          • VoyageAI Embeddings
        • LLMs
          • AWS Bedrock
          • Azure OpenAI
          • Cohere
          • 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
          • Zep 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
          • Custom Retriever
          • 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
          • Code Interpreter by E2B
          • 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
      • LiteLLM Proxy
      • 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
      • Utilities
        • Custom JS Function
        • Set/Get Variable
        • If Else
        • Sticky Note
      • External Integrations
        • Zapier Zaps
    • Migration Guide
      • v1.3.0 Migration Guide
      • v1.4.3 Migration Guide
      • v2.1.4 Migration Guide
    • Use Cases
      • Calling Children Flows
      • Calling Webhook
      • Interacting with API
      • Multiple Documents QnA
      • SQL QnA
      • Upserting Data
      • Web Scrape QnA
  • Flowise
    • Flowise GitHub
    • Flowise Cloud
Powered by GitBook
On this page
  • OpenAPI Chain
  • Tool Agent + OpenAPI Toolkit
  • Conclusión
Edit on GitHub
  1. Documentación Oficial
  2. Use Cases

Interacting with API

Aprende a usar integraciones de API externas con Flowise

PreviousCalling WebhookNextMultiple Documents QnA

Last updated 3 months ago


La OpenAPI Specification (OAS) define una interfaz estándar e independiente del lenguaje para APIs HTTP. El objetivo de este caso de uso es que el LLM determine automáticamente qué API llamar, mientras mantiene una conversación con estado con el usuario.

OpenAPI Chain

  1. En este tutorial, vamos a usar

{
  "openapi": "3.0.1",
  "info": {
    "version": "v0",
    "title": "Open AI Klarna product Api"
  },
  "servers": [
    {
      "url": "https://www.klarna.com/us/shopping"
    }
  ],
  "tags": [
    {
      "name": "open-ai-product-endpoint",
      "description": "Open AI Product Endpoint. Query for products."
    }
  ],
  "paths": {
    "/public/openai/v0/products": {
      "get": {
        "tags": [
          "open-ai-product-endpoint"
        ],
        "summary": "API for fetching Klarna product information",
        "operationId": "productsUsingGET",
        "parameters": [
          {
            "name": "countryCode",
            "in": "query",
            "description": "ISO 3166 country code with 2 characters based on the user location. Currently, only US, GB, DE, SE and DK are supported.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "A precise query that matches one very small category or product that needs to be searched for to find the products the user is looking for. If the user explicitly stated what they want, use that as a query. The query is as specific as possible to the product name or category mentioned by the user in its singular form, and don't contain any clarifiers like latest, newest, cheapest, budget, premium, expensive or similar. The query is always taken from the latest topic, if there is a new topic a new query is started. If the user speaks another language than English, translate their request into English (example: translate fia med knuff to ludo board game)!",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "size",
            "in": "query",
            "description": "number of products returned",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "min_price",
            "in": "query",
            "description": "(Optional) Minimum price in local currency for the product searched for. Either explicitly stated by the user or implicitly inferred from a combination of the user's request and the kind of product searched for.",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "max_price",
            "in": "query",
            "description": "(Optional) Maximum price in local currency for the product searched for. Either explicitly stated by the user or implicitly inferred from a combination of the user's request and the kind of product searched for.",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Products found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductResponse"
                }
              }
            }
          },
          "503": {
            "description": "one or more services are unavailable"
          }
        },
        "deprecated": false
      }
    }
  },
  "components": {
    "schemas": {
      "Product": {
        "type": "object",
        "properties": {
          "attributes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "name": {
            "type": "string"
          },
          "price": {
            "type": "string"
          },
          "url": {
            "type": "string"
          }
        },
        "title": "Product"
      },
      "ProductResponse": {
        "type": "object",
        "properties": {
          "products": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Product"
            }
          }
        },
        "title": "ProductResponse"
      }
    }
  }
}
  1. Sin embargo, si quieres tener una conversación normal, no podrá hacerlo. Verás el siguiente error. Esto es porque OpenAPI Chain tiene el siguiente prompt:

Use the provided API's to respond to this user query

Como lo "forzamos" a siempre encontrar la API para responder la consulta del usuario, en los casos de conversación normal que no son relevantes para la OpenAPI, falla al hacerlo.

Usar este método podría no funcionar bien si tienes una especificación OpenAPI grande. Esto es porque estamos incluyendo todas las especificaciones como parte del mensaje enviado al LLM. Luego dependemos del LLM para determinar la URL correcta, los parámetros de consulta, el cuerpo de la solicitud y otros parámetros necesarios para responder la consulta del usuario. Como puedes imaginar, si tus especificaciones OpenAPI son complicadas, hay una mayor probabilidad de que el LLM alucine.

Tool Agent + OpenAPI Toolkit

  1. Conecta ToolAgent con OpenAPI Toolkit. Aquí, subimos la especificación YAML para la API de OpenAI. El archivo de especificaciones se puede encontrar al final de la página.

  1. ¡Vamos a probarlo!

Como puedes notar en el chat, el agent es capaz de mantener una conversación normal y usar la tool apropiada para responder la consulta del usuario. Si estás usando Analytic Tool, puedes ver la lista de tools que convertimos del archivo YAML:

Conclusión

Hemos creado exitosamente un agent que puede interactuar con API cuando es necesario y aún así poder manejar conversaciones con estado con los usuarios. A continuación se encuentran las plantillas utilizadas en esta sección:

Puedes usar un y guardarlo como archivo .yaml, y subirlo a OpenAPI Chain, luego probar haciendo algunas preguntas. OpenAPI Chain enviará todas las especificaciones al LLM, y hará que el LLM use automáticamente el método y los parámetros correctos para la llamada a la API.

Para resolver el error anterior, podemos usar un Agent. Según el cookbook oficial de OpenAI: , se recomienda convertir cada API en una tool por sí misma, en lugar de alimentar todas las APIs al LLM como un solo mensaje. Un agent también es capaz de tener una interacción similar a la humana, con la capacidad de decidir qué tool usar dependiendo de la consulta del usuario.

OpenAPI Toolkit convertirá cada una de las APIs del archivo YAML en un conjunto de tools. De esta manera, los usuarios no tienen que crear una para cada API.

Klarna OpenAPI
conversor de JSON a YAML
Function calling with an OpenAPI specification
Custom Tool
27KB
OpenAPI Chatflow.json
18KB
OpenAPI Toolkit with ToolAgent Chatflow.json
105KB
openai_openapi.yaml