index.d.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 ChatMessageConfig {
  13. inputs: any;
  14. query: string;
  15. user: User;
  16. stream?: boolean;
  17. conversation_id?: string | null;
  18. files?: File[] | null;
  19. }
  20. export declare class DifyClient {
  21. constructor(apiKey: string, baseUrl?: string);
  22. updateApiKey(apiKey: string): void;
  23. sendRequest(
  24. method: RequestMethods,
  25. endpoint: string,
  26. data?: any,
  27. params?: Params,
  28. stream?: boolean,
  29. headerParams?: HeaderParams
  30. ): Promise<any>;
  31. messageFeedback(message_id: string, rating: number, user: User): Promise<any>;
  32. getApplicationParameters(user: User): Promise<any>;
  33. fileUpload(data: FormData): Promise<any>;
  34. }
  35. export declare class CompletionClient extends DifyClient {
  36. createCompletionMessage(
  37. inputs: any,
  38. user: User,
  39. stream?: boolean,
  40. files?: File[] | null
  41. ): Promise<any>;
  42. }
  43. export declare class ChatClient extends DifyClient {
  44. createChatMessage(config: ChatMessageConfig): Promise<any>;
  45. getConversationMessages(
  46. user: User,
  47. conversation_id?: string,
  48. first_id?: string | null,
  49. limit?: number | null
  50. ): Promise<any>;
  51. getConversations(user: User, first_id?: string | null, limit?: number | null, pinned?: boolean | null): Promise<any>;
  52. renameConversation(conversation_id: string, name: string, user: User): Promise<any>;
  53. deleteConversation(conversation_id: string, user: User): Promise<any>;
  54. }