chore(types): tighten any types and fix langchain getType deprecation (#2444)

* chore(types): tighten any types and fix langchain getType deprecation

- Replace `message.getType()` with `message.type` in BedrockChatModel
- Type `docToSave` as `OramaDocument` and `explanation` as `SearchExplanation`
- Extract a typed `fallbackMetadata` to avoid `any` union warnings

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(lint): drop unnecessary `as unknown` cast on upsert return

Now that `docToSave` is typed as `OramaDocument`, it's already assignable
to the `Promise<unknown>` return type without an explicit cast.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Zero Liu 2026-05-14 00:53:06 -07:00 committed by GitHub
parent 249f9e2472
commit 7009925585
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 7 deletions

View file

@ -391,13 +391,14 @@ export class BedrockChatModel extends BaseChatModel<BedrockChatModelCallOptions>
const fallback = await this._generate(messages, options, runManager);
const fallbackText = fallback.generations[0]?.text ?? "";
if (fallbackText) {
const fallbackMetadata: Record<string, unknown> = fallback.llmOutput ?? {};
yield new ChatGenerationChunk({
message: new AIMessageChunk({
content: fallbackText,
response_metadata: fallback.llmOutput ?? {},
response_metadata: fallbackMetadata,
}),
text: fallbackText,
generationInfo: fallback.llmOutput ?? {},
generationInfo: fallbackMetadata,
});
}
}
@ -1251,7 +1252,7 @@ export class BedrockChatModel extends BaseChatModel<BedrockChatModelCallOptions>
const systemPrompts: string[] = [];
messages.forEach((message) => {
const messageType = message.getType();
const messageType = message.type;
// Handle system messages (always text-only)
if (messageType === "system") {

View file

@ -368,7 +368,7 @@ export class DBOperations {
};
}
async upsert(docToSave: any): Promise<unknown> {
async upsert(docToSave: OramaDocument): Promise<unknown> {
if (!this.oramaDb) throw new Error("DB not initialized");
const db = this.oramaDb;
@ -400,7 +400,7 @@ export class DBOperations {
);
this.markUnsavedChanges();
return docToSave as unknown;
return docToSave;
} catch (insertErr) {
logError(
`Failed to ${existingDoc.hits.length > 0 ? "update" : "insert"} document ${docToSave.id}:`,

View file

@ -1,4 +1,4 @@
import { NoteIdRank } from "../interfaces";
import { NoteIdRank, SearchExplanation } from "../interfaces";
/**
* Configuration for score normalization
@ -29,7 +29,11 @@ export class ScoreNormalizer {
/**
* Update explanation with normalized scores
*/
private updateExplanation(explanation: any, originalScore: number, normalizedScore: number): any {
private updateExplanation(
explanation: SearchExplanation | undefined,
originalScore: number,
normalizedScore: number
): SearchExplanation | undefined {
if (!explanation) return undefined;
return {