feat: enable title generation prompt edit

This commit is contained in:
Timothy J. Baek 2024-02-21 12:51:52 -08:00
parent a2088989ca
commit 05ea6cf6fd
4 changed files with 41 additions and 5 deletions

View file

@ -133,9 +133,19 @@ export const getOllamaModels = async (token: string = '') => {
});
};
export const generateTitle = async (token: string = '', model: string, prompt: string) => {
// TODO: migrate to backend
export const generateTitle = async (
token: string = '',
template: string,
model: string,
prompt: string
) => {
let error = null;
template = template.replace(/{{prompt}}/g, prompt);
console.log(template);
const res = await fetch(`${OLLAMA_API_BASE_URL}/generate`, {
method: 'POST',
headers: {
@ -144,7 +154,7 @@ export const generateTitle = async (token: string = '', model: string, prompt: s
},
body: JSON.stringify({
model: model,
prompt: `Create a concise, 3-5 word phrase as a header for the following query, strictly adhering to the 3-5 word limit and avoiding the use of the word 'title': ${prompt}`,
prompt: template,
stream: false
})
})