a little logging and formatting cleanup

This commit is contained in:
Rob Colbert 2026-05-19 15:42:48 -04:00
parent 70ad578425
commit 00e2fdfa4f

View File

@ -8,7 +8,12 @@ import { RecursiveCharacterTextSplitter } from "@langchain/textsplitters";
import env from "../config/env.js";
import { DtpService } from "../lib/service.js";
import { ChatTurnStatus } from "@gadget/api";
import { createAiApi, IAiEnvironment, IAiProvider as IAiApiProvider, AiApi } from "@gadget/ai";
import {
createAiApi,
IAiEnvironment,
IAiProvider as IAiApiProvider,
AiApi,
} from "@gadget/ai";
import ChatTurn from "../models/chat-turn.js";
import AiProvider from "../models/ai-provider.js";
import { ChatSessionService } from "./index.js";
@ -61,11 +66,20 @@ class VectorStoreService extends DtpService {
if (!env.qdrant.providerId) {
this.log.warn(
"qdrant.providerId is not configured — vector store service will not start. " +
"Set providerId in gadget-code.yaml under qdrant to enable semantic search."
"Set providerId in gadget-code.yaml under qdrant to enable semantic search.",
);
return;
}
this.log.info("initializing Qdrant client", {
host: env.qdrant.host,
port: env.qdrant.port,
collection: env.qdrant.collection,
providerId: env.qdrant.providerId,
embeddingModel: env.qdrant.embeddingModel,
vectorSize: env.qdrant.vectorSize,
});
// Initialize Qdrant client
this.client = new QdrantClient({
url: `http://${env.qdrant.host}:${env.qdrant.port}`,
@ -77,7 +91,7 @@ class VectorStoreService extends DtpService {
if (!providerDoc) {
this.log.error(
`Qdrant providerId "${env.qdrant.providerId}" not found in database — ` +
"vector store service will not start."
"vector store service will not start.",
);
return;
}
@ -144,7 +158,9 @@ class VectorStoreService extends DtpService {
distance: "Cosine",
});
} else {
this.log.info(`Qdrant collection "${env.qdrant.collection}" already exists`);
this.log.info(
`Qdrant collection "${env.qdrant.collection}" already exists`,
);
}
}
@ -152,7 +168,10 @@ class VectorStoreService extends DtpService {
* Generate an embedding vector for the given text.
*/
private async getEmbedding(text: string): Promise<number[]> {
const response = await this.aiApi.embeddings(env.qdrant.embeddingModel, text);
const response = await this.aiApi.embeddings(
env.qdrant.embeddingModel,
text,
);
return response.embedding;
}
@ -163,7 +182,10 @@ class VectorStoreService extends DtpService {
*/
async ingestTurn(turnId: string): Promise<void> {
if (!this._initialized) {
this.log.warn("ingestTurn called but service is not initialized — skipping", { turnId });
this.log.warn(
"ingestTurn called but service is not initialized — skipping",
{ turnId },
);
return;
}
@ -202,7 +224,9 @@ class VectorStoreService extends DtpService {
const combinedText = [
userPrompt ? `User: ${userPrompt}` : "",
agentResponse ? `Agent: ${agentResponse.trim()}` : "",
].filter(Boolean).join("\n\n");
]
.filter(Boolean)
.join("\n\n");
if (!combinedText.trim()) {
this.log.debug("ingestTurn: no content to ingest", { turnId });
@ -320,7 +344,10 @@ class VectorStoreService extends DtpService {
*/
async removeTurnPoints(turnId: string): Promise<void> {
if (!this._initialized) {
this.log.warn("removeTurnPoints called but service is not initialized — skipping", { turnId });
this.log.warn(
"removeTurnPoints called but service is not initialized — skipping",
{ turnId },
);
return;
}