Skip to content

Nikhi-l/CrustDataCopilot

Repository files navigation

Crustdata API Assistant WebApp

This repository contains a web application to interact with the Crustdata API via an AI assistant. The assistant is designed to help users understand and utilize the Crustdata Discovery and Enrichment API efficiently.

Table of Contents

Features

  • Crustdata API Integration:

    • Explains API endpoints and functionality
    • Constructs properly formatted requests
    • Handles error scenarios gracefully
  • Vector Store Integration:

    • Automatically uploads documentation during assistant creation
    • Maintains searchable knowledge base
    • Enables quick information retrieval
  • Python Code Execution:

    • Custom Python executor environment included
    • Ability to run and test API calls
    • Secure execution environment
  • Dynamic Knowledge Base Management:

    • Upload new documentation via chat interface
    • Modify existing knowledge base content
    • Real-time updates to vector store
  • Secure Hosting:

    • Runs on port 8000
    • Implements secure authentication
    • Role-based access control
  • Slack Bot Integration:

    • Seamless workspace integration
    • Channel-specific responses
    • User access control

Installation and Setup

Step 1: Clone the Repository

git clone https://github.com/Nikhi-l/CrustDataCopilot
cd CrustDataCopilot

Step 2: Install Dependencies

pip install -r requirements.txt

Step 3: Create the Assistant

Run the creation script:

python create-assistant.py

This script performs the following:

  • Uploads all files from knowledge_base directory to vector store
  • Generates necessary IDs for the assistant
  • Updates the .env file automatically
  • Configures initial settings

Step 4: Launch the WebApp

Start the application:

chainlit run app.py -w

The application will be accessible at http://localhost:8000

Configuration

User Management

The application uses config.json for managing access control:

{
  "users": [
    {
      "username": "crust",
      "password": "admin",
      "role": "admin"
    },
    {
      "username": "testuser",
      "password": "testpass",
      "role": "user"
    }
  ],
  "allowed_users": [
    "[email protected]",
    "[email protected]"
  ],
  "allowed_channels": [
    "C08810KS9PA"
  ]
}

Access Control Details:

  1. Local Authentication

    • Users array defines UI login credentials
    • Roles can be "admin" or "user"
    • Admins have additional privileges (e.g., knowledge base modification)
  2. Slack Authentication

    • Allowed users list controls Slack access
    • Channel restrictions prevent unauthorized usage
    • Email-based user identification

Slack Integration

1. Prerequisites

Install the required package:

pip install slack_bolt

2. Slack App Setup

  1. Visit Slack API Dashboard
  2. Create new application
  3. Configure bot permissions
  4. Obtain security credentials:
    • Slack Bot Token
    • Slack Signing Secret

3. Environment Configuration

Add to .env file:

SLACK_BOT_TOKEN=your-slack-bot-token
SLACK_SIGNING_SECRET=your-slack-signing-secret

4. App Manifest Configuration

Update your Slack app manifest with:

display_information:
  name: { APP_NAME }
features:
  bot_user:
    display_name: { APP_NAME }
    always_online: false
oauth_config:
  scopes:
    user:
      - im:history
      - channels:history
    bot:
      - app_mentions:read
      - channels:read
      - chat:write
      - files:read
      - files:write
      - im:history
      - im:read
      - im:write
      - users:read
      - users:read.email
      - channels:history
      - groups:history
settings:
  event_subscriptions:
    request_url: https://{APP_HOST }/slack/events
    bot_events:
      - app_home_opened
      - app_mention
      - message.im
  interactivity:
    is_enabled: true
    request_url: https://{ APP_HOST }/slack/events
  org_deploy_enabled: false
  socket_mode_enabled: false
  token_rotation_enabled: false

5. Direct Message Configuration

To enable DMs:

  1. Go to App Home in Slack settings
  2. Enable "Allow users to send Slash commands and messages"

Logging and Monitoring

Setup Instructions

  1. Literal.ai Integration

    • Register at Literal.ai
    • Generate API key
    • Add to .env:
      LITERAL_API_KEY=your-literal-api-key
  2. Monitoring Features

    • Real-time conversation tracking
    • Performance metrics dashboard
    • API usage statistics
    • Error monitoring
    • Data export capabilities
  3. Data Persistence

    • Automatic conversation storage
    • Historical data access
    • Analytics capabilities

Usage Guide

Knowledge Base Management

  • Initial setup uploads all knowledge_base documents
  • Use chat interface for updates
  • Admin privileges required for modifications

Chat Interface Capabilities

  • API endpoint explanations
  • Request construction assistance
  • Error debugging
  • Feature exploration:
    • Company data enrichment
    • LinkedIn search
    • Credit usage monitoring

Python Code Execution

  • Security Notice: Environment can make external API calls
  • Restricted access recommended
  • Use for testing and debugging

Environment Setup

Required .env variables:

OPENAI_API_KEY=your-openai-key
OPENAI_ASSISTANT_ID=auto-generated
OPENAI_VECTOR_STORE_ID=auto-generated
LITERAL_API_KEY=your-literal-key
SLACK_BOT_TOKEN=your-slack-token
SLACK_SIGNING_SECRET=your-slack-secret

About

Your Copilot for everything CrustData : https://youtu.be/eiYMxEoTcXc

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published