Files
AirCoding/test-oc.ts
AirCoding ae44be31d5 chore: push all design docs, V2 plan specs, and current working state
Includes AirPlan design documents, AircOding-alpha1-plan, AirPlanV2,
AirPlan-ParaV2, AirPlan-Para V1 reference docs, and all working code
changes across packages.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-12 17:12:29 +08:00

40 lines
1.4 KiB
TypeScript
Executable File

import { Effect } from "effect"
const { configure } = await import("./packages/llm/src/opencode/providers/openai-compatible.js")
const { LLMClient } = await import("./packages/llm/src/opencode/route/client.js")
const { LLMRequest, Message } = await import("./packages/llm/src/opencode/schema/index.js")
const { RequestExecutor } = await import("./packages/llm/src/opencode/route/executor.js")
const apiKey = process.env.AIRCODING_API_KEY || ""
if (!apiKey) { console.log("NO_KEY"); process.exit(0) }
const baseURL = process.env.AIRCODING_API_URL || "https://open.bigmodel.cn/api/paas/v4"
const provider = configure({ baseURL, apiKey })
const model = provider.model("glm-5.1")
const req = new LLMRequest({
model,
messages: [Message.user("say ok")],
generation: { maxTokens: 10 },
})
const executor = RequestExecutor.Service.of({
http: RequestExecutor.HttpExecutor.make({ fetch: globalThis.fetch }),
webSocket: undefined,
})
const program = Effect.gen(function* () {
const resp = yield* LLMClient.generate(req)
const texts: string[] = []
for (const ev of resp.events) {
const e = ev as any
if (e.text) texts.push(e.text)
if (e.content) for (const c of e.content) if (c.text) texts.push(c.text)
}
return texts.join("")
})
const layer = LLMClient.layer.pipe(Effect.provide(executor))
const result = await Effect.runPromise(Effect.provide(program, layer))
console.log("OK:", result)