diff --git a/src/api-client.ts b/src/api-client.ts index 99088f2..16b6ecc 100644 --- a/src/api-client.ts +++ b/src/api-client.ts @@ -60,10 +60,7 @@ export class GalileoApiClient { } private async healthCheck(): Promise { - return await this.makeRequest( - RequestMethod.GET, - Routes.healthCheck - ); + return this.makeRequest(RequestMethod.GET, Routes.healthCheck); } private async getToken(): Promise { @@ -90,7 +87,7 @@ export class GalileoApiClient { private async apiKeyLogin( api_key: string ): Promise<{ access_token: string }> { - return await this.makeRequest<{ access_token: string }>( + return this.makeRequest<{ access_token: string }>( RequestMethod.POST, Routes.apiKeyLogin, { @@ -100,7 +97,7 @@ export class GalileoApiClient { } private async usernameLogin(username: string, password: string) { - return await this.makeRequest<{ access_token: string }>( + return this.makeRequest<{ access_token: string }>( RequestMethod.POST, Routes.login, querystring.stringify({ @@ -129,7 +126,7 @@ export class GalileoApiClient { } private async createProject(project_name: string): Promise<{ id: string }> { - return await this.makeRequest<{ id: string }>( + return this.makeRequest<{ id: string }>( RequestMethod.POST, Routes.projects, { diff --git a/src/observe/api-client.ts b/src/observe/api-client.ts index b4d18f6..6da4905 100644 --- a/src/observe/api-client.ts +++ b/src/observe/api-client.ts @@ -20,7 +20,7 @@ export default class GalileoObserveApiClient extends GalileoApiClient { include_chains?: boolean, chain_id?: string ): Promise> { - return await this.makeRequest( + return this.makeRequest( RequestMethod.POST, Routes.observeRows, { @@ -46,7 +46,7 @@ export default class GalileoObserveApiClient extends GalileoApiClient { interval?: number, group_by?: string ): Promise> { - return await this.makeRequest( + return this.makeRequest( RequestMethod.POST, Routes.observeMetrics, { @@ -65,7 +65,7 @@ export default class GalileoObserveApiClient extends GalileoApiClient { public async deleteLoggedData( filters: Array = [] ): Promise> { - return await this.makeRequest(RequestMethod.POST, Routes.observeDelete, { + return this.makeRequest(RequestMethod.POST, Routes.observeDelete, { filters }); } @@ -73,7 +73,7 @@ export default class GalileoObserveApiClient extends GalileoApiClient { public async ingestBatch( transaction_batch: TransactionRecordBatch ): Promise { - return await this.makeRequest( + return this.makeRequest( RequestMethod.POST, Routes.observeIngest, transaction_batch diff --git a/src/observe/callback.ts b/src/observe/callback.ts index 56fe057..5238ed6 100644 --- a/src/observe/callback.ts +++ b/src/observe/callback.ts @@ -83,7 +83,7 @@ export default class GalileoObserveCallback extends BaseCallbackHandler { return [node_id, latency_ms]; } - private async _finalize_node(record: TransactionRecord): Promise { + private _finalize_node(record: TransactionRecord): void { const batch_records: TransactionRecord[] = []; this.records[record.node_id] = record; @@ -104,7 +104,8 @@ export default class GalileoObserveCallback extends BaseCallbackHandler { client_version: version }; - await this.api_client.ingestBatch(transaction_batch); + // fire and forget + this.api_client.ingestBatch(transaction_batch); } } @@ -149,7 +150,7 @@ export default class GalileoObserveCallback extends BaseCallbackHandler { /** * Called if an LLM/ChatModel run encounters an error */ - public async handleLLMError(err: AxiosError, runId: string): Promise { + public handleLLMError(err: AxiosError, runId: string): void { const [node_id, latency_ms] = this._end_node(runId); const record = this.records[node_id]; @@ -158,7 +159,7 @@ export default class GalileoObserveCallback extends BaseCallbackHandler { record.output_text = `ERROR: ${err.message}`; record.latency_ms = latency_ms; - await this._finalize_node(record); + this._finalize_node(record); } /** @@ -225,7 +226,7 @@ export default class GalileoObserveCallback extends BaseCallbackHandler { record.latency_ms = latency_ms; record.status_code = 200; - await this._finalize_node(record); + this._finalize_node(record); } /** @@ -357,7 +358,7 @@ export default class GalileoObserveCallback extends BaseCallbackHandler { /** * Called if a Chain run encounters an error */ - public async handleChainError(err: AxiosError, runId: string): Promise { + public handleChainError(err: AxiosError, runId: string): void { const [node_id, latency_ms] = this._end_node(runId); const record = this.records[node_id]; @@ -366,16 +367,13 @@ export default class GalileoObserveCallback extends BaseCallbackHandler { record.latency_ms = latency_ms; record.status_code = err.response?.status; - await this._finalize_node(record); + this._finalize_node(record); } /** * Called at the end of a Chain run, with the outputs and the run ID. */ - public async handleChainEnd( - outputs: ChainValues, - runId: string - ): Promise { + public handleChainEnd(outputs: ChainValues, runId: string): void { const [node_id, latency_ms] = this._end_node(runId); const record = this.records[node_id]; @@ -384,7 +382,7 @@ export default class GalileoObserveCallback extends BaseCallbackHandler { record.latency_ms = latency_ms; record.status_code = 200; - await this._finalize_node(record); + this._finalize_node(record); } /** @@ -420,7 +418,7 @@ export default class GalileoObserveCallback extends BaseCallbackHandler { /** * Called if a Tool run encounters an error */ - public async handleToolError(err: AxiosError, runId: string): Promise { + public handleToolError(err: AxiosError, runId: string): void { const [node_id, latency_ms] = this._end_node(runId); const record = this.records[node_id]; @@ -428,7 +426,7 @@ export default class GalileoObserveCallback extends BaseCallbackHandler { record.latency_ms = latency_ms; record.status_code = err.response?.status; - await this._finalize_node(record); + this._finalize_node(record); } /** @@ -442,24 +440,21 @@ export default class GalileoObserveCallback extends BaseCallbackHandler { record.latency_ms = latency_ms; record.status_code = 200; - await this._finalize_node(record); + this._finalize_node(record); } /** * Called when an agent finishes execution, before it exits. * with the final output and the run ID. */ - public async handleAgentEnd( - action: AgentFinish | undefined, - runId: string - ): Promise { + public handleAgentEnd(action: AgentFinish | undefined, runId: string): void { const [node_id, latency_ms] = this._end_node(runId); const record = this.records[node_id]; record.latency_ms = latency_ms; record.node_type = StepType.agent; record.status_code = 200; - await this._finalize_node(record); + this._finalize_node(record); } public handleRetrieverStart( @@ -489,10 +484,10 @@ export default class GalileoObserveCallback extends BaseCallbackHandler { }; } - public async handleRetrieverEnd( + public handleRetrieverEnd( documents: DocumentInterface>[], runId: string - ): Promise { + ): void { const [node_id, latency_ms] = this._end_node(runId); const record = this.records[node_id]; const formatted_docs = documents.map((doc) => { @@ -506,19 +501,16 @@ export default class GalileoObserveCallback extends BaseCallbackHandler { record.latency_ms = latency_ms; record.status_code = 200; - await this._finalize_node(record); + this._finalize_node(record); } - public async handleRetrieverError( - err: AxiosError, - runId: string - ): Promise { + public handleRetrieverError(err: AxiosError, runId: string): void { const [node_id, latency_ms] = this._end_node(runId); const record = this.records[node_id]; record.output_text = `ERROR: ${err.message}`; record.latency_ms = latency_ms; record.status_code = err.response?.status; - await this._finalize_node(record); + this._finalize_node(record); } }