(cls, *args, **kwargs)
| 176 | |
| 177 | @classmethod |
| 178 | async def create(cls, *args, **kwargs): |
| 179 | specialized_model_id = None |
| 180 | _ai_model_list = [] |
| 181 | if args[3]: |
| 182 | if args[1]: |
| 183 | ws_id = args[1].oid |
| 184 | _ai_model_list = get_ai_model_list_by_workspace(args[0], ws_id) |
| 185 | if args[3].enable_custom_model: |
| 186 | if args[3].custom_model: |
| 187 | if any(str(model.id) == str(args[3].custom_model) for model in _ai_model_list): |
| 188 | specialized_model_id = args[3].custom_model |
| 189 | print("use custom model: id[" + specialized_model_id + "]") |
| 190 | config: LLMConfig = await get_default_config(specialized_model_id) |
| 191 | instance = cls(*args, **kwargs, config=config) |
| 192 | |
| 193 | chat_params: list[SysArgModel] = await get_groups(args[0], "chat") |
| 194 | for config in chat_params: |
| 195 | if config.pkey == 'chat.sqlbot_name': |
| 196 | if config.pval.strip(): |
| 197 | instance.chat_question.sqlbot_name = config.pval |
| 198 | if config.pkey == 'chat.limit_rows': |
| 199 | if config.pval.lower().strip() == 'true': |
| 200 | instance.enable_sql_row_limit = True |
| 201 | else: |
| 202 | instance.enable_sql_row_limit = False |
| 203 | if config.pkey == 'chat.context_record_count': |
| 204 | count_value = config.pval |
| 205 | if count_value is None: |
| 206 | count_value = settings.GENERATE_SQL_QUERY_HISTORY_ROUND_COUNT |
| 207 | count_value = int(count_value) |
| 208 | if count_value < 0: |
| 209 | count_value = 0 |
| 210 | instance.base_message_round_count_limit = count_value |
| 211 | return instance |
| 212 | |
| 213 | def is_running(self, timeout=0.5): |
| 214 | try: |
nothing calls this directly
no test coverage detected