feat: add v2 generate text endpoint (#34371)
This commit is contained in:
parent
7073e8797f
commit
595c6bd4a7
12 changed files with 462 additions and 233 deletions
35
packages/protocol/src/groups/generate.ts
Normal file
35
packages/protocol/src/groups/generate.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { Model } from "@opencode-ai/schema/model"
|
||||
import { Schema } from "effect"
|
||||
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi"
|
||||
import { InvalidRequestError, ServiceUnavailableError } from "../errors"
|
||||
import { LocationQuery, locationQueryOpenApi } from "./location"
|
||||
|
||||
export const GenerateGroup = HttpApiGroup.make("server.generate")
|
||||
.add(
|
||||
HttpApiEndpoint.post("generate.text", "/api/generate", {
|
||||
query: LocationQuery,
|
||||
payload: Schema.Struct({
|
||||
prompt: Schema.String,
|
||||
model: Model.Ref.pipe(Schema.optional),
|
||||
}),
|
||||
success: Schema.Struct({
|
||||
data: Schema.Struct({ text: Schema.String }),
|
||||
}).annotate({ identifier: "GenerateTextResponse" }),
|
||||
error: [InvalidRequestError, ServiceUnavailableError],
|
||||
})
|
||||
.annotateMerge(locationQueryOpenApi)
|
||||
.annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "v2.generate.text",
|
||||
summary: "Generate text",
|
||||
description:
|
||||
"Run one stateless model generation at the requested location and return the assistant text. Uses the location's default model when none is specified.",
|
||||
}),
|
||||
),
|
||||
)
|
||||
.annotateMerge(
|
||||
OpenApi.annotations({
|
||||
title: "generate",
|
||||
description: "Experimental one-shot generation routes.",
|
||||
}),
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue