MCPcopy Index your code
hub / github.com/caesarHQ/textSQL / getSuggestionForFailedQuery

Function getSuggestionForFailedQuery

client/censusGPT/src/App.js:183–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

181 }
182
183 const getSuggestionForFailedQuery = async () => {
184 currentSuggestionId = null
185 const options = {
186 method: 'POST',
187 headers: { 'content-type': 'application/json' },
188 body: JSON.stringify({
189 natural_language_query: query,
190 scope: props.version === 'San Francisco' ? 'SF' : 'USA',
191 generation_id: currentGenerationId,
192 session_id: sessionId,
193 }),
194 }
195
196 fetch(api_endpoint + '/api/get_suggestion_failed_query', options)
197 .then((response) => response.json())
198 .then((response) => {
199 // Handle errors
200 if (!response || !response.suggested_query) {
201 capturePosthog('backend_error', response)
202 return
203 }
204
205 // Capture the response in posthog
206 capturePosthog('backend_response', {
207 origin: 'get_suggestion_failed_query',
208 })
209 // Set the state for SQL and Status Code
210 if (response.generation_id)
211 currentSuggestionId = response.generation_id
212
213 setSuggestedQuery(response.suggested_query)
214 })
215 .catch((err) => {
216 logSentryError({ query }, err)
217 setIsLoading(false)
218 capturePosthog('backend_error', {
219 error: err,
220 })
221 console.error(err)
222 })
223 }
224
225 const getSuggestionForQuery = async () => {
226 currentSuggestionId = null

Callers 1

fetchBackendFunction · 0.85

Calls 2

capturePosthogFunction · 0.90
logSentryErrorFunction · 0.90

Tested by

no test coverage detected