Skip to content

datasciencedojo/ejento_streamlit_client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ejento AI Chat Application

A Streamlit-based chat interface for interacting with the Ejento AI API with real-time streaming responses, thread management, and persistent chat history.

Streamlit Python


📧 Before You Start

You will receive an email containing:

  • 🌐 API Base URL
  • 🔑 API Subscription Key
  • 📧 Your registered email address

🌐 Note: Your Agent ID is available on the Ejento website after login.

  • Look for: AGENT_ID = "2009" (your number will be different)

⚠️ Check your email first! You'll need these credentials for setup.


🚀 Quick Setup (3 Steps)

Step 1: Install Dependencies

pip install -r requirements.txt

This installs Streamlit, requests, and all other required libraries.


Step 2: Get Your Access Token

Run the authentication script:

python3 get_token.py

Follow the prompts:

  1. Enter your API base URL (from email)
  2. Enter your email address (from email)
  3. Check email for authentication code
  4. Enter the code
  5. Copy your ACCESS_TOKEN!

Step 3: Configure Secrets

Option A: Interactive Setup (Recommended)

Run the setup script:

python3 setup_secrets.py

The script will:

  • Prompt you for each required value
  • Create .streamlit/secrets.toml automatically
  • Validate your configuration

Option B: Manual Setup

Create .streamlit/secrets.toml manually:

# From email
API_BASE_URL = "https://your-api.azure-api.net"
API_SUBSCRIPTION_KEY = "your_subscription_key"

# From get_token.py script
ACCESS_TOKEN = "your_access_token_here"

# From Ejento website (after login)
# Look for AGENT_ID on the Ejento dashboard
AGENT_ID = "2009"

# Optional: Customize your app title (uncomment to use)
# APP_TITLE = "🤖 AI Blog Assistant"

📍 Notes:

  • QUERY_SOURCE is not needed (hardcoded to "web")
  • APP_TITLE is optional - uncomment and customize if desired
  • Cookie encryption uses ACCESS_TOKEN automatically

For Streamlit Cloud:

  1. Go to your app settings
  2. Click "Secrets"
  3. Add the same TOML format above
  4. Save and restart

▶️ Run the Application

streamlit run app.py

The application will open at http://localhost:8501


✨ Features

  • 💬 Real-time Streaming Responses - See AI responses as they're generated
  • 🧵 Thread Management - Automatic chat thread creation and switching
  • 📝 Persistent History - Chat history saved and loaded across sessions
  • 🔄 New Chat Button - Start fresh conversations anytime
  • 📱 Responsive Design - Clean interface with 16px font throughout
  • 🔐 Secure Authentication - Passwordless token-based authentication
  • 🍪 Cookie Persistence - Remember your active thread across page reloads

📁 Project Structure

ejento_chat_app/
├── app.py                    # Main Streamlit application
├── config.py                 # Configuration management
├── get_token.py              # Authentication script
├── setup_secrets.py          # Interactive setup script
├── requirements.txt          # Python dependencies
├── .streamlit/
│   └── secrets.toml          # Local secrets (not committed)
└── README.md                 # This file

🔧 Configuration Details

Required Secrets

Key Description Source Example
API_BASE_URL API endpoint URL Email https://your-api.azure-api.net
API_SUBSCRIPTION_KEY API subscription key Email your_subscription_key
ACCESS_TOKEN Authentication token get_token.py script eyJhbGci...
AGENT_ID Your agent identifier Ejento website (dashboard) "2009"

Note: QUERY_SOURCE is hardcoded to "web" and not configurable.

Optional Settings

Key Description Default
APP_TITLE Custom app title "Ejento AI Chat"


🆘 Troubleshooting

"No module named 'streamlit'"

pip install -r requirements.txt

"Configuration not found"

Make sure you've created .streamlit/secrets.toml with all required keys.

"Invalid access token"

Your token may have expired. Run get_token.py again to generate a new one.

"Can't connect to API"

Check that your BASE_URL is correct and includes https://

Authentication code not received

  • Check spam folder
  • Wait 2-3 minutes
  • Verify email address is correct
  • Request a new code

Warning: "st.cache is deprecated"

This warning comes from the streamlit-cookies-manager library (v0.2.0) and is harmless. The library maintainers are aware and working on an update. You can safely ignore this warning - it doesn't affect functionality.


🚀 Deployment

Streamlit Cloud

  1. Fork this repository
  2. Connect to Streamlit Cloud
  3. Add secrets (see Step 3 above)
  4. Deploy!

🔐 Security Notes

  • ⚠️ Never commit secrets to Git
  • ⚠️ Never share your tokens publicly
  • ⚠️ Use .streamlit/secrets.toml for local development
  • ⚠️ Use platform secrets management for production
  • ⚠️ Tokens may expire - regenerate as needed

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages