Skip to main content

Official Python SDK for Yardee Vector Database API

Project description

Yardee Python SDK

๐Ÿš€ The fastest way to add AI-powered search to your Python applications

PyPI version Python 3.8+ License: MIT

Turn your documents into intelligent search endpoints in minutes. The Yardee Python SDK provides seamless access to our vector database API, letting you build ChatGPT-style question answering over your own data.

โšก Quick Start

pip install yardee
from yardee import Client

# Initialize client
client = Client(api_key="sk-your-api-key")

# Search your knowledge base
results = client.search(
    knowledge_base_id=123,
    query="How do I reset my password?"
)

# Get intelligent answers
for result in results['results']:
    print(f"๐Ÿ“„ {result['content']}")
    print(f"๐ŸŽฏ Relevance: {result['similarity_score']:.2f}")

Get your free API key at app.yardee.ai โ†’

๐ŸŽฏ Why Yardee?

  • โšก Instant Setup: Upload PDFs, get searchable API in 30 seconds
  • ๐Ÿง  Smart Results: Vector similarity + metadata filtering + MMR diversity
  • ๐Ÿ”— Connect Everything: HubSpot CRM, live databases, CSV files
  • ๐ŸŒ Built for Scale: Used by developers in 50+ countries
  • ๐Ÿ’ฐ Developer-Friendly Pricing: Free tier + pay-per-query

๐Ÿ›  Core Features

๐Ÿ“š Knowledge Base Management

# Create a knowledge base
kb = client.create_knowledge_base(
    name="Customer Support",
    description="FAQ and help articles"
)

# Upload documents
result = client.upload_document(
    knowledge_base_id=kb['id'],
    file_path="./support_docs.pdf"
)

# List all knowledge bases
knowledge_bases = client.list_knowledge_bases()

๐Ÿ” Advanced Search

# Basic search
results = client.search(
    knowledge_base_id=123,
    query="pricing plans",
    top_k=5
)

# Advanced filtering
results = client.search(
    knowledge_base_id=123,
    query="enterprise features",
    similarity_threshold=0.8,
    metadata_filters={"department": "sales"},
    use_mmr=True  # Maximum Marginal Relevance for diversity
)

# Conversational search with context
results = client.search(
    knowledge_base_id=123,
    query="What about enterprise pricing?",
    chat_history=[
        {"role": "user", "content": "Tell me about your pricing"},
        {"role": "assistant", "content": "We have three pricing tiers..."}
    ]
)

๐Ÿ“Š Document Management

# List documents
documents = client.list_documents(knowledge_base_id=123)

# Delete document
client.delete_document(document_id=456)

๐Ÿ—ƒ๏ธ Live Database Connections

# Connect PostgreSQL database
db_conn = client.create_database_connection(
    knowledge_base_id=123,
    name="Production PostgreSQL",
    db_type="postgres",
    host="db.mycompany.com",
    port=5432,
    database="analytics",
    username="readonly_user",
    password="secure_password"
)

# Connect with SSH tunnel for security
secure_conn = client.create_database_connection(
    knowledge_base_id=123,
    name="Secure MySQL",
    db_type="mysql",
    host="internal-db",
    port=3306,
    database="sales",
    username="api_user", 
    password="password",
    use_ssh_tunnel=True,
    ssh_host="bastion.company.com",
    ssh_port=22,
    ssh_user="ubuntu",
    ssh_private_key="-----BEGIN RSA PRIVATE KEY-----\n..."
)

# Test connection
test_result = client.test_connection(123, db_conn['id'])
print(f"Connection status: {'โœ… Working' if test_result['success'] else 'โŒ Failed'}")

# Query database with natural language (uses same search endpoint)
results = client.search(
    knowledge_base_id=123,
    query="How many customers signed up last month?"
)

๐Ÿš€ HubSpot CRM Integration

# Connect HubSpot CRM
hubspot_conn = client.create_hubspot_connection(
    knowledge_base_id=123,
    name="HubSpot CRM",
    private_app_token="pat-na1-your-private-app-token"
)

# Query HubSpot data with natural language
crm_results = client.search(
    knowledge_base_id=123,
    query="Show me deals in the proposal stage with value over $50k"
)

# Mixed queries across documents + CRM + databases
comprehensive_results = client.search(
    knowledge_base_id=123,
    query="Compare our pricing from the docs with actual deal values in HubSpot"
)

# List all connections
connections = client.list_connections(123)
for conn in connections['connections']:
    print(f"- {conn['name']} ({conn['db_type']}) - {conn['status']}")

๐Ÿš€ Real-World Examples

Customer Support Chatbot

from yardee import Client

