feat(agent): add server info in AgentConnected event. (#402)

release-0.2
Zhiming Ma 2023-09-05 15:06:35 +08:00 committed by GitHub
parent a207520571
commit f514e47c2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 29 deletions

View File

@ -3,21 +3,12 @@
"info": {
"title": "Tabby Server",
"description": "\n[![tabby stars](https://img.shields.io/github/stars/TabbyML/tabby?style=social)](https://github.com/TabbyML/tabby)\n\nOpenAPI documentation for [tabby](https://github.com/TabbyML/tabby), a self-hosted AI coding assistant.",
"license": {
"name": "Apache 2.0",
"url": "https://github.com/TabbyML/tabby/blob/main/LICENSE"
},
"license": { "name": "Apache 2.0", "url": "https://github.com/TabbyML/tabby/blob/main/LICENSE" },
"version": "0.1.0"
},
"servers": [
{
"url": "https://playground.app.tabbyml.com",
"description": "Playground server"
},
{
"url": "http://localhost:8080",
"description": "Local server"
}
{ "url": "https://playground.app.tabbyml.com", "description": "Playground server" },
{ "url": "http://localhost:8080", "description": "Local server" }
],
"paths": {
"/v1/completions": {
@ -25,13 +16,7 @@
"tags": ["v1"],
"operationId": "completion",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CompletionRequest"
}
}
},
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/CompletionRequest" } } },
"required": true
},
"responses": {
@ -105,14 +90,16 @@
},
"HealthState": {
"type": "object",
"required": ["model", "device", "compute_type", "arch", "cpu_info", "cpu_count"],
"required": ["model", "device", "compute_type", "arch", "cpu_info", "cpu_count", "cuda_devices", "version"],
"properties": {
"model": { "type": "string" },
"device": { "type": "string" },
"compute_type": { "type": "string" },
"arch": { "type": "string" },
"cpu_info": { "type": "string" },
"cpu_count": { "type": "integer", "minimum": 0.0 }
"cpu_count": { "type": "integer", "minimum": 0.0 },
"cuda_devices": { "type": "array", "items": { "type": "string" } },
"version": { "$ref": "#/components/schemas/Version" }
}
},
"LogEventRequest": {
@ -135,6 +122,16 @@
"nullable": true
}
}
},
"Version": {
"type": "object",
"required": ["build_date", "build_timestamp", "git_sha", "git_describe"],
"properties": {
"build_date": { "type": "string" },
"build_timestamp": { "type": "string" },
"git_sha": { "type": "string" },
"git_describe": { "type": "string" }
}
}
}
}

View File

@ -70,6 +70,9 @@ export class AnonymousUsageLogger {
if (unique && this.emittedUniqueEvent.indexOf(event) >= 0) {
return;
}
if (unique) {
this.emittedUniqueEvent.push(event);
}
await this.anonymousUsageTrackingApi.api
.usage({
distinctId: this.anonymousId,
@ -80,11 +83,6 @@ export class AnonymousUsageLogger {
...data,
},
})
.then(() => {
if (unique) {
this.emittedUniqueEvent.push(event);
}
})
.catch((error) => {
this.logger.error({ error }, "Error when sending anonymous usage data");
});

View File

@ -120,9 +120,6 @@ export class TabbyAgent extends EventEmitter implements Agent {
if (this.status === "unauthorized") {
this.emitAuthRequired();
}
if (this.status == "ready") {
this.anonymousUsageLogger.uniqueEvent("AgentConnected");
}
}
}
@ -257,6 +254,9 @@ export class TabbyAgent extends EventEmitter implements Agent {
return this.callApi(this.api.v1.health, {})
.then((healthState) => {
this.serverHealthState = healthState;
if (this.status === "ready") {
this.anonymousUsageLogger.uniqueEvent("AgentConnected", healthState);
}
})
.catch(() => {});
}