(natural_language_query)
| 450 | } |
| 451 | |
| 452 | const getTables = async (natural_language_query) => { |
| 453 | setIsGetTablesLoading(true) |
| 454 | |
| 455 | let requestBody = { |
| 456 | natural_language_query, |
| 457 | scope: props.version === 'San Francisco' ? 'SF' : 'USA', |
| 458 | session_id: sessionId, |
| 459 | } |
| 460 | |
| 461 | const options = { |
| 462 | method: 'POST', |
| 463 | headers: { 'content-type': 'application/json' }, |
| 464 | body: JSON.stringify(requestBody), |
| 465 | } |
| 466 | |
| 467 | const response = await fetch(api_endpoint + '/api/get_tables', options) |
| 468 | const response_1 = await response.json() |
| 469 | setIsGetTablesLoading(false) |
| 470 | |
| 471 | try { |
| 472 | if (response_1?.generation_id) { |
| 473 | currentGenerationId = response_1.generation_id |
| 474 | } |
| 475 | } catch { |
| 476 | //do nothing |
| 477 | } |
| 478 | |
| 479 | if (!response_1 || !response_1.table_names) { |
| 480 | setTableNames() |
| 481 | capturePosthog('getTables_backend_error', response_1) |
| 482 | setErrorMessage( |
| 483 | 'Something went wrong. Please try again or try a different query' |
| 484 | ) |
| 485 | return false |
| 486 | } |
| 487 | if (response_1.table_names.length === 0) { |
| 488 | setShowExplanationModal('no_tables') |
| 489 | return false |
| 490 | } |
| 491 | |
| 492 | capturePosthog('getTables_backend_response', response_1) |
| 493 | setTableNames(response_1.table_names) |
| 494 | return response_1.table_names |
| 495 | } |
| 496 | |
| 497 | const handleClickExample = async (natural_language_query) => { |
| 498 | setSearchParams( |
no test coverage detected