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
17 changes: 4 additions & 13 deletions src/__tests__/SentientAI.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@ describe("SentientAI", () => {
it("should throw if FAST_LLM_MODEL is not set", () => {
delete process.env.FAST_LLM_MODEL;
expect(() => new SentientAI()).toThrow(
"FAST_LLM_MODEL and LLM_MODEL must be set",
"FAST_LLM_MODEL and LLM_MODEL must be set"
);
});

it("should throw if LLM_MODEL is not set", () => {
delete process.env.LLM_MODEL;
expect(() => new SentientAI()).toThrow(
"FAST_LLM_MODEL and LLM_MODEL must be set",
"FAST_LLM_MODEL and LLM_MODEL must be set"
);
});

it("should throw if both models are not set", () => {
delete process.env.FAST_LLM_MODEL;
delete process.env.LLM_MODEL;
expect(() => new SentientAI()).toThrow(
"FAST_LLM_MODEL and LLM_MODEL must be set",
"FAST_LLM_MODEL and LLM_MODEL must be set"
);
});

Expand All @@ -88,7 +88,6 @@ describe("SentientAI", () => {

describe("getRawData", () => {
it("should return raw data for an enabled tool", async () => {
process.env.ENABLED_TOOLS = "weather-current";
const sentai = new SentientAI();
const params = { latitude: 37.7749, longitude: -122.4194 };
const result = await sentai.getRawData("weather-current", params);
Expand All @@ -99,15 +98,7 @@ describe("SentientAI", () => {
process.env.ENABLED_TOOLS = "weather-current";
const sentai = new SentientAI();
await expect(sentai.getRawData("non-existent-tool", {})).rejects.toThrow(
"Tool 'non-existent-tool' not found",
);
});

it("should throw when tool is not enabled", async () => {
process.env.ENABLED_TOOLS = "weather-current";
const sentai = new SentientAI();
await expect(sentai.getRawData("weather-forecast", {})).rejects.toThrow(
"Tool 'weather-forecast' is not enabled",
"Tool 'non-existent-tool' not found"
);
});
});
Expand Down
7 changes: 2 additions & 5 deletions src/sentientAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class SentientAI {
toolName: string,
params: Record<string, any>
): Promise<any> {
const tool = this.getTool(toolName);
const tool = this.getRawTool(toolName);
return this.rawDataProvider.process(tool, params);
}

Expand All @@ -48,14 +48,11 @@ export class SentientAI {
return this.orchestrator.processStream(input);
}

private getTool(toolName: string): QSTool {
private getRawTool(toolName: string): QSTool {
const tool = ToolRegistry.getTool(toolName as ToolName);
if (!tool) {
throw new Error(`Tool '${toolName}' not found`);
}
if (!ToolRegistry.isEnabled(toolName as ToolName)) {
throw new Error(`Tool '${toolName}' is not enabled`);
}
return tool;
}
}
Expand Down