Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@vinhnx
Copy link
Owner

@vinhnx vinhnx commented May 24, 2025

  • Removed redundant tokens_usage table; token counting now handled by database triggers.
  • Updated log_request_to_supabase function to reflect changes in token usage tracking.
  • Added new functions for user analytics: get_user_analytics, get_user_request_history, get_user_token_breakdown, get_user_monthly_usage, and get_recent_user_activity.
  • Enhanced success and failure callbacks for LiteLLM to log requests and errors to Supabase.
  • Improved documentation for production readiness and user-request analytics.
  • Added tests for real user integration, simplified token usage, and user analytics functionality.

vinhnx added 21 commits May 20, 2025 22:32
- Implemented a FastAPI backend in `api.py` to handle chat requests, utilizing the litellm library for AI responses.
- Developed a simple API server in `simple_api.py` that directly interacts with OpenAI's API for chat completions, including error handling for API key issues and rate limits.
- Created a new static HTML page (hello.html) to verify server functionality.
- Added a simple chat interface (simple-chat.html) with user and assistant message handling.
- Implemented a test page (test.html) to confirm static file serving.
- Updated index.html to correctly reference the main TypeScript file.
- Introduced CSS styles for chat components in Chat.css.
- Enhanced Chat.tsx to manage session IDs, error handling, and local storage for messages.
- Added health check endpoint to the API for server status verification.
- Improved error handling in chat API interactions and refined message structure.
- Updated Vite configuration to include API proxy settings for local development.
- Refactored utility imports to maintain a consistent namespace across the application.
- Add update password page and form
- Create protected route with user session validation
- Implement forgot password form with Supabase integration
- Add login form with email and password authentication
- Create logout button for user session management
- Implement sign-up form with email verification
- Add success page for sign-up confirmation
- Create error handling page for authentication issues
- Set up Tailwind CSS and PostCSS configuration
- Add utility components for UI elements (Button, Card, Input, Label, Checkbox)
- Implement middleware for session management with Supabase
- Update global styles and theme configuration
…ofile management features with authentication middleware and Chainlit session handling.
- Deleted obsolete authentication pages and components including login, signup, error handling, and password management.
- Removed global CSS and Tailwind configuration files as they are no longer needed.
- Eliminated the auth-bridge and auth-redirect JavaScript files that handled client-side authentication.
- Updated the main application logic to streamline user authentication using OAuth with Chainlit and Supabase.
- Adjusted the FastAPI server configuration by removing the authentication middleware.
- Changed the default model in the LLM providers configuration to a new model.
- Added setup for LiteLLM callbacks to log requests and responses to Supabase.
- Enhanced conversation handlers to include detailed logging for API calls.
- Introduced token usage tracking and cost estimation for LLM calls.
- Created a comprehensive logging system for success and failure events.
- Developed example scripts to demonstrate logging functionality and integration tests.
- Updated database schema for request logs and token usage tracking.
- Implemented error handling and logging improvements across various modules.
- Removed redundant `tokens_usage` table; token counting now handled by database triggers.
- Updated `log_request_to_supabase` function to reflect changes in token usage tracking.
- Added new functions for user analytics: `get_user_analytics`, `get_user_request_history`, `get_user_token_breakdown`, `get_user_monthly_usage`, and `get_recent_user_activity`.
- Enhanced success and failure callbacks for LiteLLM to log requests and errors to Supabase.
- Improved documentation for production readiness and user-request analytics.
- Added tests for real user integration, simplified token usage, and user analytics functionality.
@vinhnx vinhnx added this to the Authentication milestone May 24, 2025
@vinhnx vinhnx requested a review from Copilot May 24, 2025 01:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request refactors authentication and logging functionality by removing redundant database tables, updating logging callbacks, and adding comprehensive tests for user analytics and token usage tracking. Key changes include:

  • Removal of the redundant tokens_usage table and reliance on database triggers for token counting.
  • Addition of new functions for detailed user analytics and updated logging callbacks.
  • Extensive updates and refactoring of test files and documentation to align with the new authentication and logging mechanisms.

Reviewed Changes

Copilot reviewed 62 out of 62 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
examples/test_user_analytics.py Added tests for user analytics functionality.
examples/test_supabase_logging.py Updated tests for Supabase logging including direct logging and callback setup.
examples/test_simplified_system.py Added tests verifying simplified token usage and removal of redundant tables.
examples/test_real_user_integration.py Added tests for real user integration and proper mapping of session IDs to authenticated user IDs.
examples/test_integration_with_session.py Introduced tests for user session integration with quick_completion calls.
examples/test_callback_integration.py Enhanced tests for LiteLLM callbacks with success and failure scenarios.
examples/litellm_supabase_standalone.py Provided a standalone example demonstrating LiteLLM with Supabase logging integration.
examples/litellm_supabase_example.py Updated example implementation to include Supabase callbacks and proper user logging.
examples/gpt_image_1_advanced_example.py Fixed import paths for media processing and provider configurations.
docs/user-request-analytics.md Added detailed documentation for user-request analytics and associated SQL functions/views.
docs/production-ready-summary.md Documented production readiness, database migrations, and final architecture changes.
docs/litellm-supabase-logging.md Updated documentation to reflect new logging, token tracking, and callback integrations.
docs/developer/rust-implementation.md Updated rust example to reflect current model usage.
docs/developer/mcp.md Removed deprecated MCP documentation.
docs/api/utils.md, docs/api/assistants.md Updated import paths to use the new vtai.utils namespace.
AGENT.md Added development guide with commands, code style, and project structure details.
.vscode/tasks.json, .github/copilot-instructions.md Updated developer and copilot instructions to reflect new coding conventions and project tasks.
Comments suppressed due to low confidence (2)

docs/developer/rust-implementation.md:323

  • The updated model identifier 'gpt-4o' in this rust example might be inconsistent with other parts of the codebase that use 'gpt-4o-mini'; please verify that this is the intended model identifier.
-  -d '{"model":"gpt-4o", "messages":[{"role":"user","content":"Hello"}]}'

docs/developer/mcp.md:1

  • The complete removal of this documentation file suggests MCP integration is deprecated; ensure that any references to MCP in the project documentation and code have been appropriately updated or redirected.
# Model Context Protocol (MCP) Integration

vinhnx added 6 commits May 24, 2025 09:24
…nsive testing

- Added `byok_fix_validation.py` to demonstrate and validate BYOK fixes.
- Created `test_byok_complete_flow.py` to validate the entire BYOK flow from Chat Settings to API calls.
- Developed `test_byok_functionality.py` to verify authentication flow and priority of API keys.
- Introduced `test_byok_functionality_simple.py` for simple user_keys propagation tests.
- Added `test_byok_simple.py` to directly test authentication logic without full application imports.
- Implemented `test_byok_user_env.py` to verify user_env functionality and its priority in authentication.
- Created `vtai/utils/api_keys.py` for secure management of API keys, including encryption and decryption.
- Removed unused conversation handlers: handle_reasoning_conversation and handle_thinking_conversation.
- Simplified conversation handling logic to streamline message processing.
- Introduced dynamic model configuration for Ollama, LM Studio, and llama.cpp.
- Enhanced logging to prevent duplicate messages during user session initialization.
- Deleted redundant assistant management files and tools.
- Updated settings to include new model configurations for Ollama, LM Studio, and llama.cpp.
- Improved API key handling and validation logic.
- Added checks for non-200 HTTP status codes in Supabase logging.
vinhnx added 18 commits May 24, 2025 17:10
…tion, enhancing user profile management and logging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants