( input: StructuredGenerateInput, onEvent?: (event: GenerateStreamEvent) => void, accessToken?: string )
| 164 | } |
| 165 | |
| 166 | export async function generateSkillStructured( |
| 167 | input: StructuredGenerateInput, |
| 168 | onEvent?: (event: GenerateStreamEvent) => void, |
| 169 | accessToken?: string |
| 170 | ): Promise<GenerateSkillResponse> { |
| 171 | const headers: Record<string, string> = { "Content-Type": "application/json" }; |
| 172 | if (accessToken) { |
| 173 | headers["Authorization"] = `Bearer ${accessToken}`; |
| 174 | } |
| 175 | |
| 176 | const response = await fetch(`${baseUrl}/api/v2/skills/generate`, { |
| 177 | method: "POST", |
| 178 | headers, |
| 179 | body: JSON.stringify(input), |
| 180 | }); |
| 181 | |
| 182 | const libraryName = input.libraries[0]?.name || "skill"; |
| 183 | return handleGenerateResponse(response, libraryName, onEvent); |
| 184 | } |
| 185 | |
| 186 | async function handleGenerateResponse( |
| 187 | response: Response, |
no test coverage detected