File size: 740 Bytes
c9d42cc
cce8120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use client';
"use client";

import {useState} from "react";
import models from "../services/models/client";

export default function useModels(){

const [loading,setLoading]=useState(false);

async function exec(fn,...args){

setLoading(true);

try{

const {data}=await fn(...args);

return data;

}finally{

setLoading(false);

}

}

return{

loading,

list:(...a)=>exec(models.list,...a),

running:(...a)=>exec(models.running,...a),

download:(...a)=>exec(models.download,...a),

load:(...a)=>exec(models.load,...a),

unload:(...a)=>exec(models.unload,...a),

remove:(...a)=>exec(models.remove,...a),

chat:(...a)=>exec(models.chat,...a),

embeddings:(...a)=>exec(models.embeddings,...a),

health:(...a)=>exec(models.health,...a)

};

}