MCPcopy
hub / github.com/1Panel-dev/MaxKB / get_application

Method get_application

apps/application/serializers/common.py:144–169  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

142 return no_references_setting
143
144 def get_application(self):
145 if self.debug:
146 application = QuerySet(Application).filter(id=self.application_id).first()
147 if not application:
148 raise ChatException(500, _('The application does not exist'))
149 else:
150 application = QuerySet(ApplicationVersion).filter(application_id=self.application_id).order_by(
151 '-create_time')[0:1].first()
152 if not application:
153 raise ChatException(500, _("The application has not been published. Please use it after publishing."))
154 if application.type == ApplicationTypeChoices.SIMPLE.value:
155 # 数据集id列表
156 knowledge_id_list = [str(row.target_id) for row in
157 QuerySet(ResourceMapping).filter(source_id=self.application_id,
158 source_type='APPLICATION',
159 target_type='KNOWLEDGE')]
160
161 # 需要排除的文档
162 exclude_document_id_list = [str(document.id) for document in
163 QuerySet(Document).filter(
164 knowledge_id__in=knowledge_id_list,
165 is_active=False)]
166 self.knowledge_id_list = knowledge_id_list
167 self.exclude_document_id_list = exclude_document_id_list
168 self.application = application
169 return application
170
171 def get_chat_user(self, asker=None):
172 if self.chat_user:

Callers 2

chatMethod · 0.80

Calls 1

ChatExceptionClass · 0.90

Tested by

no test coverage detected