Spaces:
Paused
Paused
Download src/lib/server/textGeneration/reasoning.ts from Mike0021/chat-ui-agent-demo: direct link, hf CLI and curl.
- Browser
- Download file 765 Bytes
-
https://huggingface.co/spaces/Mike0021/chat-ui-agent-demo/resolve/main/src/lib/server/textGeneration/reasoning.ts
- Command line
-
hf download hf://spaces/Mike0021/chat-ui-agent-demo/src/lib/server/textGeneration/reasoning.ts
-
curl -L -o reasoning.ts https://huggingface.co/spaces/Mike0021/chat-ui-agent-demo/resolve/main/src/lib/server/textGeneration/reasoning.ts
765 Bytes
| import { generateFromDefaultEndpoint } from "$lib/server/generateFromDefaultEndpoint"; | |
| import { MessageUpdateType } from "$lib/types/MessageUpdate"; | |
| export async function generateSummaryOfReasoning( | |
| reasoning: string, | |
| modelId: string | undefined, | |
| locals: App.Locals | undefined | |
| ): Promise<string> { | |
| const prompt = `Summarize concisely the following reasoning for the user. Keep it short (one short paragraph).\n\n${reasoning}`; | |
| const summary = await (async () => { | |
| const it = generateFromDefaultEndpoint({ | |
| messages: [{ from: "user", content: prompt }], | |
| modelId, | |
| locals, | |
| }); | |
| let out = ""; | |
| for await (const update of it) { | |
| if (update.type === MessageUpdateType.Stream) out += update.token; | |
| } | |
| return out; | |
| })(); | |
| return summary.trim(); | |
| } | |