-
Notifications
You must be signed in to change notification settings - Fork 7
OpenAI Key per Org #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
rename project and stack --------- Co-authored-by: sourabhlodha <sourabhlodha@Administrators-MacBook-Pro.local>
* use latest docker image * update envsample
* token expiry time can be customize * default to one day
* trial * pushing all * models file * renaming * Rename Project.py to project.py * Rename oganization.py to organization.py * Update README.md (#44) * changes (#45) Co-authored-by: sourabhlodha <sourabhlodha@Administrators-MacBook-Pro.local> * Readme update (#47) rename project and stack --------- Co-authored-by: sourabhlodha <sourabhlodha@Administrators-MacBook-Pro.local> * fix create_user endpoint (#62) * standard api response and http exception handling (#67) * standardization and edits * small edits * small edits * small edits * fixed project post * trial * pushing all * models file * renaming * Rename Project.py to project.py * Rename oganization.py to organization.py * standardization and edits * small edits * small edits * small edits * fixed project post * remove these files since they were somehow pushed into this branch * re-push the docker file * re-push utils file * re-push the file * fixing test cases --------- Co-authored-by: Sourabh Lodha <sourabh_lodha@ymail.com> Co-authored-by: sourabhlodha <sourabhlodha@Administrators-MacBook-Pro.local> Co-authored-by: Aviraj Gour <100823015+avirajsingh7@users.noreply.github.com> Co-authored-by: Ishankoradia <ikoradia@umich.edu>
* intial commit user project mapping and authorization * fix alembic migration * Use standard API response * add pagination * add index and use base model
* fixing testcases and migrations * changes migration file name * remove old migration --------- Co-authored-by: Akhilesh Negi <akhileshnegi.an3@gmail.com>
* Intial setup api key * added Api key auth flow * support both api key and oauth --------- Co-authored-by: Sourabh Lodha <sourabh_lodha@ymail.com>
Back merge Production to staging code
* fix authentication part * Modify test cases to compatible with new auth
* issue CI * first stab at continuous integration * fixing testcases and migrations * syncing with master * moving to python version 3.11.7 * making copy of env * updating env * added migrations * added uv sync * updating working directory * added step to activate env * updating working directory * updating working directory for codecov upload * updating script to upload to codecov * remove working directory * added working directory for % check * clenaup * cleanup * activating env * update the issue template * update readme and env file
* getting threads up and running * added testcases and citation * removing ssl verify * using standardized APIResponse * getting rid of redundant files * refactor code after testing * refactor testcases * setting up init.py * fixing review comments * cleanup * cleanup * removed validate thread as it can be handled by default * fixing few code review suggestions * removed validation testcases for assistant ID
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
|
|
||
|
|
||
| def upgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this?
|
|
||
|
|
||
| def downgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check other comments too
| dependencies=[Depends(get_current_active_superuser)], | ||
| response_model=APIResponse[CredsPublic], | ||
| ) | ||
| def create_new_credential(*, session: SessionDep, creds_in: CredsCreate): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As more than one credentials will be added then we should have another column like name or something it separate multiple credentials like OpenAI, Gemini. Might as well add description Column as well
| sa.ForeignKeyConstraint( | ||
| ["organization_id"], ["organization.id"], ondelete="CASCADE" | ||
| ), | ||
| sa.PrimaryKeyConstraint("id"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also add inserted_at and updated_at column
* Update README.md (ProjectTech4DevAI#44) * changes (ProjectTech4DevAI#45) * Readme update (ProjectTech4DevAI#47) rename project and stack --------- Co-authored-by: sourabhlodha <sourabhlodha@Administrators-MacBook-Pro.local> * fix create_user endpoint (ProjectTech4DevAI#62) * standard api response and http exception handling (ProjectTech4DevAI#67) * Upgrade PostgreSQL to 16 & Fix CORS Configuration (ProjectTech4DevAI#57) * use latest docker image * update envsample * Add Customizable Token Expiry Time in Login API (ProjectTech4DevAI#70) * token expiry time can be customize * default to one day * Organization/project : Crud, Endpoint and Test Cases (ProjectTech4DevAI#63) * trial * pushing all * models file * renaming * Rename Project.py to project.py * Rename oganization.py to organization.py * Update README.md (ProjectTech4DevAI#44) * changes (ProjectTech4DevAI#45) Co-authored-by: sourabhlodha <sourabhlodha@Administrators-MacBook-Pro.local> * Readme update (ProjectTech4DevAI#47) rename project and stack --------- Co-authored-by: sourabhlodha <sourabhlodha@Administrators-MacBook-Pro.local> * fix create_user endpoint (ProjectTech4DevAI#62) * standard api response and http exception handling (ProjectTech4DevAI#67) * standardization and edits * small edits * small edits * small edits * fixed project post * trial * pushing all * models file * renaming * Rename Project.py to project.py * Rename oganization.py to organization.py * standardization and edits * small edits * small edits * small edits * fixed project post * remove these files since they were somehow pushed into this branch * re-push the docker file * re-push utils file * re-push the file * fixing test cases --------- Co-authored-by: Sourabh Lodha <sourabh_lodha@ymail.com> Co-authored-by: sourabhlodha <sourabhlodha@Administrators-MacBook-Pro.local> Co-authored-by: Aviraj Gour <100823015+avirajsingh7@users.noreply.github.com> Co-authored-by: Ishankoradia <ikoradia@umich.edu> * Add Project User Management (ProjectTech4DevAI#65) * intial commit user project mapping and authorization * fix alembic migration * Use standard API response * add pagination * add index and use base model * Alembic: migration fixes for organization (ProjectTech4DevAI#77) * fixing testcases and migrations * changes migration file name * remove old migration --------- Co-authored-by: Akhilesh Negi <akhileshnegi.an3@gmail.com> * Added Support of API Key Authentication (ProjectTech4DevAI#76) * Intial setup api key * added Api key auth flow * support both api key and oauth --------- Co-authored-by: Sourabh Lodha <sourabh_lodha@ymail.com> * Main to stage code sync (ProjectTech4DevAI#80) Back merge Production to staging code * added migration for api table (ProjectTech4DevAI#81) * creds table * Refactor Authentication Logic and Testing Enhancements (ProjectTech4DevAI#89) * fix authentication part * Modify test cases to compatible with new auth * Github: CI (ProjectTech4DevAI#74) * issue CI * first stab at continuous integration * fixing testcases and migrations * syncing with master * moving to python version 3.11.7 * making copy of env * updating env * added migrations * added uv sync * updating working directory * added step to activate env * updating working directory * updating working directory for codecov upload * updating script to upload to codecov * remove working directory * added working directory for % check * clenaup * cleanup * activating env * update the issue template * update readme and env file * adding badges (ProjectTech4DevAI#91) * OpenAI: Threads (ProjectTech4DevAI#40) * getting threads up and running * added testcases and citation * removing ssl verify * using standardized APIResponse * getting rid of redundant files * refactor code after testing * refactor testcases * setting up init.py * fixing review comments * cleanup * cleanup * removed validate thread as it can be handled by default * fixing few code review suggestions * removed validation testcases for assistant ID * threads testcases fix (ProjectTech4DevAI#93) * project router changes * endpoint,crud and migration file * models file * minor fix * fixes * fixes * test cases and fixes * alembic file * type checking * cleaner exception * fixing alembic revision heads * using crendentials * init module * running pre commit * running pre commit * final changes * migration file * Rename fa868aa8debd_add_credetial_table.py to fa868aa8debd_add_credential_table.py * test case change * test cases * test cases * test cases * removing duplicate lines * datetime columns addition * migration file --------- Co-authored-by: Sourabh Lodha <sourabh_lodha@ymail.com> Co-authored-by: Aviraj Gour <100823015+avirajsingh7@users.noreply.github.com> Co-authored-by: Akhilesh Negi <akhileshnegi.an3@gmail.com>
Summary
Target issue is #55
#149 will be implemented later on, after this pr is merged. The reason I have kept that implementation for later is because I did not want this pr to become very extensive.
This pull request introduces several key features and updates to the
ai-platformrepository. It primarily focuses on managing organization credentials and API keys, specifically OpenAI keys, on a per-organization basis. The changes include:Database Migration: A new migration script is added to create a 'creds' table in the database. This table is designed to store organization credentials, including fields for organization ID, active status, validity, and JSON credential data.
API Enhancements: A new credentials API router is introduced, providing CRUD operations for managing organization credentials and API keys. Most endpoints are secured with superuser access control.
CRUD Operations: New CRUD operations are implemented for handling organization credentials, including functionalities to set, get, and remove credentials, with specific handling for OpenAI API keys.
Model Definitions: Credential models are defined using SQLModel, supporting JSON storage and organization relationships. The models include base, create, update, and public variants.
Project API Update: A return statement is added to the
delete_projectendpoint to ensure consistency with other API endpoints.CI Workflow Update: An empty line is added to the continuous integration workflow file.
These changes are merged from the
feature/credsbranch into themainbranch, as part of the effort to manage OpenAI keys per organization.This pull request introduces a new feature to the
ai-platformrepository, specifically targeting the management of OpenAI keys per organization. The changes are made on thefeature/credsbranch and are intended to be merged into themainbranch. Key updates include:Continuous Integration Workflow: A new line has been added to the
.github/workflows/continuous_integration.ymlfile to enhance the CI process.Database Migration: A new Alembic migration script (
e08733a76537_create_credentials_table.py) is added to create acredstable. This table includes columns fororganization_id,is_active,valid,id, and credential fields, along with necessary foreign key constraints.API Routes: New routes are introduced in
backend/app/api/routes/credentials.pyto manage credentials. These routes support CRUD operations for API keys and organization credentials, with appropriate access control and error handling. Additionally, a return statement is added to thedelete_projectendpoint inbackend/app/api/routes/project.pyto ensure consistent API response formats.CRUD Operations: The
backend/app/crud/credentials.pyfile now includes CRUD operations for managing organization credentials, focusing on setting, getting, and removing credentials, particularly for API key management.Model System: A new credentials model system is defined in
backend/app/models/credentials.pyusing SQLModel. It includes base, create, update, and public credential classes, with organization relationships and JSON storage capabilities. Thebackend/app/models/organization.pyfile is updated to change the relationship fromapi_keystocreds, maintaining a bidirectional relationship with the Creds model.These changes collectively enhance the platform's ability to manage OpenAI keys on a per-organization basis, improving both functionality and data integrity.
This pull request introduces a new feature to the
ai-platformrepository, specifically targeting the management of OpenAI keys per organization. The changes include:Database Migration: A new Alembic migration script is added to create a
credentialstable. This table includes columns fororganization_id,is_active,valid,id, and credential fields, with appropriate foreign key constraints.API Enhancements: A new API route for credentials management is introduced, providing CRUD operations for organization credentials. This includes handling API key management and implementing superuser access controls.
CRUD Operations: New CRUD functionalities are added for managing credentials, allowing setting, getting, and removing credentials for organizations, with specific handling for OpenAI API keys.
Model Updates: Credential models are introduced using SQLModel, featuring organization relationships and schemas for base, create, update, and public credential management.
Organization Model Update: The existing APIKey relationship in the Organization model is replaced with a Creds relationship, indicating a transition in the authentication mechanism from API keys to a more comprehensive credentials system.
Project API Update: A return statement is added to the
delete_projectendpoint to ensure a consistent API response format.CI Workflow: An empty line is added to the CI workflow file, which does not introduce any functional changes.
These updates collectively enhance the platform's capability to manage credentials at an organizational level, with a focus on OpenAI API key management.
This pull request introduces a new feature to the
ProjectTech4DevAI/ai-platformrepository, specifically targeting the management of OpenAI API keys on a per-organization basis. The changes are made in thefeature/credsbranch and are intended to be merged into themainbranch.Key updates include:
Database Migration: A new Alembic migration script is added to create a
credentialstable. This table includes columns fororganization_id,is_active,valid,id, andcredential, with appropriate foreign key constraints.API Enhancements: A new API route for credentials management is implemented, providing CRUD operations to create, read, update, and delete credentials associated with organizations.
CRUD Operations: The pull request introduces CRUD functionalities in the
credentials.pyfile, allowing for the management of credentials, specifically handling OpenAI API keys.Model Updates:
Credsrelationship, reflecting changes in the authentication system.Project API Consistency: A return statement is added to the
delete_projectendpoint in the project API for improved consistency, although there are noted areas for improvement in error handling and documentation.CI Workflow: An empty line is added to the CI workflow file, which does not introduce any functional changes.
These changes collectively aim to enhance the platform's capability to manage OpenAI API keys at the organizational level, improving both functionality and consistency across the system.
This pull request introduces a new feature to the
ai-platformrepository, specifically targeting the management of OpenAI keys per organization. The changes are made on thefeature/credsbranch and are intended to be merged into themainbranch.Key updates include:
Database Migration: A new Alembic migration script is added to create a
credstable. This table is designed to store organization credentials, including fields fororganization_id,is_activestatus, validity, and JSON credential data.API Enhancements: A new credentials management API is introduced, providing CRUD operations for organization credentials and API keys. This includes endpoints for creating, reading, updating, and deleting credentials.
CRUD Operations: The backend now includes CRUD operations for managing organization credentials, with functions to set, get, remove, and fetch API keys.
Model Updates:
Organizationmodel's relationship withAPIKeyis updated to relate toCreds, maintaining the existing structure but changing the associated entity.Project API Update: A return statement is added to the
delete_projectendpoint to ensure consistency with other endpoints.CI Workflow: An empty line is added to the CI workflow file, which does not have any functional impact.
These changes collectively enhance the platform's ability to manage organization-specific credentials, particularly for OpenAI API keys.