diff options
| author | Dax Raad <[email protected]> | 2025-05-26 21:08:15 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-05-26 21:08:22 -0400 |
| commit | e5242093526e407f829cd9eee1e90b7286d100f7 (patch) | |
| tree | fe9b43a7d96b32435783e9c3370f4e45b640482b /js/src/session/session.ts | |
| parent | e1c897c1aed381aa07354f398417aeff6a720471 (diff) | |
| download | opencode-e5242093526e407f829cd9eee1e90b7286d100f7.tar.gz opencode-e5242093526e407f829cd9eee1e90b7286d100f7.zip | |
title
Diffstat (limited to 'js/src/session/session.ts')
| -rw-r--r-- | js/src/session/session.ts | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/js/src/session/session.ts b/js/src/session/session.ts index 4def98283..c8a941e40 100644 --- a/js/src/session/session.ts +++ b/js/src/session/session.ts @@ -6,6 +6,7 @@ import { Storage } from "../storage/storage"; import { Log } from "../util/log"; import { convertToModelMessages, + generateText, stepCountIs, streamText, type TextUIPart, @@ -17,7 +18,9 @@ import { import { z } from "zod"; import * as tools from "../tool"; -import ANTHROPIC_PROMPT from "./prompt/anthropic.txt"; +import PROMPT_ANTHROPIC from "./prompt/anthropic.txt"; +import PROMPT_TITLE from "./prompt/title.txt"; + import type { Tool } from "../tool/tool"; import { Share } from "../share/share"; @@ -120,6 +123,7 @@ export namespace Session { sessionID: string, ...parts: UIMessagePart<UIDataTypes>[] ) { + const model = await LLM.findModel("claude-sonnet-4-20250514"); const session = await get(sessionID); const l = log.clone().tag("session", sessionID); l.info("chatting"); @@ -138,7 +142,7 @@ export namespace Session { parts: [ { type: "text", - text: ANTHROPIC_PROMPT, + text: PROMPT_ANTHROPIC, }, ], metadata: { @@ -151,6 +155,28 @@ export namespace Session { }; msgs.push(system); state().messages.set(sessionID, msgs); + generateText({ + messages: convertToModelMessages([ + { + role: "system", + parts: [ + { + type: "text", + text: PROMPT_TITLE, + }, + ], + }, + { + role: "user", + parts, + }, + ]), + model, + }).then(async (result) => { + const session = await Session.get(sessionID); + session.title = result.text; + return Session.update(session); + }); await write(system); } const msg: Message = { @@ -168,7 +194,6 @@ export namespace Session { msgs.push(msg); await write(msg); - const model = await LLM.findModel("claude-sonnet-4-20250514"); const result = streamText({ stopWhen: stepCountIs(1000), messages: convertToModelMessages(msgs), |
