Skip to content
Open
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
57 changes: 43 additions & 14 deletions core/llm/llms/Asksage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ToolCallDelta,
} from "../../index.js";
import { BaseLLM } from "../index.js";
import { LlmApiRequestType } from "../openaiTypeConverters.js";
import {
AskSageTool,
AskSageToolChoice,
Expand Down Expand Up @@ -63,6 +64,11 @@ class Asksage extends BaseLLM {
model: "gpt-4o",
};

protected useOpenAIAdapterFor: (LlmApiRequestType | "*")[] = [
"chat",
"streamChat",
];

private sessionTokenPromise: Promise<string> | null = null;
private tokenTimestamp: number = 0;
private email?: string;
Expand Down Expand Up @@ -383,21 +389,44 @@ class Asksage extends BaseLLM {

const data = (await response.json()) as AskSageResponse;

// Extract tool calls from response (check both top-level and choices format)
// Extract tool calls from response, preferring the unified format
const rawToolCalls =
data.tool_calls || data.choices?.[0]?.message?.tool_calls;

// Convert to ToolCallDelta format if present
const toolCalls: ToolCallDelta[] | undefined = rawToolCalls?.map(
(tc) => ({
id: tc.id,
type: tc.type,
function: {
name: tc.function.name,
arguments: tc.function.arguments,
},
}),
);
data.tool_calls_unified ||
data.tool_calls ||
data.choices?.[0]?.message?.tool_calls;

// Normalize to ToolCallDelta format (handles OpenAI, Anthropic, and unified formats)
const toolCalls: ToolCallDelta[] | undefined = rawToolCalls
?.map((tc): ToolCallDelta | undefined => {
if ("function" in tc && tc.function?.name) {
// OpenAI or unified format
const args = tc.function.arguments;
return {
id: tc.id,
type: "function" as const,
function: {
name: tc.function.name,
arguments:
typeof args === "string" ? args : JSON.stringify(args ?? {}),
},
};
} else if ("name" in tc && typeof tc.name === "string") {
// Anthropic format
const args =
tc.text ?? (tc.input ? JSON.stringify(tc.input) : "{}");
return {
id: tc.id,
type: "function" as const,
function: {
name: tc.name,
arguments:
typeof args === "string" ? args : JSON.stringify(args),
},
};
}
return undefined;
})
.filter((tc): tc is ToolCallDelta => tc !== undefined);

const assistantMessage: ChatMessage = {
role: "assistant",
Expand Down
4 changes: 4 additions & 0 deletions core/llm/toolSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =

return false;
},
askSage: (_model) => {
// Ask Sage proxies to tool-capable models (GPT-4o, Claude, Gemini, etc.)
return true;
},
};

export function isRecommendedAgentModel(modelName: string): boolean {
Expand Down
11 changes: 0 additions & 11 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 2 additions & 42 deletions extensions/vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 2 additions & 37 deletions gui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions manual-testing-sandbox/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ def subtract(self, number):
self.result -= number
return self

def multiply(self, number):
self.result *= number
return self

def divide(self, number):
if number == 0:
raise ValueError("Cannot divide by zero")
self.result /= number
return self

def reset(self):
self.result = 0
return self
Expand Down
Loading
Loading