You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.d.ts 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Types.d.ts
  2. export const BASE_URL: string;
  3. export type RequestMethods = 'GET' | 'POST' | 'PATCH' | 'DELETE';
  4. interface Params {
  5. [key: string]: any;
  6. }
  7. interface HeaderParams {
  8. [key: string]: string;
  9. }
  10. interface User {
  11. }
  12. interface DifyFileBase {
  13. type: "image"
  14. }
  15. export interface DifyRemoteFile extends DifyFileBase {
  16. transfer_method: "remote_url"
  17. url: string
  18. }
  19. export interface DifyLocalFile extends DifyFileBase {
  20. transfer_method: "local_file"
  21. upload_file_id: string
  22. }
  23. export type DifyFile = DifyRemoteFile | DifyLocalFile;
  24. export declare class DifyClient {
  25. constructor(apiKey: string, baseUrl?: string);
  26. updateApiKey(apiKey: string): void;
  27. sendRequest(
  28. method: RequestMethods,
  29. endpoint: string,
  30. data?: any,
  31. params?: Params,
  32. stream?: boolean,
  33. headerParams?: HeaderParams
  34. ): Promise<any>;
  35. messageFeedback(message_id: string, rating: number, user: User): Promise<any>;
  36. getApplicationParameters(user: User): Promise<any>;
  37. fileUpload(data: FormData): Promise<any>;
  38. textToAudio(text: string ,user: string, streaming?: boolean): Promise<any>;
  39. getMeta(user: User): Promise<any>;
  40. }
  41. export declare class CompletionClient extends DifyClient {
  42. createCompletionMessage(
  43. inputs: any,
  44. user: User,
  45. stream?: boolean,
  46. files?: DifyFile[] | null
  47. ): Promise<any>;
  48. }
  49. export declare class ChatClient extends DifyClient {
  50. createChatMessage(
  51. inputs: any,
  52. query: string,
  53. user: User,
  54. stream?: boolean,
  55. conversation_id?: string | null,
  56. files?: DifyFile[] | null
  57. ): Promise<any>;
  58. getSuggested(message_id: string, user: User): Promise<any>;
  59. stopMessage(task_id: string, user: User) : Promise<any>;
  60. getConversations(
  61. user: User,
  62. first_id?: string | null,
  63. limit?: number | null,
  64. pinned?: boolean | null
  65. ): Promise<any>;
  66. getConversationMessages(
  67. user: User,
  68. conversation_id?: string,
  69. first_id?: string | null,
  70. limit?: number | null
  71. ): Promise<any>;
  72. renameConversation(conversation_id: string, name: string, user: User,auto_generate:boolean): Promise<any>;
  73. deleteConversation(conversation_id: string, user: User): Promise<any>;
  74. audioToText(data: FormData): Promise<any>;
  75. }
  76. export declare class WorkflowClient extends DifyClient {
  77. run(inputs: any, user: User, stream?: boolean,): Promise<any>;
  78. stop(task_id: string, user: User): Promise<any>;
  79. }