Skip to content

Feature/pyagenity 0.2.1#2

Merged
Iamsdt merged 2 commits into
mainfrom
feature/pyagenity-0.2.1
Sep 17, 2025
Merged

Feature/pyagenity 0.2.1#2
Iamsdt merged 2 commits into
mainfrom
feature/pyagenity-0.2.1

Conversation

@Iamsdt
Copy link
Copy Markdown
Collaborator

@Iamsdt Iamsdt commented Sep 17, 2025

This pull request refactors and improves the authentication and configuration system for the Pyagenity API. It introduces a flexible, pluggable authentication backend architecture, updates configuration handling, and enhances module loading and dependency injection. The changes also improve error handling and modularity, making it easier to customize authentication and other integrations.

Authentication System Refactor:

  • Introduced an abstract BaseAuth class (pyagenity_api/src/app/core/auth/base_auth.py) to define a standard authentication interface, enabling pluggable authentication backends.
  • Implemented a new JwtAuth class (pyagenity_api/src/app/core/auth/jwt_auth.py) for JWT-based authentication, replacing the previous inline JWT logic and improving error handling.
  • Refactored the authentication logic in auth_backend.py to use dependency injection for loading authentication backends, removing the old verify_jwt function and supporting custom or JWT methods via configuration. [1] [2]

Configuration and Module Loading:

  • Enhanced GraphConfig to support new fields (injectq, redis, thread_model_name, etc.), flexible authentication configuration, and improved error handling for unsupported auth methods. [1] [2]
  • Added new loader functions (load_container, load_auth, attach_all_modules) in loader.py to support dynamic loading and binding of containers and authentication backends using dependency injection.

Application Initialization and Error Handling:

  • Updated main.py to use the new container and attach modules via attach_all_modules, binding configuration and authentication instances for use throughout the app. Improved shutdown resource cleanup. [1] [2] [3]
  • Improved Sentry initialization in sentry_config.py to handle missing dependencies gracefully and log warnings instead of failing. [1] [2] [3]

Documentation and Miscellaneous:

  • Updated documentation (Config.md) to describe supported authentication methods and configuration options.
  • Minor updates to settings and logging for clarity and consistency. [1] [2]

These changes collectively modernize the authentication system and configuration handling, making the API framework more extensible and robust for future integrations.

- Added injectq_path property to GraphConfig for injectq configuration.
- Introduced redis_url property to GraphConfig for Redis connection.
- Enhanced auth_config method to support JWT and custom authentication methods.
- Added generate_thread_name and thread_model_name properties to GraphConfig.

fix: Improve Sentry initialization with error handling

- Wrapped Sentry initialization in a try-except block to handle ImportError and other exceptions gracefully.

refactor: Update Settings class for improved configuration

- Changed SUMMARY value to "Pyagenity Backend".
- Removed unused JWT and auth-related settings from the Settings class.

feat: Implement InjectQ and BaseAuth loading in loader.py

- Added load_container and load_auth functions to load InjectQ and BaseAuth dynamically.
- Updated attach_all_modules to bind the auth backend to the container.

chore: Update main.py to integrate new loading mechanisms

- Refactored lifespan context manager to load graph and auth backend using new methods.
- Ensured proper resource cleanup on application shutdown.

feat: Enhance CheckpointerService with state caching

- Updated put_state method to also update the state cache after storing the state.

refactor: Streamline GraphService for improved streaming

- Refactored stream_graph method to use AsyncIterable for streaming responses.
- Improved thread name generation logic based on new config properties.

feat: Introduce ThreadService for dynamic thread name generation

- Implemented thread name generation using LLM based on conversation context.
- Added methods for saving and generating thread names based on messages.

chore: Remove deprecated text.py and replace with api_check.py

- Consolidated API testing logic into a new api_check.py file for better organization.

feat: Add base authentication structure with JWT support

- Created BaseAuth class for defining authentication methods.
- Implemented JwtAuth class for handling JWT-based authentication.

feat: Implement Snowflake ID generator for unique ID creation

- Added SnowFlakeIdGenerator class to generate unique IDs using Snowflake algorithm.
@Iamsdt Iamsdt merged commit 6c9bc13 into main Sep 17, 2025
@Iamsdt Iamsdt deleted the feature/pyagenity-0.2.1 branch September 17, 2025 07:21
Sarthak422004 pushed a commit to Sarthak422004/pyagenity-api that referenced this pull request Sep 24, 2025
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.

1 participant