API接口调用超时问题

Offen
#1,288 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Muss geklärt werden
Aktivitätsstatus
Aktiv
Tech-Stack
java, javascript, openapi
Bereich
api, backend

Rechercherichtung

Beginnen Sie mit dem Java-AIFAQController-Beispiel und verfolgen Sie die Aufrufkette über /api/v1/system/assistant/ds sowie die Datenquellen-Endpunkte /api/v1/datasource/get/{id}, tableList/{id} und fieldList/{id}. Reproduzieren Sie den Timeout bei SQLBot 1.10.0 Community, das in Docker ausgeführt wird, und ermitteln Sie anschließend, ob das Verhalten ein Fehler oder eine dokumentierte Einschränkung der Community Edition ist; die Aufgabe ist abgeschlossen, sobald die Ursache und das unterstützte Verhalten festgestellt sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Done feature

版本:1.10.0 社区版,通过docker运行

问题描述:
SQLBot小助手高级应用设置中,我在获取高级应用 API 接口 的服务里,回调SQLBot的OpenAPI接口(/api/v1/datasource/get/{id} /api/v1/datasource/tableList/{id} /api/v1/datasource/fieldList/{id})获取数据源信息并拼接返回结果,会报读超时错误。

以下为请求路径图:

Image

以下为界面效果图:

Image

以下为java服务接口代码块

@RestController
@RequestMapping("/ai/faq")
@Slf4j
public class AIFAQController {

	@Autowired
	private SQLBotService sqlBotService;

	/**
	 * @see "https://sqlbot.org/docs/v1/embedding_integration/#24-api"
	 */
	@GetMapping(value = "/sqlbot/datasource")
	public ResponseEntity<RespEntity<JSONArray>> sqlbotDatasource( @RequestParam Map<String, Object> params ) {
		return R.data( getExample() );
	}

	public JSONArray getExample() {
		JSONObject requestBody = new JSONObject();
		requestBody.put( "fieldName", "" );
		JSONObject sqlbotDs = sqlBotService.post( "/api/v1/datasource/get/1", JSONObject.class );
		JSONArray dataArray = new JSONArray();
		// 数据源对象
		JSONObject dataSource = new JSONObject();
		// 数据库IP | 类型:string
		dataSource.put( "name", sqlbotDs.getString( "name" ) );
		// 数据库种类 | 类型:string
		dataSource.put( "type", sqlbotDs.getString( "type" ) );
		// 数据库IP | 类型:string
		dataSource.put( "host", "127.0.0.1" );
		// 数据库开放的端口 | 类型:integer(int32)
		dataSource.put( "port", 3306 );
		// 数据库用户名 | 类型:string
		dataSource.put( "user", "root" );
		// 数据库密码 | 类型:string
		dataSource.put( "password", "root" );
		// 数据库内的库名 | 类型:string
		dataSource.put( "dataBase", "saa_data_agent_product" );
		// 数据库模式,部分数据库会有 | 类型:string
		dataSource.put( "schema", "schema" );
		// 针对数据源的描述,可在数据源处查看编辑,详细的描述可以帮助 SQLBot 生成答案 | 类型:string
		dataSource.put( "comment", sqlbotDs.getString( "description" ) );
		JSONArray sqlbotTables = sqlBotService.post( "/api/v1/datasource/tableList/1", JSONArray.class );
		// tables数组
		JSONArray tablesArray = new JSONArray();
		for ( int i = 0; i < sqlbotTables.size(); i++ ) {
			JSONObject sqlbotTable = sqlbotTables.getJSONObject( i );
			if ( sqlbotTable.getBoolean( "checked" ) ) {
				JSONObject table = new JSONObject();
				// 构建数据集的数据表名称 | 类型:string
				table.put( "name", sqlbotTable.getString( "table_name" ) );
				// 数据集的名字,详细的以及和问题相关的描述也能够帮助 SQLBot 生成答案 | 类型:string
				table.put( "comment", sqlbotTable.getString( "custom_comment" ) );
				// DataEase 无具体赋值 在 SQLBot 中该该字段会传值给 AiModelQuestion类,帮助 AI 以字段内容规定回答格式 | 类型:string
				table.put( "rule", "" );
				JSONArray sqlbotFields = sqlBotService.post( "/api/v1/datasource/fieldList/" + sqlbotTable.getString( "id" ),
						JSONArray.class, requestBody );
				JSONArray fields = new JSONArray();
				for ( int j = 0; j < sqlbotFields.size(); j++ ) {
					JSONObject sqlbotField = sqlbotFields.getJSONObject( j );
					if ( sqlbotField.getBoolean( "checked" ) ) {
						JSONObject field = new JSONObject();
						// 字段名 | 类型:string
						field.put( "name", sqlbotField.getString( "field_name" ) );
						// 字段的数据类型 | 类型:string
						field.put( "type", sqlbotField.getString( "field_type" ) );
						// 字段描述 | 类型:string
						field.put( "comment", sqlbotField.getString( "custom_comment" ) );
						fields.add( field );
					}
				}
				table.put( "fields", fields );
				tablesArray.add( table );
			}
		}
		dataSource.put( "tables", tablesArray );
		dataArray.add( dataSource );
		return dataArray;
	}
}

以下是我个人初步原因分析:
1、sqlbot接口/api/v1/system/assistant/ds调用我的服务接口,而我的服务接口又调用SQLBot的数据源接口,由读超时判断SQLBot的API接口是单线程同步阻塞的,因为/api/v1/system/assistant/ds接口未执行完,导致我的接口服务调用SQLBot的接口就一直卡着
2、此问题是BUG还是因为社区版本的限制?

Vorherrschende Sprache
JavaScript
Sterne
6.8k
Forks
882
Ø Merge
4 Std. 41 Min.
Gemergte PRs (30 T.)
35

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus dataease/SQLBot

Alle Issues in dataease/SQLBot

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.