Spaces:
Paused
Paused
Download src/lib/server/textGeneration/utils/toolPrompt.spec.ts from Mike0021/chat-ui-agent-demo: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/Mike0021/chat-ui-agent-demo/resolve/main/src/lib/server/textGeneration/utils/toolPrompt.spec.ts
- Command line
-
hf download hf://spaces/Mike0021/chat-ui-agent-demo/src/lib/server/textGeneration/utils/toolPrompt.spec.ts
-
curl -L -o toolPrompt.spec.ts https://huggingface.co/spaces/Mike0021/chat-ui-agent-demo/resolve/main/src/lib/server/textGeneration/utils/toolPrompt.spec.ts
1.06 kB
| import { describe, expect, it } from "vitest"; | |
| import { buildToolPreprompt } from "./toolPrompt"; | |
| import type { OpenAiTool } from "$lib/server/mcp/tools"; | |
| const tool = (name: string): OpenAiTool => | |
| ({ | |
| type: "function", | |
| function: { name, description: "", parameters: { type: "object", properties: {} } }, | |
| }) as OpenAiTool; | |
| describe("buildToolPreprompt", () => { | |
| it("returns empty string when no tools", () => { | |
| expect(buildToolPreprompt([])).toBe(""); | |
| }); | |
| it("lists tool names and includes grounding rules", () => { | |
| const prompt = buildToolPreprompt([tool("web_search_exa"), tool("crawling_exa")]); | |
| expect(prompt).toContain("web_search_exa, crawling_exa"); | |
| expect(prompt).toContain("GROUNDING:"); | |
| expect(prompt).toContain("only source of facts"); | |
| expect(prompt).toContain("Never fabricate URLs, citations, or facts"); | |
| }); | |
| it("tells the model to follow up instead of answering from memory", () => { | |
| const prompt = buildToolPreprompt([tool("web_search_exa")]); | |
| expect(prompt).toContain("instead of answering from memory"); | |
| }); | |
| }); | |