Skip to content

feat: add knowledge_ids field to ApplicationVersion and populate from ResourceMapping - #6533

Merged
liuruibin merged 1 commit into
v2from
pr@v2@feat_add_knowledge_ids_fieldv2
Jul 29, 2026
Merged

feat: add knowledge_ids field to ApplicationVersion and populate from ResourceMapping#6533
liuruibin merged 1 commit into
v2from
pr@v2@feat_add_knowledge_ids_fieldv2

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

feat: add knowledge_ids field to ApplicationVersion and populate from ResourceMapping

Copilot AI review requested due to automatic review settings July 29, 2026 03:30
@shaohuzhang1

Copy link
Copy Markdown
Contributor Author

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a persisted knowledge_ids list onto ApplicationVersion so simple-app chats can read the knowledge-base bindings from the latest published version instead of querying ResourceMapping at runtime (except in debug mode).

Changes:

  • Added knowledge_ids JSONField to ApplicationVersion plus a data migration to backfill it from ResourceMapping for existing SIMPLE applications.
  • Updated application publishing to populate knowledge_ids on newly created ApplicationVersion records.
  • Updated chat open/reopen and ChatInfo.get_application() to prefer ApplicationVersion.knowledge_ids when not debugging.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
apps/chat/serializers/chat.py Uses latest ApplicationVersion.knowledge_ids for SIMPLE chat open/reopen when not in debug.
apps/application/serializers/common.py Updates SIMPLE ChatInfo loading to source knowledge IDs from ApplicationVersion when not debugging.
apps/application/serializers/application.py Populates ApplicationVersion.knowledge_ids on publish for SIMPLE applications.
apps/application/models/application.py Adds knowledge_ids field to ApplicationVersion model.
apps/application/migrations/0014_applicationversion_knowledge_ids.py Adds schema + backfills knowledge_ids from ResourceMapping.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +505 to +507
application_version = QuerySet(ApplicationVersion).filter(application_id=application.id).order_by(
'-create_time')[0:1].first()
knowledge_id_list = application_version.knowledge_ids
Comment on lines +32 to +44
updates = []
for obj in ApplicationVersion.objects.using(db_alias).iterator():
app_id = str(obj.application_id)
if app_id not in simple_application_ids:
continue
knowledge_ids = mapping.get(app_id)
if knowledge_ids:
obj.knowledge_ids = knowledge_ids
updates.append(obj)
if updates:
ApplicationVersion.objects.using(db_alias).bulk_update(
updates, ["knowledge_ids"], batch_size=500
)
Comment on lines +1275 to +1280
work_flow_version.knowledge_ids = [
str(row.target_id)
for row in QuerySet(ResourceMapping).filter(
source_id=str(application.id), source_type="APPLICATION", target_type="KNOWLEDGE"
)
]
@liuruibin
liuruibin merged commit bcd930c into v2 Jul 29, 2026
5 of 7 checks passed
@liuruibin
liuruibin deleted the pr@v2@feat_add_knowledge_ids_fieldv2 branch July 29, 2026 04:32
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.

4 participants