repo_name
stringlengths
1
62
dataset
stringclasses
1 value
lang
stringclasses
11 values
pr_id
int64
1
20.1k
owner
stringlengths
2
34
reviewer
stringlengths
2
39
diff_hunk
stringlengths
15
262k
code_review_comment
stringlengths
1
99.6k
obsidian-copilot
github_2023
typescript
955
logancyang
zeroliu
@@ -0,0 +1,211 @@ +import React, { useState, useEffect } from "react"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; +import { Button } from "@/components/ui/button"; +import { Loader2 } from "lucide-react"; +import { PasswordInput } from...
why do we need an arbitrary text color here?
obsidian-copilot
github_2023
typescript
955
logancyang
zeroliu
@@ -0,0 +1,372 @@ +import React, { useState } from "react"; +import { getModelKeyFromModel, updateSetting, useSettingsValue } from "@/settings/model"; +import { SettingItem } from "@/components/ui/setting-item"; +import { Button } from "@/components/ui/button"; +import { ArrowRight, ExternalLink, HelpCircle, Key } from...
```suggestion ``` remove?
obsidian-copilot
github_2023
others
955
logancyang
zeroliu
@@ -2,6 +2,27 @@ @import "tailwindcss/components"; @import "tailwindcss/utilities"; +/* this layer for overwrite Obsidian default css style(file: app.css) and theme css style */ +@layer components { + .modal-container input.input-reset, + input[type="text"].input-reset, + input[type="password"].input-reset, + i...
is there any reasons why we don't add these classes directly to the component? (e.g. make them part of SelectPrimitive.Trigger). Same for the others
obsidian-copilot
github_2023
typescript
981
logancyang
logancyang
@@ -0,0 +1,261 @@ +import { Badge } from "@/components/ui/badge"; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"; +import { findRelevantNotes, RelevantNoteEntry } from "...
From my quick test with copilot-plus-small, ~80% of the similar notes fall in Medium Similarity, ~10+% High Similarity and rarely Low Similarity. Of course this distribution depends heavily on the embedding model used. Not really a problem but just to report an observation.
obsidian-copilot
github_2023
typescript
981
logancyang
logancyang
@@ -4,7 +4,7 @@ import { getSettings } from "@/settings/model"; import { InternalTypedDocument, Orama, Result } from "@orama/orama"; import { TFile } from "obsidian"; -const MIN_SIMILARITY_SCORE = 0.3; +const MIN_SIMILARITY_SCORE = 0.4;
Did you find 0.3 shows too many low similarity notes? Right now if similarity ranges from 0.4->1, the weighted is 0.7*(0.4->1), then the lowest weighted similarity score is roughly 0.3 i.e. the highest of links only. Is this a design choice? For some notes they have so many similar notes, the linked notes are only v...
obsidian-copilot
github_2023
typescript
971
logancyang
logancyang
@@ -0,0 +1,190 @@ +import { DBOperations } from "@/search/dbOperations"; +import { getSettings } from "@/settings/model"; +import { extractNoteTitles, getNoteFileFromTitle } from "@/utils"; +import { InternalTypedDocument, Orama, Result } from "@orama/orama"; +import { TFile } from "obsidian"; + +const MIN_SIMILARITY_S...
nit: `getNoteEmbeddings` may be a clearer name?
obsidian-copilot
github_2023
typescript
971
logancyang
logancyang
@@ -0,0 +1,190 @@ +import { DBOperations } from "@/search/dbOperations"; +import { getSettings } from "@/settings/model"; +import { extractNoteTitles, getNoteFileFromTitle } from "@/utils"; +import { InternalTypedDocument, Orama, Result } from "@orama/orama"; +import { TFile } from "obsidian"; + +const MIN_SIMILARITY_S...
Not particularly for this PR but right now we are not differentiating notes with the same title under different paths. This was on me. In the future we should use a unique identifier i.e. note path. When a user types `[[` the list should show the corresponding path next to each title (just like OB itself does it), a...
obsidian-copilot
github_2023
typescript
971
logancyang
logancyang
@@ -267,13 +267,32 @@ export class DBOperations { return db; } - public static async getDocsByPath(db: Orama<any>, path: string): Promise<any | undefined> { + public static async getDocsByPath(db: Orama<any>, path: string) { if (!db) throw new Error("DB not initialized"); if (!path) return; c...
Did you figure out how to make `exact` work? Is it still returning partial matches?
obsidian-copilot
github_2023
typescript
971
logancyang
logancyang
@@ -17,6 +17,10 @@ export const isFolderMatch = (fileFullpath: string, inputPath: string): boolean return fileSegments.includes(inputPath.toLowerCase()); }; +/** + * @deprecated File display title can be duplicated, so we should use file path + * instead of title to find the note file. + */ export async function...
Yeah this should be replaced everywhere, thanks for marking it deprecated.
obsidian-copilot
github_2023
typescript
971
logancyang
logancyang
@@ -36,6 +40,9 @@ export async function getNoteFileFromTitle(vault: Vault, noteTitle: string): Pro return null; } +/** + * @deprecated Use app.vault.getAbstractFileByPath() instead. + */ export const getNotesFromPath = async (vault: Vault, path: string): Promise<TFile[]> => {
`getNotesFromPath` gets an array of notes from a folder path, it's not the same as `app.vault.getAbstractFileByPath()`.
obsidian-copilot
github_2023
typescript
971
logancyang
logancyang
@@ -445,6 +452,9 @@ export function extractChatHistory(memoryVariables: MemoryVariables): [string, s return chatHistory; } +/** + * @deprecated Use noteUtils getLinkedNotes() instead. + */ export function extractNoteTitles(query: string): string[] {
This is extracting from a query and not a note, so it's not the same as `getLinkedNotes()`
obsidian-copilot
github_2023
typescript
971
logancyang
logancyang
@@ -565,6 +575,7 @@ export async function safeFetch(url: string, options: RequestInit): Promise<Resp url: url, type: "basic", redirected: false, + bytes: () => Promise.resolve(new Uint8Array(0)),
What's this for? Why do I get `The bytes property isn't part of the standard Response interface`?
obsidian-copilot
github_2023
others
888
logancyang
zeroliu
@@ -1,41 +1,416 @@ -/* - -This CSS file will be included with your plugin, and -available in the app when your plugin is enabled. - -If your plugin does not need CSS, delete this file. - -*/ - +*, +:after, +:before { + --tw-border-spacing-x: 0; + --tw-border-spacing-y: 0; + --tw-translate-x: 0; + --tw-translate-y: ...
should this file be checked in? It looks like the generated tailwind CSS file
obsidian-copilot
github_2023
others
888
logancyang
zeroliu
@@ -0,0 +1,1101 @@ +@import "tailwindcss/base"; +@import "tailwindcss/components"; +@import "tailwindcss/utilities"; + +@layer base { + :root { + --background: 0 0% 100%; + --foreground: 222.2 47.4% 11.2%; + --muted: 210 40% 96.1%; + --muted-foreground: 215.4 16.3% 46.9%; + --popover: 0 0% 100%; + --...
what are these styles?
obsidian-copilot
github_2023
others
888
logancyang
zeroliu
@@ -0,0 +1,1101 @@ +@import "tailwindcss/base"; +@import "tailwindcss/components"; +@import "tailwindcss/utilities"; + +@layer base { + :root { + --background: 0 0% 100%;
to make UI library compatible with obsidian plugin, we should use the CSS variables defined in obsidian (https://docs.obsidian.md/Reference/CSS+variables/CSS+variables). Many obsidian users use themes, which are made by altering those CSS variables (https://docs.obsidian.md/Themes/App+themes/Build+a+theme). Users would...
obsidian-copilot
github_2023
others
888
logancyang
logancyang
@@ -159,14 +163,6 @@ If your plugin does not need CSS, delete this file. opacity: 1; } -.context-note .note-name {
These 3 red blocks were added recently, why are they removed here?
obsidian-copilot
github_2023
others
888
logancyang
logancyang
@@ -4,8 +4,11 @@ "description": "ChatGPT integration for Obsidian", "main": "main.js", "scripts": { - "dev": "node esbuild.config.mjs", - "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", + "dev": "npm-run-all --parallel dev:*", + "dev:tailwind": "npx tailwindcss -i src/st...
Typo: `build:tailiwind`. I recommend some form of AI assistance to spot these things in the future. It's hard for reviewers to spot.
obsidian-copilot
github_2023
others
888
logancyang
logancyang
@@ -4,8 +4,11 @@ "description": "ChatGPT integration for Obsidian", "main": "main.js", "scripts": { - "dev": "node esbuild.config.mjs", - "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", + "dev": "npm-run-all --parallel dev:*", + "dev:tailwind": "npx tailwindcss -i src/st...
How about something like ``` { "scripts": { "build:tailwind": "npx tailwindcss -i src/styles/tailwind.css -o ./styles.css --minify", "build:esbuild": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", "build": "npm run build:tailwind && npm run build:esbuild || exit 1" } } ```
obsidian-copilot
github_2023
javascript
888
logancyang
zeroliu
@@ -0,0 +1,70 @@ +// tailwind.config.js + +import tailwindcssAnimate from "tailwindcss-animate"; + +/** @type {import("tailwindcss").Config} */ +module.exports = { + content: ["./src/**/*.{js,ts,jsx,tsx}", "./src/styles/tailwind.css"], + darkMode: ["class", '[data-theme="dark"]'], + plugins: [tailwindcssAnimate], + ...
can we not extend but redefine all the tokens? Otherwise, people can still use predefined tailwind tokens without realizing that it's not connected to obsidian CSS variables. We can also turn on this eslint rule to enforce only supported classnames are used in the code base: https://github.com/francoismassart/eslint-pl...
obsidian-copilot
github_2023
typescript
888
logancyang
zeroliu
@@ -0,0 +1,22 @@ +import * as React from "react"; + +import { cn } from "@/lib/utils"; + +const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>( + ({ className, type, ...props }, ref) => { + return ( + <input + type={type} + className={cn( + "flex h-9 w-full rou...
do we support file type input? If not, I suggest not adding the related style until it's needed
obsidian-copilot
github_2023
typescript
888
logancyang
zeroliu
@@ -0,0 +1,22 @@ +import * as React from "react"; + +import { cn } from "@/lib/utils"; + +const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
not blocking this PR but maybe we can look into React 19 and use the `ref` props now that it's officially GA. Maintaining forwardRef for RadixUI can be pretty tedious.
obsidian-copilot
github_2023
typescript
888
logancyang
zeroliu
@@ -121,7 +121,8 @@ export enum EmbeddingModelProviders { OPENAI = "openai", COHEREAI = "cohereai", GOOGLE = "google", - AZURE_OPENAI = "azure_openai", + // AZURE_OPENAI = "azure_openai", + AZURE_OPENAI = "azure openai",
does it belong to this PR?
obsidian-copilot
github_2023
others
888
logancyang
zeroliu
@@ -1,3 +1,110 @@ +@import "tailwindcss/base"; +@import "tailwindcss/components"; +@import "tailwindcss/utilities"; + +@layer base { + body { + /* preDefine CSS variables in Obsidian.(https://docs.obsidian.md/Reference/CSS+variables/Foundations/Colors) */ + /*Primary background*/ + --ob-bg-primary: var(--back...
why do we need to redefine obsidian CSS with `--ob-bg` prefix?
obsidian-copilot
github_2023
others
888
logancyang
zeroliu
@@ -1,3 +1,110 @@ +@import "tailwindcss/base"; +@import "tailwindcss/components"; +@import "tailwindcss/utilities"; + +@layer base { + body { + /* preDefine CSS variables in Obsidian.(https://docs.obsidian.md/Reference/CSS+variables/Foundations/Colors) */ + /*Primary background*/ + --ob-bg-primary: var(--back...
I don't think we should be touching the default component style as it will affect UI outside of obsidian-copilot
obsidian-copilot
github_2023
javascript
888
logancyang
zeroliu
@@ -0,0 +1,105 @@ +// tailwind.config.js + +import tailwindcssAnimate from "tailwindcss-animate"; +import { colorOpacityPlugin } from "./src/lib/plugins/colorOpacityPlugin"; +import colors from "tailwindcss/colors"; + +/** @type {import("tailwindcss").Config} */
we can use tailwind.config.ts to get full type support instead of this type comment
obsidian-copilot
github_2023
javascript
888
logancyang
zeroliu
@@ -0,0 +1,105 @@ +// tailwind.config.js + +import tailwindcssAnimate from "tailwindcss-animate"; +import { colorOpacityPlugin } from "./src/lib/plugins/colorOpacityPlugin"; +import colors from "tailwindcss/colors"; + +/** @type {import("tailwindcss").Config} */ +module.exports = { + content: ["./src/**/*.{js,ts,jsx,t...
what's the use case of black, white, red, yellow? Are there existing semantic tokens that can replace them?
obsidian-copilot
github_2023
javascript
888
logancyang
zeroliu
@@ -0,0 +1,105 @@ +// tailwind.config.js + +import tailwindcssAnimate from "tailwindcss-animate"; +import { colorOpacityPlugin } from "./src/lib/plugins/colorOpacityPlugin"; +import colors from "tailwindcss/colors"; + +/** @type {import("tailwindcss").Config} */ +module.exports = { + content: ["./src/**/*.{js,ts,jsx,t...
When do we need this token? It doesn't feel necessary to introduce a new token that needs to calculate a new value outside of the obsidian design system?
obsidian-copilot
github_2023
javascript
888
logancyang
zeroliu
@@ -0,0 +1,221 @@ +// tailwind.config.js + +import tailwindcssAnimate from "tailwindcss-animate"; +import { colorOpacityPlugin } from "./src/lib/plugins/colorOpacityPlugin"; +import colors from "tailwindcss/colors"; + +/** @type {import("tailwindcss").Config} */ +module.exports = { + content: ["./src/**/*.{js,ts,jsx,t...
please clean up the comments
obsidian-copilot
github_2023
javascript
888
logancyang
zeroliu
@@ -0,0 +1,221 @@ +// tailwind.config.js + +import tailwindcssAnimate from "tailwindcss-animate"; +import { colorOpacityPlugin } from "./src/lib/plugins/colorOpacityPlugin"; +import colors from "tailwindcss/colors"; + +/** @type {import("tailwindcss").Config} */ +module.exports = { + content: ["./src/**/*.{js,ts,jsx,t...
can we not use the obsidian defined red and yellow color?
obsidian-copilot
github_2023
typescript
850
logancyang
logancyang
@@ -53,40 +53,45 @@ export default class ChatModelManager { private getModelConfig(customModel: CustomModel): ModelConfig { const decrypt = (key: string) => this.encryptionService.getDecryptedKey(key); const params = this.getLangChainParams(); + + // Check if the model starts with "o1" + const modelN...
Can we add these to the OpenAI block below instead of baseConfig?
obsidian-copilot
github_2023
typescript
850
logancyang
logancyang
@@ -317,12 +317,26 @@ export default class ChainManager { this.validateChatModel(); this.validateChainInitialization(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const chatModel = (ChainManager.chain as any).last.bound; + const modelName = chatModel.modelName || chatModel.m...
Add a `TODO: hack for o1 models, to be removed when they support system prompt`
obsidian-copilot
github_2023
typescript
850
logancyang
logancyang
@@ -317,12 +317,26 @@ export default class ChainManager { this.validateChatModel(); this.validateChainInitialization(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const chatModel = (ChainManager.chain as any).last.bound;
What's the difference between using this vs. "ChatModelManager.getChatModel()"?
obsidian-copilot
github_2023
typescript
850
logancyang
logancyang
@@ -202,6 +207,25 @@ export default class ChatModelManager { return { ...baseConfig, ...selectedProviderConfig }; } + private handleOpenAIExtraArgs( + isO1Model: boolean, + maxTokens: number, + temperature: number, + streaming: boolean + ) { + return isO1Model + ? { + maxComplet...
o1 models support streaming now. We can remove this line.
obsidian-copilot
github_2023
typescript
817
logancyang
logancyang
@@ -286,8 +286,21 @@ class VectorStoreManager { private async getFilePathsForQA(filterType: "exclusions" | "inclusions"): Promise<Set<string>> { const targetFiles = new Set<string>(); - if (filterType === "exclusions" && this.settings.qaExclusions) { - const exclusions = this.settings.qaExclusions.spl...
It could be better to be a bit more defensive in case `getConfig` fails.
obsidian-copilot
github_2023
typescript
851
logancyang
logancyang
@@ -19,11 +32,20 @@ export default class EmbeddingManager { string, { hasApiKey: boolean; - EmbeddingConstructor: new (config: any) => Embeddings; + EmbeddingConstructor: EmbeddingConstructorType; vendor: string; } >; + private readonly providerAipKeyMap: Record<EmbeddingMod...
nit: Typo, `Api`
obsidian-copilot
github_2023
typescript
851
logancyang
logancyang
@@ -1,9 +1,8 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { AnthropicInput, ChatAnthropic } from "@langchain/anthropic"; -import { ChatOpenAI } from "@langchain/openai"; -import { OpenAIEmbeddings } from "@langchain/openai"; -import { requestUrl } from "obsidian"; +import { ChatOpenAI, OpenAIEmbe...
Does this mean we can get rid of `ProxyChatOpenAI`?
obsidian-copilot
github_2023
typescript
818
logancyang
logancyang
@@ -531,3 +531,81 @@ export async function getFilePathsFromPatterns( return Array.from(filePaths); } + +/** Proxy function to use in place of fetch() to bypass CORS restrictions. + * It currently doesn't support streaming until this is implemented + * https://forum.obsidian.md/t/support-streaming-the-request-and-...
Should this be removed
obsidian-copilot
github_2023
typescript
818
logancyang
logancyang
@@ -531,3 +531,81 @@ export async function getFilePathsFromPatterns( return Array.from(filePaths); } + +/** Proxy function to use in place of fetch() to bypass CORS restrictions. + * It currently doesn't support streaming until this is implemented + * https://forum.obsidian.md/t/support-streaming-the-request-and-...
Nit: there's a type error for `err.cause.message`: Property 'message' does not exist on type '{}'
obsidian-copilot
github_2023
typescript
818
logancyang
logancyang
@@ -256,4 +300,23 @@ export default class ChatModelManager { async countTokens(inputStr: string): Promise<number> { return ChatModelManager.chatModel.getNumTokens(inputStr); } + + async verify(model: CustomModel) { + model.enableCors = true; // enable CORS for verification + const modelConfig = this.g...
Does this "verify" need streaming? Can `invoke` work here
obsidian-copilot
github_2023
typescript
818
logancyang
logancyang
@@ -310,10 +387,32 @@ const ModelSettingsComponent: React.FC<ModelSettingsComponentProps> = ({ } }; + const handleVerify = async () => { + if (newModel.name && newModel.provider) { + setIsVerifying(true); + await chainManager.chatModelManager + .verify({ ...newModel }) + .then((res...
We don't need `res` in this notice, just showing the success message is good enough.
obsidian-copilot
github_2023
typescript
818
logancyang
logancyang
@@ -105,11 +167,16 @@ export default class ChatModelManager { threshold: HarmBlockThreshold.BLOCK_NONE, }, ], + baseUrl: customModel.baseUrl, }, [ChatModelProviders.OPENROUTERAI]: { modelName: customModel.name, openAIApiKey: decrypt(customModel.api...
These can be removed now. Ditto for the ones below.
obsidian-copilot
github_2023
typescript
818
logancyang
logancyang
@@ -310,10 +387,32 @@ const ModelSettingsComponent: React.FC<ModelSettingsComponentProps> = ({ } }; + const handleVerify = async () => { + if (newModel.name && newModel.provider) { + setIsVerifying(true); + await chainManager.chatModelManager + .verify({ ...newModel }) + .then((res...
"...and double-check the correctness"
obsidian-copilot
github_2023
typescript
818
logancyang
logancyang
@@ -11,15 +11,18 @@ import { TextComponent, ToggleComponent, } from "./SettingBlocks"; +import ChainManager from "@/LLMProviders/chainManager"; interface GeneralSettingsProps { getLangChainParams: () => LangChainParams; encryptionService: EncryptionService; + chainManager: ChainManager;
Should we pass `ChatModelManager` instead of the entire `ChainManager` through all these components? Is `ChainManager` needed for other cases?
obsidian-copilot
github_2023
typescript
818
logancyang
logancyang
@@ -46,6 +49,77 @@ type ToggleComponentProps = { disabled?: boolean; }; +const ChatModelOption: Record<
Should this be here or in the constants file? And why do we need so many of them when they all have the same fields?
obsidian-copilot
github_2023
typescript
818
logancyang
logancyang
@@ -411,41 +510,59 @@ const ModelSettingsComponent: React.FC<ModelSettingsComponentProps> = ({ </h2> {isAddModelOpen && ( <div className="add-custom-model-form"> - <TextComponent - name="Model Name" - description={`The name of the model, i.e. ${isEmbeddi...
Why not have the verify button for embedding models?
obsidian-copilot
github_2023
typescript
818
logancyang
logancyang
@@ -274,10 +275,21 @@ export default class ChainManager { const memory = this.memoryManager.getMemory(); const chatPrompt = this.promptManager.getChatPrompt(); const systemPrompt = ignoreSystemMessage ? "" : systemMessage; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const c...
Why do we add system message when `ignoreSystemMessage` is true?
obsidian-copilot
github_2023
typescript
818
logancyang
logancyang
@@ -10,6 +9,35 @@ import { ChatGroq } from "@langchain/groq"; import { ChatOllama } from "@langchain/ollama"; import { ChatOpenAI } from "@langchain/openai"; import { Notice } from "obsidian"; +import { omit, safeFetch } from "@/utils"; +import { ChatAnthropic } from "@langchain/anthropic"; + +type ChatConstructorTy...
What's this, looks scary 🥶
obsidian-copilot
github_2023
typescript
818
logancyang
logancyang
@@ -256,4 +322,19 @@ export default class ChatModelManager { async countTokens(inputStr: string): Promise<number> { return ChatModelManager.chatModel.getNumTokens(inputStr); } + + async ping(model: CustomModel): Promise<"PONG"> { + model.enableCors = true; // enable CORS for verification + // remove s...
`aIConstructor` naming is weird.
obsidian-copilot
github_2023
typescript
818
logancyang
logancyang
@@ -3,12 +3,30 @@ import { CustomModel, LangChainParams } from "@/aiParams"; import { EmbeddingModelProviders } from "@/constants"; import EncryptionService from "@/encryptionService"; import { CustomError } from "@/error"; -import { ProxyOpenAIEmbeddings } from "@/langchainWrappers"; import { CohereEmbeddings } fr...
We need to get rid of this...
obsidian-copilot
github_2023
typescript
818
logancyang
logancyang
@@ -310,10 +315,33 @@ const ModelSettingsComponent: React.FC<ModelSettingsComponentProps> = ({ } }; + const handleVerify = async () => { + if (newModel.name && newModel.provider) { + setIsVerifying(true); + await ping({ ...newModel }) + .then((_) => new Notice("Model verification successf...
This should not be here. We don't want to couple everything. Model-related stuff should be in model-related files.
obsidian-copilot
github_2023
typescript
131
logancyang
logancyang
@@ -142,6 +142,9 @@ const Chat: React.FC<ChatProps> = ({ return; } const noteContent = await getFileContent(file); + if (debug) { + console.log("ALL NOTE CONTENT IS", noteContent)
Should we only show truncated content from the PDF in case the text is super long? And if you intend to keep this debugging message, no need to make it all caps, perhaps some delimiters can make it more visible.
obsidian-copilot
github_2023
typescript
131
logancyang
logancyang
@@ -69,6 +69,7 @@ export const DISPLAY_NAME_TO_MODEL: Record<string, string> = { [ChatModelDisplayNames.AZURE_GPT_35_TURBO_16K]: ChatModels.AZURE_GPT_35_TURBO_16K, [ChatModelDisplayNames.AZURE_GPT_4]: ChatModels.GPT_4, [ChatModelDisplayNames.AZURE_GPT_4_32K]: ChatModels.GPT_4_32K, + [ChatModelDisplayNames.LOC...
Maybe we can move the model providers constants below to the top so this can use the `LOCALAI` constant.
obsidian-copilot
github_2023
typescript
131
logancyang
logancyang
@@ -92,8 +93,12 @@ export const formatDateTime = (now: Date, timezone: 'local' | 'utc' = 'local') = }; export async function getFileContent(file: TFile): Promise<string | null> { - if (file.extension != "md") return null; - return await this.app.vault.read(file); + if (file.extension == "md") { + return await...
Does this mean this PR works only for a PDF file opened directly in Obsidian, and not embedded in another markdown note? I initially misunderstood and tried an _embedded_ PDF, and it didn't work. Don't get me wrong, this is still phenomenal work!! Just wondering, after your research, do you think there's a path to enab...
obsidian-copilot
github_2023
typescript
768
logancyang
logancyang
@@ -0,0 +1,139 @@ +import { ChainType } from "@/chainFactory"; +import { VAULT_VECTOR_STORE_STRATEGY } from "@/constants"; +import React, { useMemo } from "react"; + +interface NotePrompt { + title: string; + prompts: string[]; +} +const SUGGESTED_PROMPTS: Record<string, NotePrompt> = { + activeNote: { + title: "...
This should be single braces instead of double?
obsidian-copilot
github_2023
typescript
768
logancyang
logancyang
@@ -0,0 +1,139 @@ +import { ChainType } from "@/chainFactory"; +import { VAULT_VECTOR_STORE_STRATEGY } from "@/constants"; +import React, { useMemo } from "react"; + +interface NotePrompt { + title: string; + prompts: string[]; +} +const SUGGESTED_PROMPTS: Record<string, NotePrompt> = { + activeNote: { + title: "...
These 3 questions will likely fail in Vault QA because "recent project notes", "deadline", "brainstorming sessions" may not exist literally in the user's vault. They are more appropriate as Copilot Plus questions. In general I recommend specific questions for this mode, so ideally it needs something that literally e...
obsidian-copilot
github_2023
typescript
768
logancyang
logancyang
@@ -76,13 +75,6 @@ const ChatIcons: React.FC<ChatIconsProps> = ({ if (vault_qa_strategy === VAULT_VECTOR_STORE_STRATEGY.ON_MODE_SWITCH) { await onRefreshVaultContext(); } - const activeNoteOnMessage: ChatMessage = { - sender: AI_SENDER, - message: `OK Feel free to a...
This message below is worth keeping above the "NEVER" warning unconditionally for Vault QA. "Please note that this is a retrieval-based QA. Questions should contain keywords and concepts that exist literally in your vault."
obsidian-copilot
github_2023
typescript
768
logancyang
logancyang
@@ -0,0 +1,139 @@ +import { ChainType } from "@/chainFactory"; +import { VAULT_VECTOR_STORE_STRATEGY } from "@/constants"; +import React, { useMemo } from "react"; + +interface NotePrompt { + title: string; + prompts: string[]; +} +const SUGGESTED_PROMPTS: Record<string, NotePrompt> = { + activeNote: { + title: "...
Should we use `<>` to indicate that the user must replace it `[[<your note>]]`?
obsidian-copilot
github_2023
typescript
797
logancyang
logancyang
@@ -106,36 +98,25 @@ const ChatControls: React.FC<ChatControlsProps> = ({ return ( <div className="chat-icons-container"> - <button className="chat-icon-button clickable-icon" onClick={() => onNewChat(false)}> - <RefreshIcon className="icon-scaler" /> - <span className="tooltip-text"> - ...
Shouldn't this be `onRefreshVaultContext`?
obsidian-copilot
github_2023
typescript
797
logancyang
logancyang
@@ -106,36 +98,25 @@ const ChatControls: React.FC<ChatControlsProps> = ({ return ( <div className="chat-icons-container"> - <button className="chat-icon-button clickable-icon" onClick={() => onNewChat(false)}> - <RefreshIcon className="icon-scaler" /> - <span className="tooltip-text"> - ...
Since we are updating this, `UseActiveNoteAsContextIcon` is a legacy name, we can rename it to "RefreshIndexIcon" or something.
obsidian-copilot
github_2023
typescript
631
logancyang
logancyang
@@ -224,16 +224,35 @@ export default class CopilotPlugin extends Plugin { if (doc.prompt) { new AddPromptModal( this.app, - (title: string, newPrompt: string) => { - this.dbPrompts.put({
Seems you have an old version.
obsidian-copilot
github_2023
typescript
774
logancyang
logancyang
@@ -85,7 +85,7 @@ const GeneralSettings: React.FC<GeneralSettingsProps> = ({ <option value={ChainType.LLM_CHAIN}>Chat</option> <option value={ChainType.VAULT_QA_CHAIN}>Vault QA (Basic)</option> </select> - <span className="tooltip-text">Default Mode Selection</span> + ...
This line can be removed/
obsidian-copilot
github_2023
typescript
723
logancyang
logancyang
@@ -132,8 +132,8 @@ const QASettings: React.FC<QASettingsProps> = ({ /> <TextAreaComponent name="Indexing Exclusions" - description="Comma separated list of paths, tags or note titles, e.g. folder1, folder1/folder2, #tag1, #tag2, [[note1]], [[note2]], etc, to be excluded from the indexing ...
nit: typo, should be "excalidraw" with one "l"
obsidian-copilot
github_2023
typescript
688
logancyang
logancyang
@@ -674,12 +674,14 @@ ${chatContent}`; currentChain={currentChain} setCurrentChain={setChain} onNewChat={async (openNote: boolean) => { + handleStopGenerating(ABORT_REASON.NEW_CHAT); if (settings.autosaveChat && chatHistory.length > 0) { await hand...
This can be removed. I'll do it later.
obsidian-copilot
github_2023
typescript
651
logancyang
logancyang
@@ -146,6 +155,13 @@ export const BUILTIN_EMBEDDING_MODELS: CustomModel[] = [ }, ]; +export const COHEREAI_EMBEDDING_INPUT_TYPES = [
Should this be a user setting or set internally? I'd like to avoid cluttering the settings and overwhelming users with options.
obsidian-copilot
github_2023
typescript
656
logancyang
logancyang
@@ -52,7 +65,13 @@ export class CustomPromptProcessor { content: content, }); } - return prompts; + + // Clean up promptUsageTimestamps + this.usageStrategy?.removeUnusedPrompts(prompts.map((prompt) => prompt.title)).save(); + + console.log(this.settings.promptUsageTimestamps);
We can remove this.
obsidian-copilot
github_2023
typescript
656
logancyang
logancyang
@@ -0,0 +1,53 @@ +import { CopilotSettings } from "@/settings/SettingsPage";
Nit: For consistency can we name this file `promptUsageStrategy.ts` without the capitalization.
obsidian-copilot
github_2023
typescript
659
logancyang
logancyang
@@ -22,6 +22,7 @@ export interface CopilotSettings { googleApiKey: string; openRouterAiApiKey: string; defaultModelKey: string; + defaultTag: string;
How about `defaultConversationTag` and put it below the `defaultSaveFolder` below
obsidian-copilot
github_2023
typescript
659
logancyang
logancyang
@@ -79,6 +79,13 @@ const GeneralSettings: React.FC<GeneralSettingsProps> = ({ value={settings.defaultSaveFolder} onChange={(value) => updateSettings({ defaultSaveFolder: value })} /> + <TextComponent + name="Default Conversation Tag" + description="The default tag to be used ...
I don't see where you set the default `ai-conversations` though, it's in constants.ts
obsidian-copilot
github_2023
typescript
572
logancyang
logancyang
@@ -196,6 +196,7 @@ export const DEFAULT_SETTINGS: CopilotSettings = { lmStudioBaseUrl: "http://localhost:1234/v1", stream: true, defaultSaveFolder: "copilot-conversations", + excludedFolders: [], indexVaultToVectorStore: VAULT_VECTOR_STORE_STRATEGY.ON_MODE_SWITCH, qaExclusionPaths: "",
It is right here. @milesvdw
obsidian-copilot
github_2023
typescript
572
logancyang
logancyang
@@ -196,6 +196,7 @@ export const DEFAULT_SETTINGS: CopilotSettings = { lmStudioBaseUrl: "http://localhost:1234/v1", stream: true, defaultSaveFolder: "copilot-conversations", + excludedFolders: [],
No need for this new setting.
obsidian-copilot
github_2023
typescript
572
logancyang
logancyang
@@ -545,6 +545,7 @@ export default class CopilotPlugin extends Plugin { content: fileContents[index], metadata: fileMetadatas[index]?.frontmatter ?? {}, }; +
No need to change this file?
obsidian-copilot
github_2023
typescript
572
logancyang
logancyang
@@ -79,6 +79,13 @@ const GeneralSettings: React.FC<GeneralSettingsProps> = ({ value={settings.defaultSaveFolder} onChange={(value) => updateSettings({ defaultSaveFolder: value })} /> + <TextComponent
This should be in QA settings instead.
obsidian-copilot
github_2023
typescript
593
logancyang
logancyang
@@ -75,6 +73,20 @@ const Chat: React.FC<ChatProps> = ({ const [inputMessage, setInputMessage] = useState(""); const [abortController, setAbortController] = useState<AbortController | null>(null); const [loading, setLoading] = useState(false); + const [chatIsVisible, setChatIsVisible] = useState(false); + + c...
The event listener for EVENT_NAMES.CHAT_IS_VISIBLE is added in the useEffect hook but is never removed. This can lead to memory leaks if the Chat component is unmounted and remounted multiple times, as the event listener will persist and accumulate.
obsidian-copilot
github_2023
typescript
593
logancyang
logancyang
@@ -80,6 +81,8 @@ export default class CopilotPlugin extends Plugin { this.registerView(CHAT_VIEWTYPE, (leaf: WorkspaceLeaf) => new CopilotView(leaf, this)); + this.initActiveLeafChangeHandler();
It registers an event listener for the "active-leaf-change" event but does not remove it during the plugin's onunload lifecycle. This can lead to memory leaks or multiple event handlers being registered if the plugin is reloaded or reinitialized multiple times.
obsidian-copilot
github_2023
others
311
logancyang
logancyang
@@ -31,7 +31,7 @@ "esbuild": "0.17.3", "jest": "^29.7.0", "jest-environment-jsdom": "^29.5.0", - "obsidian": "latest", + "obsidian": "^1.5.7-1",
I pulled this PR locally and ran npm install, `npm list obsidian` gives me 1.5.7-1 correctly. However, I see this when I run the plugin <img width="730" alt="image" src="https://github.com/logancyang/obsidian-copilot/assets/4860545/5939d0dc-bfec-4500-b6a5-ccbd8d9e9b68"> Can you reproduce it? This is weird.
obsidian-copilot
github_2023
typescript
311
logancyang
logancyang
@@ -126,9 +125,12 @@ export const formatDateTime = (now: Date, timezone: 'local' | 'utc' = 'local') = return formattedDateTime.format('YYYY_MM_DD-HH_mm_ss'); }; -export async function getFileContent(file: TFile, vault: Vault): Promise<string | null> { +export async function getFileContent(file: TFile, vault: Vaul...
If we pass `app` it seems we can access `vault` from it, so there's no need to pass `vault` anymore?
obsidian-copilot
github_2023
typescript
311
logancyang
Noobgam
@@ -39,29 +39,25 @@ export const getNotesFromPath = async (vault: Vault, path: string): Promise<TFil }); } -export async function getTagsFromNote(file: TFile, vault: Vault): Promise<string[]> { - const fileContent = await vault.cachedRead(file); - const frontMatter = parseYaml(fileContent.split('---')?.[1] ?? '...
For the sake of people who will be using this repository, even though Logan seems to not consider the tags in the note content for whatever reason, Obsidian in fact does. Should be a oneliner-change after this PR, you can take inspiration from here https://github.com/Noobgam/obsidian-copilot/pull/35/files#diff-39b2...
obsidian-copilot
github_2023
typescript
513
logancyang
logancyang
@@ -1,101 +0,0 @@ -import cors from "@koa/cors"; -import Koa from "koa"; -import proxy from "koa-proxies"; -import { CopilotSettings } from "@/settings/SettingsPage"; -import { ChatModelDisplayNames } from "@/constants"; - -// There should only be 1 running proxy server at a time so keep it in upper scope -let server: ...
@gianluca-venturini this is for some model providers such as Claude and all those 3rd party OpenAI replacements who don't allow CORS. Without this workaround they result in CORS errors in Obsidian.
obsidian-copilot
github_2023
typescript
513
logancyang
logancyang
@@ -316,9 +315,10 @@ const Chat: React.FC<ChatProps> = ({ }; useEffect(() => { - async function handleSelection(selectedText: string) { - const wordCount = selectedText.split(' ').length; - const tokenCount = await chainManager.chatModelManager.countTokens(selectedText); + async function handleS...
Don't forget to remove console.logs once you are confident it works, same for the ones below.
obsidian-copilot
github_2023
typescript
513
logancyang
logancyang
@@ -27,3 +30,53 @@ export class ProxyOpenAIEmbeddings extends OpenAIEmbeddings { }); } } + +export class ChatAnthropicWrapped extends ChatAnthropic { + constructor(fields?: Partial<AnthropicInput>) { + super(fields); + + // Override the client with a custom one that uses myFetch + this.clientOptions....
What's the implication of removing this? Do we lose functionalities here?
obsidian-copilot
github_2023
others
513
logancyang
logancyang
@@ -41,6 +39,12 @@ const context = await esbuild.context({ treeShaking: true, outfile: "main.js", plugins: [svgPlugin(), wasmPlugin], + define: { + global: "window", + }, + alias: { + events: "./null-events.js",
Good to know that this makes pouchdb work on mobile! And yes, I've been thinking about removing pouchdb. 1. Custom prompt: use data.json directly for better obsidian sync support 2. Vector store: this is my main question. Do you know any browser-native vector db? Right now pouchdb doesn't provide any advantage on ...
obsidian-copilot
github_2023
typescript
513
logancyang
logancyang
@@ -96,6 +95,7 @@ export default class ChatModelManager { [ModelProviders.LM_STUDIO]: { openAIApiKey: "placeholder", openAIProxyBaseUrl: `${params.lmStudioBaseUrl}`, + useOpenAILocalProxy: params.useOpenAILocalProxy,
Why do we need this for LM Studio? Is this line for testing?
obsidian-copilot
github_2023
typescript
513
logancyang
logancyang
@@ -73,7 +72,7 @@ export default class ChatModelManager { openAIProxyBaseUrl: params.openAIProxyBaseUrl, }, [ModelProviders.ANTHROPIC]: { - anthropicApiUrl: `http://localhost:${PROXY_SERVER_PORT}`, + anthropicApiUrl: "https://api.anthropic.com",
I think you can remove this line? ChatAnthropic should default to this.
obsidian-copilot
github_2023
typescript
513
logancyang
logancyang
@@ -46,6 +46,7 @@ export default class EmbeddingManager { embeddingModel, openAIEmbeddingProxyBaseUrl, openAIEmbeddingProxyModelName, + useOpenAILocalProxy,
~~Aren't we removing the local proxy in this PR? I thought this flag was deprecated because of that?~~ Oh I see, `useOpenAILocalProxy` now indicates using `safeFetch` i.e. `requestUrl`. Should we give it a better name? Like `enableCors` or something since local proxy is actually removed.
obsidian-copilot
github_2023
typescript
513
logancyang
logancyang
@@ -188,15 +153,15 @@ const ChatIcons: React.FC<ChatIconsProps> = ({ <span className="tooltip-text">Model Selection</span> </div> </div> - <button className="chat-icon-button" onClick={onNewChat}> + <button className="chat-icon-button clickable-icon" onClick={onNewChat}>
I don't see how `clickable-icon` is used? Maybe I'm missing something.
obsidian-copilot
github_2023
typescript
513
logancyang
logancyang
@@ -310,9 +313,9 @@ const Chat: React.FC<ChatProps> = ({ }; useEffect(() => { - async function handleSelection(selectedText: string) { - const wordCount = selectedText.split(" ").length; - const tokenCount = await chainManager.chatModelManager.countTokens(selectedText); + async function handleSe...
Nice! As a note: we just need to make sure text selection commands/prompts are working
obsidian-copilot
github_2023
typescript
513
logancyang
logancyang
@@ -12,6 +14,7 @@ export class ProxyChatOpenAI extends ChatOpenAI { this["client"] = new OpenAI({ ...this["clientConfig"], baseURL: fields.openAIProxyBaseUrl, + fetch: fields.useOpenAILocalProxy ? safeFetch : undefined,
Ditto, maybe call it `enableCors`
obsidian-copilot
github_2023
typescript
513
logancyang
logancyang
@@ -24,6 +27,72 @@ export class ProxyOpenAIEmbeddings extends OpenAIEmbeddings { this["client"] = new OpenAI({ ...this["clientConfig"], baseURL: fields.openAIEmbeddingProxyBaseUrl, + fetch: fields.useOpenAILocalProxy ? safeFetch : undefined,
Since embedding endpoints don't need streaming, perhaps we should default to `safeFetch`? WDYT?
obsidian-copilot
github_2023
typescript
513
logancyang
logancyang
@@ -341,8 +344,10 @@ const Chat: React.FC<ChatProps> = ({ isVisible = false, ignoreSystemMessage = true, // Ignore system message by default for commands } = options; - const handleSelection = async (selectedText: string, eventSubtype?: string) => { - const messageWithPrompt = await...
We can remove these console logs now
obsidian-copilot
github_2023
typescript
513
logancyang
logancyang
@@ -59,7 +59,7 @@ export interface LangChainParams { openRouterModel: string; lmStudioBaseUrl: string; openAIProxyBaseUrl?: string; - useOpenAILocalProxy?: boolean; + enableCors?: boolean;
Personally I'd prefer having this in CopilotSettings instead of LangChainParams since it has nothing to do with Langchain. But no worries, it will be address by my following PR. You can leave it here.
obsidian-copilot
github_2023
typescript
291
logancyang
petery789
@@ -38,6 +39,37 @@ export const getNotesFromPath = async (vault: Vault, path: string): Promise<TFil }); } +export async function getTagsFromNote(file: TFile, vault: Vault): Promise<string[]> { + const fileContent = await vault.cachedRead(file); + const frontMatter = parseYaml(fileContent.split('---')?.[1] ?? ''...
😂
obsidian-copilot
github_2023
typescript
288
logancyang
logancyang
@@ -151,33 +151,56 @@ const Chat: React.FC<ChatProps> = ({ } let noteFiles: TFile[] = []; - if (debug) { - console.log('Chat note context path:', settings.chatNoteContextPath); - } - if (settings.chatNoteContextPath) { - // Recursively get all note TFiles in the path - noteFiles = aw...
How is this checking for tags? This is checking the entire file content.
obsidian-copilot
github_2023
typescript
272
logancyang
logancyang
@@ -79,56 +109,105 @@ class VectorDBManager { } } - public static async getMemoryVectors(docHash: string): Promise<MemoryVector[] | undefined> { + public static async loadFile(noteFile: NoteFile, embeddingsAPI: Embeddings) { if (!this.db) throw new Error("DB not initialized"); + const textSplitter =...
Can we guarantee `memoryVectors` is always not empty?
obsidian-copilot
github_2023
typescript
272
logancyang
logancyang
@@ -79,56 +109,105 @@ class VectorDBManager { } } - public static async getMemoryVectors(docHash: string): Promise<MemoryVector[] | undefined> { + public static async loadFile(noteFile: NoteFile, embeddingsAPI: Embeddings) { if (!this.db) throw new Error("DB not initialized"); + const textSplitter =...
A chunk size of 5000 could be slightly too big for some embedding models, any particular reason for this number? ref: https://huggingface.co/spaces/mteb/leaderboard
obsidian-copilot
github_2023
typescript
272
logancyang
logancyang
@@ -79,56 +109,105 @@ class VectorDBManager { } } - public static async getMemoryVectors(docHash: string): Promise<MemoryVector[] | undefined> { + public static async loadFile(noteFile: NoteFile, embeddingsAPI: Embeddings) {
Should we call it something like `indexFile`? `load` sounds a bit strange here. I think `noteFile` is fine though, since it's a note and it contains the properties of TFile.
obsidian-copilot
github_2023
typescript
272
logancyang
logancyang
@@ -79,56 +109,105 @@ class VectorDBManager { } } - public static async getMemoryVectors(docHash: string): Promise<MemoryVector[] | undefined> { + public static async loadFile(noteFile: NoteFile, embeddingsAPI: Embeddings) { if (!this.db) throw new Error("DB not initialized"); + const textSplitter =...
Correct me if i'm wrong, so each `noteFile` maps to one `docToSave` with its `serializedMemoryVectors`, then could there be a case when the user switches to a different embedding model at one point, starts to index new files with that model, so they end up having a memory vector store of a bunch of `serializedMemoryVec...
obsidian-copilot
github_2023
typescript
272
logancyang
logancyang
@@ -79,56 +109,105 @@ class VectorDBManager { } } - public static async getMemoryVectors(docHash: string): Promise<MemoryVector[] | undefined> { + public static async loadFile(noteFile: NoteFile, embeddingsAPI: Embeddings) { if (!this.db) throw new Error("DB not initialized"); + const textSplitter =...
`docHash` as the hash of the note path works well as the id of the entry, but do you think it's also useful to have a `hash(content)` in the entry that can be used to tell whether the note has been modified? Or is it already covered by the mtime mechanism?
obsidian-copilot
github_2023
typescript
78
logancyang
logancyang
@@ -240,7 +240,7 @@ class AIState { getEmbeddingsAPI(): Embeddings { const OpenAIEmbeddingsAPI = new OpenAIEmbeddings({ - openAIApiKey: this.langChainParams.openAIApiKey, + openAIApiKey: this.langChainParams.openAIApiKey || this.langChainParams.azureOpenAIApiKey,
This is actually not going to fix it, pls refer to my other comment.
obsidian-copilot
github_2023
typescript
38
logancyang
logancyang
@@ -101,7 +101,7 @@ export class CopilotSettingTab extends PluginSettingTab { }) ) .addText((text) =>{ - text.inputEl.type = "number"; + text.inputEl.type = "decimal";
Could you point me to the `decimal` type HTML specification? How does it behave compared to `number`?
langfuse-python
github_2023
python
1,154
langfuse
greptile-apps[bot]
@@ -142,6 +142,7 @@ def _next(self): total_size += item_size if total_size >= MAX_BATCH_SIZE_BYTES: self._log.debug("hit batch size limit (size: %d)", total_size) + raise RuntimeError(f"hit batch size limit (size: {total_size})") ...
logic: Unreachable code: 'break' statement after 'raise' will never execute ```suggestion raise RuntimeError(f"hit batch size limit (size: {total_size})") ```