diff --git a/backend/open_webui/apps/webui/routers/evaluations.py b/backend/open_webui/apps/webui/routers/evaluations.py
index 9a6845efa..b9e3bff29 100644
--- a/backend/open_webui/apps/webui/routers/evaluations.py
+++ b/backend/open_webui/apps/webui/routers/evaluations.py
@@ -5,6 +5,7 @@ from pydantic import BaseModel
from open_webui.apps.webui.models.users import Users, UserModel
from open_webui.apps.webui.models.feedbacks import (
FeedbackModel,
+ FeedbackResponse,
FeedbackForm,
Feedbacks,
)
@@ -55,27 +56,15 @@ async def update_config(
}
-@router.get("/feedbacks", response_model=list[FeedbackModel])
-async def get_feedbacks(user=Depends(get_verified_user)):
- feedbacks = Feedbacks.get_feedbacks_by_user_id(user.id)
- return feedbacks
-
-
-@router.delete("/feedbacks", response_model=bool)
-async def delete_feedbacks(user=Depends(get_verified_user)):
- success = Feedbacks.delete_feedbacks_by_user_id(user.id)
- return success
-
-
-class FeedbackUserModel(FeedbackModel):
+class FeedbackUserResponse(FeedbackResponse):
user: Optional[UserModel] = None
-@router.get("/feedbacks/all", response_model=list[FeedbackUserModel])
+@router.get("/feedbacks/all", response_model=list[FeedbackUserResponse])
async def get_all_feedbacks(user=Depends(get_admin_user)):
feedbacks = Feedbacks.get_all_feedbacks()
return [
- FeedbackUserModel(
+ FeedbackUserResponse(
**feedback.model_dump(), user=Users.get_user_by_id(feedback.user_id)
)
for feedback in feedbacks
@@ -88,6 +77,29 @@ async def delete_all_feedbacks(user=Depends(get_admin_user)):
return success
+@router.get("/feedbacks/all/export", response_model=list[FeedbackModel])
+async def get_all_feedbacks(user=Depends(get_admin_user)):
+ feedbacks = Feedbacks.get_all_feedbacks()
+ return [
+ FeedbackModel(
+ **feedback.model_dump(), user=Users.get_user_by_id(feedback.user_id)
+ )
+ for feedback in feedbacks
+ ]
+
+
+@router.get("/feedbacks/user", response_model=list[FeedbackUserResponse])
+async def get_feedbacks(user=Depends(get_verified_user)):
+ feedbacks = Feedbacks.get_feedbacks_by_user_id(user.id)
+ return feedbacks
+
+
+@router.delete("/feedbacks", response_model=bool)
+async def delete_feedbacks(user=Depends(get_verified_user)):
+ success = Feedbacks.delete_feedbacks_by_user_id(user.id)
+ return success
+
+
@router.post("/feedback", response_model=FeedbackModel)
async def create_feedback(
request: Request,
diff --git a/src/lib/apis/evaluations/index.ts b/src/lib/apis/evaluations/index.ts
index 854b3abb8..f6f35f7c1 100644
--- a/src/lib/apis/evaluations/index.ts
+++ b/src/lib/apis/evaluations/index.ts
@@ -93,6 +93,37 @@ export const getAllFeedbacks = async (token: string = '') => {
return res;
};
+export const exportAllFeedbacks = async (token: string = '') => {
+ let error = null;
+
+ const res = await fetch(`${WEBUI_API_BASE_URL}/evaluations/feedbacks/all/export`, {
+ method: 'GET',
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ authorization: `Bearer ${token}`
+ }
+ })
+ .then(async (res) => {
+ if (!res.ok) throw await res.json();
+ return res.json();
+ })
+ .then((json) => {
+ return json;
+ })
+ .catch((err) => {
+ error = err.detail;
+ console.log(err);
+ return null;
+ });
+
+ if (error) {
+ throw error;
+ }
+
+ return res;
+};
+
export const createNewFeedback = async (token: string, feedback: object) => {
let error = null;
diff --git a/src/lib/components/admin/Evaluations.svelte b/src/lib/components/admin/Evaluations.svelte
index 5407a09d8..4632238f0 100644
--- a/src/lib/components/admin/Evaluations.svelte
+++ b/src/lib/components/admin/Evaluations.svelte
@@ -1,4 +1,7 @@
+
+