Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

Add tool type to chat completion requests

Akarshan7f25311d26f9
diff --git a/core/src/browser/extensions/engines/AIEngine.ts b/core/src/browser/extensions/engines/AIEngine.ts
index a0ce5669c..c3288d241 100644
--- a/core/src/browser/extensions/engines/AIEngine.ts
+++ b/core/src/browser/extensions/engines/AIEngine.ts
@@ -22,10 +22,26 @@ export interface InputAudio {
format: 'mp3' | 'wav' | 'ogg' | 'flac' // Add more formats as needed/llama-server seems to support mp3
}
-export interface chatCompletionRequest {
- model: string // Model ID, though for local it might be implicit via sessionInfo
- messages: chatCompletionRequestMessage[]
+export interface ToolFunction {
+ name: string; // Required: a-z, A-Z, 0-9, _, - (max length: 64)
+ description?: string; // Optional
+ parameters?: Record<string, unknown>; // Optional: JSON Schema object
+ strict?: boolean | null; // Optional: defaults to false
+ type: 'function'
+}
+
+export interface ToolCall {
+ function: ToolFunction;
+}
+export interface ToolDefinition {
+ tools?: ToolCall[];
+}
+
+export interface chatCompletionRequest {
+ model: string; // Model ID, though for local it might be implicit via sessionInfo
+ messages: chatCompletionRequestMessage[];
+ tools?: ToolFunction[];
// Core sampling parameters
temperature?: number | null
dynatemp_range?: number | null