def answer_support_question(question: str) -> str:
    client = Client(api_key="sk-your-key")
    
    results = client.search(
        knowledge_base_id=123,  # Your support docs
        query=question,
        top_k=3,
        similarity_threshold=0.7
    )
    
    if not results['results']:
        return "I couldn't find relevant information. Please contact support."
    
    # Combine top results into answer
    context = "\n".join([r['content'] for r in results['results']])
    return f"Based on our documentation:\n\n{context}"

# Use it
answer = answer_support_question("How do I cancel my subscription?")
print(answer)

Content Discovery API

from flask import Flask, request, jsonify
from yardee import Client

app = Flask(__name__)
client = Client(api_key="sk-your-key")

@app.route('/search')
def search_content():
    query = request.args.get('q')
    
    results = client.search(
        knowledge_base_id=456,  # Your content KB
        query=query,
        top_k=10,
        use_mmr=True  # Diverse results
    )
    
    return jsonify({
        'query': query,
        'results': results['results'],
        'count': len(results['results'])
    })

if __name__ == '__main__':
    app.run()

Complete Business Intelligence Setup

from yardee import Client
import os

def setup_complete_intelligence_system():
    """
    Set up a complete business intelligence system with documents, 
    database, and CRM integration.
    """
    client = Client(api_key="sk-your-key")
    
    # 1. Create knowledge base
    kb = client.create_knowledge_base(
        name="Business Intelligence Hub",
        description="Complete business data: docs + database + CRM"
    )
    kb_id = kb['id']
    print(f"โœ… Created knowledge base: {kb['name']}")
    
    # 2. Upload documentation
    doc_results = []
    doc_folder = "./business_docs"
    if os.path.exists(doc_folder):
        for filename in os.listdir(doc_folder):
            if filename.endswith(('.pdf', '.docx', '.txt')):
                try:
                    result = client.upload_document(kb_id, os.path.join(doc_folder, filename))
                    doc_results.append(result)
                    print(f"โœ… Uploaded: {filename}")
                except Exception as e:
                    print(f"โŒ Failed to upload {filename}: {e}")
    
    # 3. Connect production database
    try:
        db_conn = client.create_database_connection(
            knowledge_base_id=kb_id,
            name="Production Database",
            db_type="postgres",
            host=os.getenv("DB_HOST", "db.company.com"),
            port=5432,
            database=os.getenv("DB_NAME", "analytics"), 
            username=os.getenv("DB_USER", "readonly_user"),
            password=os.getenv("DB_PASS", "secure_password"),
            ssl_required=True
        )
        print(f"โœ… Connected database: {db_conn['name']}")
        
        # Test database connection
        test_result = client.test_connection(kb_id, db_conn['id'])
        if test_result['success']:
            print("โœ… Database connection verified")
        else:
            print(f"โš ๏ธ  Database test failed: {test_result.get('error', 'Unknown error')}")
            
    except Exception as e:
        print(f"โŒ Database connection failed: {e}")
    
    # 4. Connect HubSpot CRM
    hubspot_token = os.getenv("HUBSPOT_TOKEN")
    if hubspot_token:
        try:
            crm_conn = client.create_hubspot_connection(
                knowledge_base_id=kb_id,
                name="HubSpot CRM",
                private_app_token=hubspot_token
            )
            print(f"โœ… Connected HubSpot: {crm_conn['name']}")
            
            # Test HubSpot connection  
            test_result = client.test_connection(kb_id, crm_conn['id'])
            if test_result['success']:
                print("โœ… HubSpot connection verified")
            else:
                print(f"โš ๏ธ  HubSpot test failed: {test_result.get('error', 'Unknown error')}")
                
        except Exception as e:
            print(f"โŒ HubSpot connection failed: {e}")
    else:
        print("โš ๏ธ  No HUBSPOT_TOKEN environment variable found")
    
    # 5. Test comprehensive queries
    print("\n๐Ÿง  Testing AI queries across all data sources...")
    
    test_queries = [
        "How many customers do we have in our database?",
        "What are our top 3 selling products this quarter?", 
        "Show me recent deals over $10k from HubSpot",
        "According to our documentation, what is our refund policy?",
        "Compare actual sales numbers with our pricing strategy from the docs"
    ]
    
    for query in test_queries:
        try:
            results = client.search(kb_id, query, top_k=3)
            print(f"\n๐Ÿ“Š Query: '{query}'")
            print(f"   Results: {len(results['results'])} found")
            
            for i, result in enumerate(results['results'][:2], 1):
                source = result.get('document_title', 'Unknown source')
                content_preview = result['content'][:100] + "..." if len(result['content']) > 100 else result['content']
                print(f"   {i}. {source}: {content_preview}")
                
        except Exception as e:
            print(f"   โŒ Query failed: {e}")
    
    # 6. Summary
    connections = client.list_connections(kb_id)
    documents = client.list_documents(kb_id)
    
    print(f"\n๐ŸŽ‰ Setup Complete!")
    print(f"   ๐Ÿ“š Knowledge Base ID: {kb_id}")
    print(f"   ๐Ÿ“„ Documents: {documents['count']}")
    print(f"   ๐Ÿ”— Connections: {len(connections.get('connections', []))}")
    print(f"   ๐Ÿš€ Ready for AI-powered business intelligence!")
    
    return kb_id

