diff --git a/AIClasses/FunctionDefinitions/AIFunctionDefinition.ts b/AIClasses/FunctionDefinitions/AIFunctionDefinition.ts new file mode 100644 index 0000000..7d125a3 --- /dev/null +++ b/AIClasses/FunctionDefinitions/AIFunctionDefinition.ts @@ -0,0 +1,9 @@ +export interface FunctionDefinition { + name: string; + description: string; + parameters: { + type: string; + properties: Record; + required?: string[]; + }; + } \ No newline at end of file diff --git a/AIClasses/FunctionDefinitions/ListVaultFiles.ts b/AIClasses/FunctionDefinitions/ListVaultFiles.ts new file mode 100644 index 0000000..da1f9b7 --- /dev/null +++ b/AIClasses/FunctionDefinitions/ListVaultFiles.ts @@ -0,0 +1,14 @@ +import { AIFunction } from "Enums/AIFunction"; +import type { FunctionDefinition } from "./AIFunctionDefinition"; + +export const ListVaultFiles: FunctionDefinition = { + name: AIFunction.ListVaultFiles, + description: `Returns complete list of vault files with metadata (names, paths, sizes). + Call this whenever you need to know what files exist in the vault to answer questions, + verify file presence, or to perform further agentic functions. Use proactively + when vault contents would inform your response.`, + parameters: { + type: "object", + properties: {} + } +} \ No newline at end of file diff --git a/AIClasses/Gemini/Gemini.ts b/AIClasses/Gemini/Gemini.ts index bbe4d79..09634fe 100644 --- a/AIClasses/Gemini/Gemini.ts +++ b/AIClasses/Gemini/Gemini.ts @@ -1,7 +1,5 @@ import { Resolve } from "Services/DependencyService"; import { Services } from "Services/Services"; -import type { IActioner } from "Actioner/IActioner"; -import type { GeminiActionDefinitions } from "Actioner/Gemini/GeminiActionDefinitions"; import type { IAIClass } from "AIClasses/IAIClass"; import type { IPrompt } from "AIClasses/IPrompt"; import { StreamingService, type StreamChunk } from "Services/StreamingService"; @@ -11,23 +9,15 @@ import { Role } from "Enums/Role"; export class Gemini implements IAIClass { private readonly apiKey: string; private readonly aiPrompt: IPrompt; - private readonly actionDefinitions: GeminiActionDefinitions; private readonly streamingService: StreamingService; public constructor(apiKey: string) { this.apiKey = apiKey; this.aiPrompt = Resolve(Services.IPrompt); - this.actionDefinitions = Resolve(Services.IActionDefinitions); this.streamingService = new StreamingService(); } - /** - * Stream response from Gemini API - */ - public async* streamRequest( - conversation: Conversation, - actioner: IActioner - ): AsyncGenerator { + public async* streamRequest(conversation: Conversation): AsyncGenerator { const contents = conversation.contents.map(content => ({ role: content.role === Role.User ? "user" : "model", @@ -53,7 +43,7 @@ export class Gemini implements IAIClass { tools: [ { google_search: {}, - //TODO: functionDeclarations: [this.actionDefinitions[create_file]], + functionDeclarations: [], }, ] }; diff --git a/AIClasses/IAIClass.ts b/AIClasses/IAIClass.ts index 9a1f6dc..fdb2c45 100644 --- a/AIClasses/IAIClass.ts +++ b/AIClasses/IAIClass.ts @@ -1,7 +1,6 @@ -import type { IActioner } from "Actioner/IActioner"; import type { StreamChunk } from "Services/StreamingService"; import type { Conversation } from "Conversations/Conversation"; export interface IAIClass { - streamRequest(conversation: Conversation, actioner: IActioner): AsyncGenerator; + streamRequest(conversation: Conversation): AsyncGenerator; } \ No newline at end of file diff --git a/AIClasses/IPrompt.ts b/AIClasses/IPrompt.ts index da6036a..f8b2ffe 100644 --- a/AIClasses/IPrompt.ts +++ b/AIClasses/IPrompt.ts @@ -1,5 +1,5 @@ import type AIAgentPlugin from "main"; -import type { TAbstractFile, TFile, Vault } from "obsidian"; +import type { TFile, Vault } from "obsidian"; import { Resolve } from "Services/DependencyService"; import { Services } from "Services/Services"; import { SystemInstruction } from "./SystemPrompt"; diff --git a/Actioner/Actioner.ts b/Actioner/Actioner.ts deleted file mode 100644 index 08a641f..0000000 --- a/Actioner/Actioner.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { create_file } from "./Actions"; -import type { IActioner } from "./IActioner"; -import type { Vault } from "obsidian"; -import { Resolve } from "Services/DependencyService"; -import { Services } from "Services/Services"; -import type AIAgentPlugin from "main"; - -export class Actioner implements IActioner { - - private vault: Vault; - - public constructor() { - this.vault = Resolve(Services.AIAgentPlugin).app.vault; - } - - public async [create_file](action: CreateFileRequest) { - //await createDirectories(this.vault, action.file_path); - await this.vault.create(action.file_path, JSON.stringify(action.file_content, null, 4)); - } -} \ No newline at end of file diff --git a/Actioner/Actions.ts b/Actioner/Actions.ts deleted file mode 100644 index f72a6d7..0000000 --- a/Actioner/Actions.ts +++ /dev/null @@ -1,9 +0,0 @@ -const request_directories: symbol = Symbol.for("request_directories"); -const request_contents: symbol = Symbol.for("request_contents"); -const create_schema: symbol = Symbol.for("create_schema"); -const create_file: symbol = Symbol.for("create_file"); -const delete_file: symbol = Symbol.for("delete_file"); -const edit_file: symbol = Symbol.for("edit_file"); -const rename_file: symbol = Symbol.for("rename_file"); - -export { request_directories, request_contents, create_schema, create_file, delete_file, edit_file, rename_file }; \ No newline at end of file diff --git a/Actioner/Gemini/GeminiActionDefinitions.ts b/Actioner/Gemini/GeminiActionDefinitions.ts deleted file mode 100644 index 6c43467..0000000 --- a/Actioner/Gemini/GeminiActionDefinitions.ts +++ /dev/null @@ -1,131 +0,0 @@ -import { Type } from "@google/genai"; -import { create_file, create_schema, delete_file, edit_file, rename_file, request_contents, request_directories } from "Actioner/Actions"; -import type { IActionDefinitions } from "Actioner/IActionDefinitions"; - -export class GeminiActionDefinitions implements IActionDefinitions { - public [request_directories](): object { - return { - name: "request_directories", - description: "Request the available user directories. Call this for further available functions", - parameters: {} - }; - } - - public [request_contents](): object { - return { - name: "request_contents", - description: "Request the contents of a file. The contents will be added using the Files API", - parameters: { - type: Type.OBJECT, - properties: { - file_path: { - type: Type.STRING, - description: "The file path of the file to be requested" - } - }, - requited: ["file_path"] - } - }; - } - - public [create_schema](): object { - return { - name: "create_schema", - description: "Create a new data definition schema for the user", - parameters: { - type: Type.OBJECT, - properties: { - file_path: { - type: Type.STRING, - description: "The file path of the schema to be created" - }, - schema_content: { - type: Type.OBJECT, - description: "The schema definition where each field is the property name and each value is the default property value. Nested properties are accepted" - } - }, - required: ["file_path", "file_content"] - } - }; - } - - public [create_file](): object { - return { - name: "create_file", - description: "Create a new file for the user", - parameters: { - type: Type.OBJECT, - properties: { - file_path: { - type: Type.STRING, - description: "The file path of the file to be created" - }, - file_content: { - type: Type.STRING, - description: "The content of the file to be created" - } - }, - required: ["file_path", "file_content"] - } - }; - } - - public [delete_file](): object { - return { - name: "delete_file", - description: "Request a file to be deleted", - parameters: { - type: Type.OBJECT, - properties: { - file_path: { - type: Type.STRING, - description: "The file path of the file to be deleted" - } - }, - requited: ["file_path"] - } - }; - } - - public [edit_file](): object { - return { - name: "edit_file", - description: "Edit the contents of an existing file", - parameters: { - type: Type.OBJECT, - properties: { - file_path: { - type: Type.STRING, - description: "The file path of the file to be edited" - }, - file_content: { - type: Type.STRING, - description: "The new content of the file to be written" - } - }, - requited: ["file_path, file_content"] - } - }; - } - - public [rename_file](): object { - return { - name: "rename_file", - description: "Rename or move a file", - parameters: { - type: Type.OBJECT, - properties: { - old_file_path: { - type: Type.STRING, - description: "The old file path of the file" - }, - new_file_path: { - type: Type.STRING, - description: "The new file path of the file" - } - }, - requited: ["old_file_path", "new_file_path"] - } - }; - } -} \ No newline at end of file diff --git a/Actioner/IActionDefinitions.ts b/Actioner/IActionDefinitions.ts deleted file mode 100644 index b29e068..0000000 --- a/Actioner/IActionDefinitions.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { create_file, create_schema, delete_file, edit_file, rename_file, request_contents, request_directories } from "./Actions"; - -export interface IActionDefinitions { - [request_directories](): object; - [request_contents](): object; - [create_schema](): object; - [create_file](): object; - [delete_file](): object; - [edit_file](): object; - [rename_file](): object; -} \ No newline at end of file diff --git a/Actioner/IActioner.ts b/Actioner/IActioner.ts deleted file mode 100644 index 13a70d1..0000000 --- a/Actioner/IActioner.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface IActioner { - [key: symbol]: (...args: any[]) => any; -} \ No newline at end of file diff --git a/Components/ChatWindow.svelte b/Components/ChatWindow.svelte index 28016c8..a106afa 100644 --- a/Components/ChatWindow.svelte +++ b/Components/ChatWindow.svelte @@ -1,5 +1,4 @@