index.d.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. export declare class DifyClient {
  13. constructor(apiKey: string, baseUrl?: string);
  14. updateApiKey(apiKey: string): void;
  15. sendRequest(
  16. method: RequestMethods,
  17. endpoint: string,
  18. data?: any,
  19. params?: Params,
  20. stream?: boolean,
  21. headerParams?: HeaderParams
  22. ): Promise<any>;
  23. messageFeedback(message_id: string, rating: number, user: User): Promise<any>;
  24. getApplicationParameters(user: User): Promise<any>;
  25. fileUpload(data: FormData): Promise<any>;
  26. textToAudio(text: string ,user: string, streaming?: boolean): Promise<any>;
  27. getMeta(user: User): Promise<any>;
  28. }
  29. export declare class CompletionClient extends DifyClient {
  30. createCompletionMessage(
  31. inputs: any,
  32. user: User,
  33. stream?: boolean,
  34. files?: File[] | null
  35. ): Promise<any>;
  36. }
  37. export declare class ChatClient extends DifyClient {
  38. createChatMessage(
  39. inputs: any,
  40. query: string,
  41. user: User,
  42. stream?: boolean,
  43. conversation_id?: string | null,
  44. files?: File[] | null
  45. ): Promise<any>;
  46. getSuggested(message_id: string, user: User): Promise<any>;
  47. stopMessage(task_id: string, user: User) : Promise<any>;
  48. getConversations(
  49. user: User,
  50. first_id?: string | null,
  51. limit?: number | null,
  52. pinned?: boolean | null
  53. ): Promise<any>;
  54. getConversationMessages(
  55. user: User,
  56. conversation_id?: string,
  57. first_id?: string | null,
  58. limit?: number | null
  59. ): Promise<any>;
  60. renameConversation(conversation_id: string, name: string, user: User,auto_generate:boolean): Promise<any>;
  61. deleteConversation(conversation_id: string, user: User): Promise<any>;
  62. audioToText(data: FormData): Promise<any>;
  63. }
  64. export declare class WorkflowClient extends DifyClient {
  65. run(inputs: any, user: User, stream?: boolean,): Promise<any>;
  66. stop(task_id: string, user: User): Promise<any>;
  67. }