This microservice is built using Python with FastAPI and communicates with external services like agent-config and AI providers to handle user queries. It utilizes the LangChain library to interact with the AI models and generate appropriate responses based on the agent configuration.
- Construir la imagen:
docker build -t conversational-agent .- Ejecutar el contenedor:
docker run -p 8000:8000 conversational-agentLa API estará disponible en http://localhost:8000
- Clone this repository.
- Install the necessary dependencies using pip:
pip install -r requirements.txt- Run the FastAPI application:
uvicorn app:app --reload- The service will be running on
http://localhost:8000.
Puedes encontrar todos los endpoints y ejemplos en nuestra colección de Postman: Colección Postman
Una vez que el servidor esté corriendo, puedes acceder a la documentación Swagger en:
http://localhost:8000/docs
- Handles User Queries: The microservice receives a query from a user and processes it by calling the external
agent-configservice to retrieve the configuration of the agent. - Agent Configuration: The microservice integrates with an external service (
agent-config) to fetch the agent configuration based on the query context. - AI Interaction: Once the agent configuration is retrieved, it uses LangChain to communicate with AI models and provides responses to user queries.
- Handles Multiple Agent Types: The service supports different types of agents, which can be configured according to the query context.
This endpoint is used to send a user query to the conversational agent and get a response based on the agent configuration.
{
"query": "string",
"agent_id": "string (optional)",
"parameter_prompt": "object (optional)",
"conversation_id": "string (optional)",
"metadata_filter": "object (optional)"
}- Query: "hola que vendes"
curl --location 'http://localhost:8000/api/ms/conversational-engine/handle-message' --header 'Content-Type: application/json' --data-raw '{
"query": "hola que vendes",
"agent_id": "mi_primer_agente_base_seller_chat",
"parameter_prompt": {
"detail": {
"store_name": "Tienda MundoTech",
"store_phone": "+1-800-555-1234",
"store_email": "contacto@mundotech.com",
"store_website": "https://www.mundotech.com",
"store_address": "Av. Principal 123, Ciudad Tecno, País Tech",
"store_hours": {
"monday_to_friday": "9:00 AM - 8:00 PM",
"saturday": "10:00 AM - 6:00 PM",
"sunday": "Cerrado"
},
"products": [
{
"category": "Electrónicos",
"items": ["Laptops", "Tablets", "Smartphones", "Smartwatches", "Auriculares Bluetooth"]
},
{
"category": "Accesorios de Computación",
"items": ["Teclados mecánicos", "Ratones inalámbricos", "Monitores 4K", "Cables HDMI", "Bases de refrigeración"]
},
{
"category": "Hogar Inteligente",
"items": ["Asistentes de voz", "Cámaras de seguridad", "Enchufes inteligentes", "Luces LED inteligentes", "Termostatos inteligentes"]
}
],
"promotions": [
"10% de descuento en laptops seleccionadas",
"2x1 en auriculares Bluetooth",
"Envío gratis en compras mayores a $100"
],
"return_policy": "Aceptamos devoluciones dentro de los 30 días posteriores a la compra con recibo original. Los productos deben estar en condiciones originales.",
"customer_service_hours": "Lunes a viernes de 9:00 AM a 6:00 PM",
"social_media": {
"facebook": "https://facebook.com/mundotech",
"instagram": "https://instagram.com/mundotech",
"twitter": "https://twitter.com/mundotech"
}
}
},
"conversation_id": "",
"metadata_filter": null
}'- Query: "ayudame con info para zapatos super start"
curl --location 'http://localhost:8000/api/ms/conversational-engine/handle-message' --header 'Content-Type: application/json' --data '{
"query": "ayudame con info para zapatos super start",
"agent_id": "mi_primer_agente_info",
"parameter_prompt": null,
"conversation_id": "",
"metadata_filter": null
}'- Query: "quiero cambiar 2000mxn a usd"
curl --location 'http://localhost:8000/api/ms/conversational-engine/handle-message' --header 'Content-Type: application/json' --data '{
"query": "quiero cambiar 2000mxn a usd",
"agent_id": null,
"parameter_prompt": null,
"conversation_id": "",
"metadata_filter": null
}'- Query: "cual es el precio de las supertart dolares en mxn son 200000"
curl --location 'http://localhost:8000/api/ms/conversational-engine/handle-message' --header 'Content-Type: application/json' --data '{
"query": "cual es el precio de las supertart dolares en mxn son 200000",
"agent_id": "mi_primer_agente_deporte",
"parameter_prompt": null,
"conversation_id": "",
"metadata_filter": null
}'- Agent Config Service: The
agent-configmicroservice is responsible for retrieving the configuration of the agent based on the query type. This information is used to customize the response generation. - AI Providers: The service utilizes LangChain to interact with various AI models and generate answers to user queries based on the agent configuration.
- FastAPI
- LangChain
- Uvicorn
- Requests
- JSON
This project is licensed under the MIT License - see the LICENSE file for details.