API for admin is needed
Self Checks
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to file this report (我已阅读并同意 Language Policy).
1. Is this request related to a challenge you're experiencing?
Some one would have the request,that summarize all the apps in studio from an admin api,and then he could do something with theme,for example,analyze,or a list select for frontend,etc.
2. Describe the feature you'd like to see
A full api for admin use,analyze or for another app use
3. How will this feature improve your workflow or experience?
This can better enhance the collaboration between dify project and the customer's own existing applications
4. Additional context or comments
No response
5. Can you help us with this feature?
- [ ] I am interested in contributing to this feature.
🤖
Hi there, @vkiller! Good to see you here again. 😊
Thank you for your feature request. Adding an admin API for summarizing and analyzing all apps in the studio is indeed a valuable addition to the dify project.
Based on the current structure of the dify API, there are already existing admin endpoints as indicated by the import statement from . import admin in the console controllers. However, without the content of the admin module, it's hard to provide more specific details about the admin endpoints.
Here's a simple example of how you can add an admin API that fetches all apps from the database and returns the necessary information:
class AdminAppListApi(Resource):
@login_required
@account_initialization_required
@marshal_with(app_fields) # use the same app_fields defined earlier
def get(self):
# Check if the current user is an admin
if current_user.role not in ['owner', 'admin']:
return {'message': 'Unauthorized'}, 401
# Fetch all apps from the database
all_apps = db.session.query(App).all()
# Return the apps
return {'apps': all_apps}
api.add_resource(AdminAppListApi, '/admin/apps')
This new AdminAppListApi class defines a GET method that fetches all apps from the database and returns them. The @login_required and @account_initialization_required decorators ensure that the user is logged in and their account is initialized. The @marshal_with(app_fields) decorator is used to format the output according to the app_fields dictionary defined earlier.
The if current_user.role not in ['owner', 'admin']: check ensures that only users with the role 'owner' or 'admin' can access this endpoint. If the user is not an admin, a message 'Unauthorized' is returned with a 401 status code.
Finally, the api.add_resource(AdminAppListApi, '/admin/apps') line adds this new API endpoint to the application under the path '/admin/apps'.
Please note that this is a basic example and might need to be adjusted to fit your specific needs. For example, you might want to add more information to the app_fields dictionary or add more checks to ensure that the user has the necessary permissions to access this endpoint.
You can find more information about the current structure of the dify API in the api/controllers/console/init.py file.
I hope this helps! If you have any further questions or need more clarification, feel free to ask.
Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
Yes, that's how to implement it.Just like Chat App API http://localhost/v1,user also need an admin api http://localhost/admin/v1 for summarizing and analyzing studio things, this allows for closer integration with user his own applications.hope official plan and roadmap for this.
Not planning on that for now, currently we support using JWT to access the console's API as a temporary solution. Also, could you elaborate more on your use case?
We have a customer who is a leader in a certain industry. They have a series of applications of their own. They currently plan to use AI Agent to make a series of applications as enhancements to the original applications. We are considering using dify framework technology of differentiate as a support for AI Agent capabilities. This is When it comes to integrating two sets of applications, the above requirements naturally arise.
We've aligned internally, and it looks like Console OpenAPI might start design & development around March. 😄
Close due to it's no longer active, if you have any questions, you can reopen it.
We've aligned internally, and it looks like Console OpenAPI might start design & development around March. 😄
any process about this? @takatost ,it seems closed automatically.