mirror of
https://github.com/epistemic-technology/co-intelligence.git
synced 2026-07-22 06:45:17 +00:00
Address the source-code issues flagged by the Obsidian community plugin review tool (https://community.obsidian.md/account/plugins/co-intelligence): - Add `App.commands` module augmentation so `executeCommandById` is typed rather than an unsafe-any call. - Cast `processFrontMatter` callbacks to `CoiNoteFrontmatter` (with `linked-tags` added to the type) instead of indexing `any` frontmatter. - Derive provider name in model-service from the registered `Model.provider` rather than introspecting the SDK's `LanguageModel.provider`, and type the `generateText` params via `Parameters<typeof generateText>[0]`. - Type the regex `replace` callback args in ChatInterface and notes.ts. - Drop the dead `triggerChange` prop from UserInput and its call site. - Rename unused params with `_` prefix and configure `@typescript-eslint/no-unused-vars` with `argsIgnorePattern: "^_"`. - Replace `document.createElementNS`/`createElement` and `el.createEl("div")` with Obsidian's `createSvg`, `createDiv`, `createSpan` helpers in settings and the suggestion modals. - Narrow `state.state?.file` from `any` before passing to a string parameter, and capture `this.app` outside the monkey-patched closure.
62 lines
1.2 KiB
TypeScript
62 lines
1.2 KiB
TypeScript
import { ModelMessage } from "ai";
|
|
import { TFile } from "obsidian";
|
|
|
|
export interface ContextItemContent {
|
|
title: string;
|
|
content: string;
|
|
}
|
|
|
|
/**
|
|
* Interface for chat request parameters.
|
|
*/
|
|
export interface ChatRequest {
|
|
requestID: string;
|
|
modelId: ModelId; // e.g., 'openai:gpt-4-turbo'
|
|
messages: ModelChatMessage[];
|
|
systemPrompt?: string;
|
|
context?: ContextItemContent[];
|
|
webSearch?: boolean;
|
|
}
|
|
|
|
export interface Source {
|
|
url: string;
|
|
title?: string;
|
|
}
|
|
|
|
export type ModelChatMessage = ModelMessage & {
|
|
isReasoning?: boolean;
|
|
};
|
|
|
|
export interface CoiNoteFrontmatter {
|
|
"is-coi-chat": boolean;
|
|
"coi-chat-view": boolean;
|
|
"note-renamed": boolean;
|
|
"linked-notes"?: string[];
|
|
"linked-tags"?: string[];
|
|
tags: string[];
|
|
}
|
|
|
|
export type ModelId =
|
|
| `openai:${string}`
|
|
| `anthropic:${string}`
|
|
| `google:${string}`
|
|
| `perplexity:${string}`;
|
|
|
|
export type Provider = "openai" | "anthropic" | "google" | "perplexity";
|
|
|
|
export interface Model {
|
|
id: ModelId;
|
|
provider: Provider;
|
|
name: string;
|
|
renaming: boolean;
|
|
toggleWebSearch: boolean;
|
|
streaming: boolean;
|
|
}
|
|
|
|
export type Tag = string;
|
|
|
|
export interface ContextItems {
|
|
notes: TFile[];
|
|
tags: Tag[];
|
|
sources: Source[];
|
|
}
|