Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

feat: replace the end user column in the web page Log & Ann. with the… (#653)

TheFu52794b54b7ca957
diff --git a/api/controllers/console/app/conversation.py b/api/controllers/console/app/conversation.py
index 2d4762d5d42..5727c84a520 100644
--- a/api/controllers/console/app/conversation.py
+++ b/api/controllers/console/app/conversation.py
@@ -95,6 +95,7 @@ class CompletionConversationApi(Resource):
'status': fields.String,
'from_source': fields.String,
'from_end_user_id': fields.String,
+ 'from_end_user_session_id': fields.String(attribute='end_user.session_id'),
'from_account_id': fields.String,
'read_at': TimestampField,
'created_at': TimestampField,
@@ -135,6 +136,8 @@ class CompletionConversationApi(Resource):
query = db.select(Conversation).where(Conversation.app_id == app.id, Conversation.mode == 'completion')
+ query = query.options(joinedload(Conversation.end_user))
+
if args['keyword']:
query = query.join(
Message, Message.conversation_id == Conversation.id
@@ -246,6 +249,7 @@ class ChatConversationApi(Resource):
'status': fields.String,
'from_source': fields.String,
'from_end_user_id': fields.String,
+ 'from_end_user_session_id': fields.String(attribute='end_user.session_id'),
'from_account_id': fields.String,
'summary': fields.String(attribute='summary_or_query'),
'read_at': TimestampField,
@@ -288,6 +292,8 @@ class ChatConversationApi(Resource):
query = db.select(Conversation).where(Conversation.app_id == app.id, Conversation.mode == 'chat')
+ query = query.options(joinedload(Conversation.end_user))
+
if args['keyword']:
query = query.join(
Message, Message.conversation_id == Conversation.id
diff --git a/api/models/model.py b/api/models/model.py
index 7b3ba2745b5..468233cd115 100644
--- a/api/models/model.py
+++ b/api/models/model.py
@@ -203,7 +203,7 @@ class Conversation(db.Model):
system_instruction_tokens = db.Column(db.Integer, nullable=False, server_default=db.text('0'))
status = db.Column(db.String(255), nullable=False)
from_source = db.Column(db.String(255), nullable=False)
- from_end_user_id = db.Column(UUID)
+ from_end_user_id = db.Column(UUID, db.ForeignKey('end_users.id'))
from_account_id = db.Column(UUID)
read_at = db.Column(db.DateTime)
read_account_id = db.Column(UUID)
@@ -213,6 +213,8 @@ class Conversation(db.Model):
messages = db.relationship("Message", backref="conversation", lazy='select', passive_deletes="all")
message_annotations = db.relationship("MessageAnnotation", backref="conversation", lazy='select', passive_deletes="all")
+ end_user = db.relationship("EndUser", backref="conversations")
+
is_deleted = db.Column(db.Boolean, nullable=False, server_default=db.text('false'))
@property
diff --git a/web/app/components/app/log/list.tsx b/web/app/components/app/log/list.tsx
index 4fb7a13b250..bfc545af529 100644
--- a/web/app/components/app/log/list.tsx
+++ b/web/app/components/app/log/list.tsx
@@ -412,7 +412,7 @@ const ConversationList: FC<IConversationList> = ({ logs, appDetail, onRefresh })
</thead>
<tbody className="text-gray-500">
{logs.data.map((log) => {
- const endUser = log.from_end_user_id?.slice(0, 8)
+ const endUser = log.from_end_user_session_id
const leftValue = get(log, isChatMode ? 'summary' : 'message.query')
const rightValue = get(log, isChatMode ? 'message_count' : 'message.answer')
return <tr
diff --git a/web/models/log.ts b/web/models/log.ts
index 9f915a3313e..3e2d86be426 100644
--- a/web/models/log.ts
+++ b/web/models/log.ts
@@ -79,6 +79,7 @@ export type CompletionConversationGeneralDetail = {
status: 'normal' | 'finished'
from_source: 'api' | 'console'
from_end_user_id: string
+ from_end_user_session_id: string
from_account_id: string
read_at: Date
created_at: number