index.d.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. }
  27. export declare class CompletionClient extends DifyClient {
  28. createCompletionMessage(
  29. inputs: any,
  30. user: User,
  31. stream?: boolean,
  32. files?: File[] | null
  33. ): Promise<any>;
  34. }
  35. export declare class ChatClient extends DifyClient {
  36. createChatMessage(
  37. inputs: any,
  38. query: string,
  39. user: User,
  40. stream?: boolean,
  41. conversation_id?: string | null,
  42. files?: File[] | null
  43. ): Promise<any>;
  44. getConversationMessages(
  45. user: User,
  46. conversation_id?: string,
  47. first_id?: string | null,
  48. limit?: number | null
  49. ): Promise<any>;
  50. getConversations(user: User, first_id?: string | null, limit?: number | null, pinned?: boolean | null): Promise<any>;
  51. renameConversation(conversation_id: string, name: string, user: User): Promise<any>;
  52. deleteConversation(conversation_id: string, user: User): Promise<any>;
  53. }