Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"id": "poneglyph",
"name": "Poneglyph",
"version": "0.5.1",
"version": "0.5.2",
"minAppVersion": "0.15.0",
"description": "Research Assistant as you second brain!",
"description": "AI-powered research tool that turns your notes into a living knowledge graph.",
"author": "kausthub-kannan",
"authorUrl": "https://obsidian.md",
"authorUrl": "https://github.com/kausthub-kannan",
"isDesktopOnly": true
}
21 changes: 17 additions & 4 deletions src/backend/utils/model-provider.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { ChatMistralAI } from "@langchain/mistralai";
import { ChatOpenAI } from "@langchain/openai";
import { ChatAnthropic } from "@langchain/anthropic";
import { ChatOllama } from "@langchain/ollama";
import { HTTPClient } from "@mistralai/mistralai";
import { requestUrl } from "obsidian";
import type { GraphQuerySettings } from "settings";

export const modelDirectory = {
"mistral": ChatMistralAI
"mistral": ChatMistralAI,
"openai": ChatOpenAI,
"anthropic": ChatAnthropic,
"ollama": ChatOllama,
} as const;

type SupportedProvider = keyof typeof modelDirectory;
Expand All @@ -15,14 +21,12 @@ const obsidianHttpClient = new HTTPClient({
request.headers.forEach((value, key) => {
headers[key] = value;
});

const response = await requestUrl({
url: request.url,
method: request.method,
headers: headers,
body: request.body ? await new Response(request.body).text() : undefined,
});

return new Response(response.text, {
status: response.status,
headers: response.headers,
Expand All @@ -41,12 +45,21 @@ const getModel = (
throw new Error(`Provider "${settings.modelProvider}" is not supported.`);
}

// Ollama runs locally and doesn't need an API key or custom HTTP client
if (provider === "ollama") {
return new ChatOllama({
model: settings.modelID,
temperature: temperature,
baseUrl: settings.modelBaseURL || "http://localhost:11434",
});
}

// @ts-expect-error dynamic class instantiation
return new ModelClass({
model: settings.modelID,
temperature: temperature,
apiKey: settings.modelAPIKey,
httpClient: obsidianHttpClient,
...(provider === "mistral" && { httpClient: obsidianHttpClient }),
});
};

Expand Down
Loading
Loading