Chat with Documents

Use Archie to ask questions and get answers about your documents with AI-powered intelligence.


Overview

Archie is Archivus’s AI assistant that understands your documents and provides answers with citations and confidence scores. Access Archie from the sidebar or via direct links.


Quick Start (Web Interface)

1. Open Archie

Click “Archie” in your sidebar, or navigate directly to /archie.

2. Attach Documents (Optional)

Type @ to search and attach specific documents:

@contract-2024 What are the key terms?

3. Ask Questions

Ask in natural language:

  • “What are the payment terms?”
  • “Summarize the key points”
  • “Find all mentions of liability”

4. Follow Up

Archie remembers context - ask follow-up questions naturally.


Open Archie with pre-loaded context:

URL Effect
/archie?document=doc_abc123 Opens with document attached
/archie?q=Find%20invoices Opens and sends query
/archie?document=doc_abc123&q=Summarize Both: document + auto-query

API Integration

Create Chat Session

curl -X POST https://api.archivus.app/api/v1/chat/sessions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "X-Tenant-Subdomain: your-tenant" \
  -H "Content-Type: application/json" \
  -d '{
    "document_id": "doc_abc123",
    "name": "Contract Analysis"
  }'

Ask a Question

curl -X POST https://api.archivus.app/api/v1/chat/sessions/{session_id}/ask \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "X-Tenant-Subdomain: your-tenant" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "What are the key terms of this contract?"
  }'

Response:

{
  "message_id": "msg_123",
  "role": "assistant",
  "content": "The key terms include:\n\n1. **Term Duration**: 24 months\n2. **Payment Terms**: Net 30 days\n...",
  "confidence": 0.95,
  "sources": [
    {
      "document_id": "doc_abc123",
      "page": 3,
      "excerpt": "Term: 24 months starting January 1, 2025"
    }
  ]
}

Multi-Document Session

curl -X POST https://api.archivus.app/api/v1/chat/sessions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "X-Tenant-Subdomain: your-tenant" \
  -H "Content-Type: application/json" \
  -d '{
    "document_ids": ["doc_abc123", "doc_def456"],
    "name": "Contract Comparison"
  }'

RAG Query (Search All Documents)

curl -X POST https://api.archivus.app/api/v1/chat/sessions/{session_id}/ask-rag \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "X-Tenant-Subdomain: your-tenant" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Find all contracts expiring in Q4 2025"
  }'

Code Examples

Python

import requests

class ArchivusChat:
    def __init__(self, api_key, tenant):
        self.api_key = api_key
        self.tenant = tenant
        self.base_url = "https://api.archivus.app/api/v1"
        self.headers = {
            "Authorization": f"Bearer {api_key}",
            "X-Tenant-Subdomain": tenant,
            "Content-Type": "application/json"
        }

    def create_session(self, document_ids, name=None):
        data = {"document_ids": document_ids} if isinstance(document_ids, list) else {"document_id": document_ids}
        if name:
            data["name"] = name
        response = requests.post(f"{self.base_url}/chat/sessions", headers=self.headers, json=data)
        return response.json()

    def ask(self, session_id, message):
        response = requests.post(
            f"{self.base_url}/chat/sessions/{session_id}/ask",
            headers=self.headers,
            json={"message": message}
        )
        return response.json()

# Usage
chat = ArchivusChat("YOUR_API_KEY", "your-tenant")
session = chat.create_session("doc_abc123", "Contract Analysis")
answer = chat.ask(session["id"], "What are the key terms?")
print(f"Answer: {answer['content']}")
print(f"Confidence: {answer['confidence']}")

JavaScript

class ArchivusChat {
  constructor(apiKey, tenant) {
    this.baseURL = 'https://api.archivus.app/api/v1';
    this.headers = {
      'Authorization': `Bearer ${apiKey}`,
      'X-Tenant-Subdomain': tenant,
      'Content-Type': 'application/json'
    };
  }

  async createSession(documentIds, name = null) {
    const data = Array.isArray(documentIds)
      ? { document_ids: documentIds }
      : { document_id: documentIds };
    if (name) data.name = name;

    const response = await fetch(`${this.baseURL}/chat/sessions`, {
      method: 'POST',
      headers: this.headers,
      body: JSON.stringify(data)
    });
    return response.json();
  }

  async ask(sessionId, message) {
    const response = await fetch(`${this.baseURL}/chat/sessions/${sessionId}/ask`, {
      method: 'POST',
      headers: this.headers,
      body: JSON.stringify({ message })
    });
    return response.json();
  }
}

// Usage
const chat = new ArchivusChat('YOUR_API_KEY', 'your-tenant');
const session = await chat.createSession('doc_abc123', 'Contract Analysis');
const answer = await chat.ask(session.id, 'What are the key terms?');
console.log('Answer:', answer.content);
console.log('Confidence:', answer.confidence);

Understanding Responses

Confidence Scores

Range Meaning Action
0.9 - 1.0 High confidence Very reliable
0.7 - 0.9 Good confidence Likely accurate
0.5 - 0.7 Moderate Verify important details
< 0.5 Low May be incomplete

Source Citations

Every response includes citations:

{
  "sources": [
    {
      "document_id": "doc_abc123",
      "page": 3,
      "excerpt": "Term: 24 months starting January 1, 2025"
    }
  ]
}

Best Practices

Ask Specific Questions

Effective:

  • “What is the termination clause?”
  • “Who are the parties to this contract?”
  • “When does this contract expire?”

Less Effective:

  • “Tell me everything”
  • “Summarize this”

Use Follow-ups

Archie remembers conversation context:

answer1 = chat.ask(session_id, "What is the contract term?")
answer2 = chat.ask(session_id, "Can it be extended?")  # Archie knows we're discussing the same contract
answer3 = chat.ask(session_id, "What's the process?")

Verify Important Decisions

For critical information:

  • Check the source citations
  • Review confidence scores
  • Verify against original document

Costs

Operation Credits
Chat message 1
RAG query 2
Context windowing Saves 60-80%
Prompt caching Saves 70-90%

Next Steps


Questions? Contact support@ubiship.com