edge-runtime.d.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. declare namespace Briven {
  2. export interface ModelOptions {
  3. /**
  4. * Pool embeddings by taking their mean. Applies only for `gte-small` model
  5. */
  6. mean_pool?: boolean
  7. /**
  8. * Normalize the embeddings result. Applies only for `gte-small` model
  9. */
  10. normalize?: boolean
  11. /**
  12. * Stream response from model. Applies only for LLMs like `mistral` (default: false)
  13. */
  14. stream?: boolean
  15. /**
  16. * Automatically abort the request to the model after specified time (in seconds). Applies only for LLMs like `mistral` (default: 60)
  17. */
  18. timeout?: number
  19. /**
  20. * Mode for the inference API host. (default: 'ollama')
  21. */
  22. mode?: 'ollama' | 'openaicompatible'
  23. signal?: AbortSignal
  24. }
  25. export class Session {
  26. /**
  27. * Create a new model session using given model
  28. */
  29. constructor(model: string, sessionOptions?: unknown)
  30. /**
  31. * Execute the given prompt in model session
  32. */
  33. run(
  34. prompt:
  35. | string
  36. | Omit<import('npm:openai@^4.52.5').OpenAI.Chat.ChatCompletionCreateParams, 'model' | 'stream'>,
  37. modelOptions?: ModelOptions
  38. ): unknown
  39. }
  40. /**
  41. * Provides AI related APIs
  42. */
  43. export interface Ai {
  44. readonly Session: typeof Session
  45. }
  46. /**
  47. * Provides AI related APIs
  48. */
  49. export const ai: Ai
  50. }
  51. declare namespace EdgeRuntime {
  52. export function waitUntil<T>(promise: Promise<T>): Promise<T>
  53. }