MCPcopy
hub / github.com/Effect-TS/effect / AllParts

Function AllParts

packages/ai/ai/src/Response.ts:201–231  ·  view source on GitHub ↗
(
  toolkit: T
)

Source from the content-addressed store, hash-verified

199 * @category Schemas
200 */
201export const AllParts = <T extends Toolkit.Any | Toolkit.WithHandler<any>>(
202 toolkit: T
203): Schema.Schema<AllParts<T extends Toolkit.Any ? Toolkit.Tools<T> : Toolkit.WithHandlerTools<T>>, AllPartsEncoded> => {
204 const toolCalls: Array<Schema.Schema<ToolCallPart<string, any>, ToolCallPartEncoded>> = []
205 const toolCallResults: Array<Schema.Schema<ToolResultPart<string, any, any>, ToolResultPartEncoded>> = []
206 for (const tool of Object.values(toolkit.tools as Record<string, Tool.Any>)) {
207 toolCalls.push(ToolCallPart(tool.name, tool.parametersSchema as any))
208 toolCallResults.push(ToolResultPart(tool.name, tool.successSchema, tool.failureSchema))
209 }
210 return Schema.Union(
211 TextPart,
212 TextStartPart,
213 TextDeltaPart,
214 TextEndPart,
215 ReasoningPart,
216 ReasoningStartPart,
217 ReasoningDeltaPart,
218 ReasoningEndPart,
219 ToolParamsStartPart,
220 ToolParamsDeltaPart,
221 ToolParamsEndPart,
222 FilePart,
223 DocumentSourcePart,
224 UrlSourcePart,
225 ResponseMetadataPart,
226 FinishPart,
227 ErrorPart,
228 ...toolCalls,
229 ...toolCallResults
230 ) as any
231}
232
233// =============================================================================
234// Generate Parts

Callers

nothing calls this directly

Calls 3

ToolCallPartFunction · 0.70
ToolResultPartFunction · 0.70
valuesMethod · 0.45

Tested by

no test coverage detected