# Run the setup
if __name__ == "__main__":
    setup_complete_intelligence_system()

๐Ÿ”ง Advanced Configuration

from yardee import Client

# Custom configuration
client = Client(
    api_key="sk-your-key",
    base_url="https://app.yardee.ai/api/v1",  # Custom endpoint
    timeout=60,  # Request timeout
    max_retries=5  # Retry failed requests
)

# Using context manager (auto-closes connections)
with Client(api_key="sk-your-key") as client:
    results = client.search(123, "your query")

๐Ÿšจ Error Handling

from yardee import Client, YardeeError, AuthenticationError, RateLimitError

client = Client(api_key="sk-your-key")

try:
    results = client.search(123, "test query")
    
except AuthenticationError:
    print("โŒ Invalid API key")
    
except RateLimitError:
    print("โณ Rate limit exceeded, please wait")
    
except YardeeError as e:
    print(f"โŒ API Error: {e}")
    
except Exception as e:
    print(f"๐Ÿ’ฅ Unexpected error: {e}")

๐Ÿ“– API Reference

Client Class

Client(api_key, base_url=None, timeout=30, max_retries=3)

Main client class for interacting with Yardee API.

Parameters:

  • api_key (str): Your Yardee API key (required)
  • base_url (str): Custom API endpoint (optional)
  • timeout (int): Request timeout in seconds (default: 30)
  • max_retries (int): Max retry attempts (default: 3)

Search Methods

search(knowledge_base_id, query, top_k=5, similarity_threshold=0.1, use_mmr=True, metadata_filters=None, chat_history=None)

Perform semantic search across a knowledge base.

Returns: Dictionary with results list and total_results count.

Knowledge Base Methods

list_knowledge_bases()

Get all knowledge bases in your account.

create_knowledge_base(name, description=None)

Create a new knowledge base.

get_knowledge_base(knowledge_base_id)

Get details of a specific knowledge base.

Document Methods

upload_document(knowledge_base_id, file_path, filename=None)

Upload a document to a knowledge base.

list_documents(knowledge_base_id)

List all documents in a knowledge base.

delete_document(document_id)

Delete a document.

Connection Methods

create_database_connection(knowledge_base_id, name, db_type, host, port, database, username, password, **options)

Create a live database connection (PostgreSQL, MySQL, SQL Server).

create_hubspot_connection(knowledge_base_id, name, private_app_token)

Create a HubSpot CRM connection.

list_connections(knowledge_base_id)

List all connections for a knowledge base.

get_connection(knowledge_base_id, connection_id)

Get details of a specific connection.

update_connection(knowledge_base_id, connection_id, **updates)

Update connection settings.

delete_connection(knowledge_base_id, connection_id)

Delete a connection.

test_connection(knowledge_base_id, connection_id)

Test if a connection is working.

๐ŸŒŸ What Developers Are Building

"Yardee turned our 500-page manual into a ChatGPT for our support team. Setup took 5 minutes."
โ€” SaaS Startup, 50k users

"We connected our CRM and now our sales team has instant access to all customer context."
โ€” E-commerce Platform, India

"The Python SDK made integration trivial. Our chatbot now answers technical questions from our docs."
โ€” Fintech Company, Pakistan

๐Ÿค Support & Community

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿš€ Get Started Now

  1. Get your API key: Sign up at app.yardee.ai
  2. Install the SDK: pip install yardee
  3. Upload your first document
  4. Start searching!
from yardee import Client

client = Client(api_key="sk-your-key")
# Your AI-powered search is ready! ๐ŸŽ‰

Made with โค๏ธ by the Yardee Team | Star us on GitHub โญ

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yardee-0.1.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yardee-0.1.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file yardee-0.1.0.tar.gz.

File metadata

  • Download URL: yardee-0.1.0.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for yardee-0.1.0.tar.gz
Algorithm Hash digest
SHA256 311ee2916cb539be067efd9368d215ddec850a1a33f425de34e8b391c552d0f5
MD5 53d80f36fcd91dc134452194faea1c01
BLAKE2b-256 2184a0ae43e09281a00f45790a70703306c5332dd2ad1c08a1e68d8d49ac1b2f

See more details on using hashes here.

File details

Details for the file yardee-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: yardee-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for yardee-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 965369150ce8fd214e0924d23b5cfd3b9b1b5618f6cdf841517ea46014ae3d11
MD5 6bba15af11057aea149d6d1d70e17e96
BLAKE2b-256 036b78872856eb38b0dda2fb48eea1ccd3e6ea1e0a3444468c48d957e33eb827

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page