stream.ts 1010 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import type { NgxConfig } from '@/api/ngx'
  2. import type { ChatComplicationMessage } from '@/api/openai'
  3. import Curd from '@/api/curd'
  4. import http from '@/lib/http'
  5. export interface Stream {
  6. modified_at: string
  7. advanced: boolean
  8. enabled: boolean
  9. name: string
  10. filepath: string
  11. config: string
  12. chatgpt_messages: ChatComplicationMessage[]
  13. tokenized?: NgxConfig
  14. }
  15. class StreamCurd extends Curd<Stream> {
  16. // eslint-disable-next-line ts/no-explicit-any
  17. enable(name: string, config?: any) {
  18. return http.post(`${this.baseUrl}/${name}/enable`, undefined, config)
  19. }
  20. disable(name: string) {
  21. return http.post(`${this.baseUrl}/${name}/disable`)
  22. }
  23. duplicate(name: string, data: { name: string }): Promise<{ dst: string }> {
  24. return http.post(`${this.baseUrl}/${name}/duplicate`, data)
  25. }
  26. advance_mode(name: string, data: { advanced: boolean }) {
  27. return http.post(`${this.baseUrl}/${name}/advance`, data)
  28. }
  29. }
  30. const stream = new StreamCurd('/streams')
  31. export default stream