mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
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:
parent
249f9e2472
commit
7009925585
3 changed files with 12 additions and 7 deletions
|
|
@ -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") {
|
||||
|
|
|
|||
|
|
@ -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}:`,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue