CROP
ProjectsPDF Parser

Agent Prompts and Purchasing Consultation

The McHale Parts Co-Pilot agent now has access to multiple data sources and provides purchasing consultations, including: - What to buy - Quantity needed -...

Agent Prompts and Purchasing Consultation

Overview

The McHale Parts Co-Pilot agent now has access to multiple data sources and provides purchasing consultations, including:

  • What to buy
  • Quantity needed
  • Stock availability
  • Current pricing
  • Delivery estimates

Data Sources

1. RAG (Weaviate)

  • Purpose: Semantic search across PDF manuals, schemas, and technical documentation
  • Data: Part descriptions, page numbers, coordinates, schemas, quantities from manuals

2. Elasticsearch (Production VM)

  • Purpose: Structured search by part numbers and metadata
  • Data: Exact matches by part numbers, descriptions, schemas, quantities

3. MongoDB (Cloud)

  • Purpose: Additional part information
  • Data: Category, price, stock levels, specifications, manufacturer

4. Store API (clintontractor.net)

  • Purpose: Real-time availability, stock quantities, pricing, delivery
  • Data:
    • in_stock: Whether item is in stock
    • stock_quantity: Current stock quantity
    • can_purchase: Whether item can be purchased now
    • price: Current price
    • estimated_delivery: Estimated delivery time

Updated Agent Prompts

System Prompt

The agent now has enhanced prompts that include:

  1. Purchasing Consultant Role: Agent acts as a purchasing consultant
  2. Multi-Source Data Access: Uses data from RAG, Elasticsearch, MongoDB, and Store API
  3. Availability Consultation: Provides stock availability information
  4. Quantity Guidance: Advises on quantity based on manuals

Key Prompt Elements:

ROLE & RESPONSIBILITY:
- Purchasing Consultation: Provide expert advice on:
  - What to buy: Based on part number, description, and schemas
  - How many: Based on quantity specified in manuals/documents
  - Availability: Real-time stock status, stock quantities, purchasing ability
  - Pricing: Current price information when available
  - Delivery: Estimated delivery times when available

Data Enrichment Workflow

# User: "Find part 10"

# 1. Elasticsearch search
es_results = elasticsearch_client.search_by_part_number("10")
# Result: part_number, description, page, schemas, quantity (from manual)

# 2. MongoDB enrichment
mongo_data = mongodb_client.get_part_details("10")
# Result: category, price, stock (from database)

# 3. Store API (real-time)
store_data = store_api_client.check_availability("10")
# Result: in_stock, stock_quantity, can_purchase, current_price, estimated_delivery

# 4. Combine data
combined_data = {
    **es_result,  # Base info from ES
    **mongo_data,  # Additional info from MongoDB
    **store_data   # Real-time availability from Store API
}

2. Response Structure

{
  "answer": "I found part 10 (WASHER SPRING 10MM H.D Z/P). According to the manual, 1 unit is needed. This part is currently in stock with 150 units available. The current price is $2.50. Would you like a link to view this part on clintontractor.net/parts/productpage/10?",
  "parts": [
    {
      "part_number": "10",
      "description": "WASHER SPRING 10MM H.D Z/P",
      "page": 6,
      "schemas": ["Schema A", "Schema B"],
      "quantity": 1,  // From manual
      "in_stock": true,  // From Store API
      "stock_quantity": 150,  // From Store API
      "price": 2.50,  // From Store API or MongoDB
      "available_for_purchase": true,
      "can_purchase": true,
      "estimated_delivery": "2-3 business days",
      "store_link": "https://clintontractor.net/parts/productpage/10"
    }
  ],
  "needs_confirmation": true,
  "store_link_question": "Would you like a link to view this part on clintontractor.net/parts/productpage/10?"
}

Purchasing Consultation

What to Buy

The agent provides:

  • Part Number: Exact part number
  • Description: Full part description
  • Schemas: Which schemas the part appears on
  • Page Reference: Page number in manual

Example response:

"I found part 10 (WASHER SPRING 10MM H.D Z/P). This part appears on Schema A and Schema B, page 6 of the manual."

Quantity

The agent uses:

  • Quantity from Manual: Quantity specified in documentation
  • Typical Usage: Typical quantity (if available in MongoDB)
  • User Context: User query context

Example response:

"According to the manual, 1 unit is needed for this assembly. However, you may want to purchase 2-3 units as spares."

Stock Availability

The agent checks:

  • Store API: Real-time stock status
  • MongoDB: Stock levels from database (if Store API unavailable)

Example response:

"This part is currently in stock with 150 units available. You can purchase it now."

or

"This part is currently out of stock. Estimated delivery time is 2-3 weeks."

Pricing and Delivery

The agent provides:

  • Current Price: Current price from Store API or MongoDB
  • Estimated Delivery: Estimated delivery time (if available)

Example response:

"The current price is $2.50 per unit. Estimated delivery time is 2-3 business days."

Configuration

Environment Variables

# Store API
STORE_API_URL=https://clintontractor.net/api
STORE_API_KEY=your-api-key-here  # Optional, if API requires authentication
STORE_API_TIMEOUT=5  # Timeout in seconds

# Elasticsearch
ELASTICSEARCH_URL=http://10.0.0.52:9200
SEARCH_INDEX_NAME=parts_current

# MongoDB
MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/database

# Weaviate
WEAVIATE_URL=http://weaviate-db:8080

Consultation Examples

Example 1: Part Number Search with Availability

User: "Find part 10"

Agent:

"I found part 10 (WASHER SPRING 10MM H.D Z/P). According to the manual, 1 unit is needed for this assembly. This part is currently in stock with 150 units available. The current price is $2.50 per unit. Estimated delivery time is 2-3 business days.

This part appears on Schema A and Schema B, page 6 of the manual.

Would you like a link to view this part on clintontractor.net/parts/productpage/10?"

Example 2: Part Number Search without Availability

User: "Find part 25"

Agent:

"I found part 25 (BOLT M8x20). According to the manual, 4 units are needed. Unfortunately, this part is currently out of stock. Estimated delivery time is 2-3 weeks.

Would you like a link to view this part on clintontractor.net/parts/productpage/25? You can also set up a notification for when it becomes available."

Example 3: Description Search with Quantity

User: "I need washers for the spring assembly"

Agent:

"I found several washer parts for the spring assembly:

  1. Part 10 (WASHER SPRING 10MM H.D Z/P) - In stock (150 units) - $2.50
    • Quantity needed: 1 unit per assembly
    • Page 6, Schema A
  2. Part 12 (WASHER FLAT 10MM) - In stock (80 units) - $1.50
    • Quantity needed: 2 units per assembly
    • Page 6, Schema A

Would you like links to view these parts on clintontractor.net/parts/productpage/[PART_NUMBER]?"

Fallback Strategy

If Store API is unavailable:

  1. Use MongoDB stock data
  2. If MongoDB unavailable, use available_for_purchase from Elasticsearch
  3. Agent informs user about limited availability information

Example fallback:

"I found part 10. According to our database, this part is typically available, but I cannot confirm current stock levels at this time. Would you like a link to check availability on clintontractor.net/parts/productpage/10?"

Best Practices

  1. Always check Store API first for real-time availability
  2. Use MongoDB as fallback for stock information
  3. Combine all sources for complete picture
  4. Inform user about data source if information is limited
  5. Provide quantity guidance based on manuals and typical usage

On this page