feat: create modelfile from models

This commit is contained in:
Timothy J. Baek
2024-06-05 09:52:58 -07:00
parent ec7c5a3f07
commit 950073c1de
2 changed files with 176 additions and 13 deletions
+21 -13
View File
@@ -369,21 +369,29 @@ export const generateChatCompletion = async (token: string = '', body: object) =
return [res, controller];
};
export const createModel = async (token: string, tagName: string, content: string) => {
export const createModel = async (
token: string,
tagName: string,
content: string,
urlIdx: string | null = null
) => {
let error = null;
const res = await fetch(`${OLLAMA_API_BASE_URL}/api/create`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
},
body: JSON.stringify({
name: tagName,
modelfile: content
})
}).catch((err) => {
const res = await fetch(
`${OLLAMA_API_BASE_URL}/api/create${urlIdx !== null ? `/${urlIdx}` : ''}`,
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
},
body: JSON.stringify({
name: tagName,
modelfile: content
})
}
).catch((err) => {
error = err;
return null;
});