llm.ts 1.1 KB

12345678910111213141516171819202122232425262728
  1. export * as LLM from "./llm"
  2. import { Schema } from "effect"
  3. import { optional } from "./schema"
  4. export const ProviderMetadata = Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.Unknown)).annotate({
  5. identifier: "LLM.ProviderMetadata",
  6. })
  7. export type ProviderMetadata = Schema.Schema.Type<typeof ProviderMetadata>
  8. export interface ToolTextContent extends Schema.Schema.Type<typeof ToolTextContent> {}
  9. export const ToolTextContent = Schema.Struct({
  10. type: Schema.Literal("text"),
  11. text: Schema.String,
  12. }).annotate({ identifier: "Tool.TextContent" })
  13. export interface ToolFileContent extends Schema.Schema.Type<typeof ToolFileContent> {}
  14. export const ToolFileContent = Schema.Struct({
  15. type: Schema.Literal("file"),
  16. uri: Schema.String,
  17. mime: Schema.String,
  18. name: optional(Schema.String),
  19. }).annotate({ identifier: "Tool.FileContent" })
  20. export const ToolContent = Schema.Union([ToolTextContent, ToolFileContent])
  21. .pipe(Schema.toTaggedUnion("type"))
  22. .annotate({ identifier: "LLM.ToolContent" })
  23. export type ToolContent = Schema.Schema.Type<typeof ToolContent>