Commit 0c441b58 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

refac: naming convention

parent a938ffb5
import { OLLAMA_API_BASE_URL } from '$lib/constants'; import { OLLAMA_API_BASE_URL } from '$lib/constants';
import { templatePrompt } from '$lib/utils'; import { promptTemplate } from '$lib/utils';
export const getOllamaUrls = async (token: string = '') => { export const getOllamaUrls = async (token: string = '') => {
let error = null; let error = null;
...@@ -145,7 +145,7 @@ export const generateTitle = async ( ...@@ -145,7 +145,7 @@ export const generateTitle = async (
) => { ) => {
let error = null; let error = null;
template = templatePrompt(template, prompt); template = promptTemplate(template, prompt);
console.log(template); console.log(template);
......
import { OPENAI_API_BASE_URL } from '$lib/constants'; import { OPENAI_API_BASE_URL } from '$lib/constants';
import { templatePrompt } from '$lib/utils'; import { promptTemplate } from '$lib/utils';
export const getOpenAIUrls = async (token: string = '') => { export const getOpenAIUrls = async (token: string = '') => {
let error = null; let error = null;
...@@ -274,7 +274,7 @@ export const generateTitle = async ( ...@@ -274,7 +274,7 @@ export const generateTitle = async (
) => { ) => {
let error = null; let error = null;
template = templatePrompt(template, prompt); template = promptTemplate(template, prompt);
console.log(template); console.log(template);
......
...@@ -468,12 +468,12 @@ export const blobToFile = (blob, fileName) => { ...@@ -468,12 +468,12 @@ export const blobToFile = (blob, fileName) => {
return file; return file;
}; };
// templatePrompt replaces any occurrences of the following in the template with the prompt // promptTemplate replaces any occurrences of the following in the template with the prompt
// {{prompt}} will be replaced with the prompt // {{prompt}} will be replaced with the prompt
// {{prompt:start:<length>}} will be replaced with the first <length> characters of the prompt // {{prompt:start:<length>}} will be replaced with the first <length> characters of the prompt
// {{prompt:end:<length>}} will be replaced with the last <length> characters of the prompt // {{prompt:end:<length>}} will be replaced with the last <length> characters of the prompt
// Character length is used as we don't have the ability to tokenize the prompt // Character length is used as we don't have the ability to tokenize the prompt
export const templatePrompt = (template: string, prompt: string) => { export const promptTemplate = (template: string, prompt: string) => {
template = template.replace(/{{prompt}}/g, prompt); template = template.replace(/{{prompt}}/g, prompt);
// Replace all instances of {{prompt:start:<length>}} with the first <length> characters of the prompt // Replace all instances of {{prompt:start:<length>}} with the first <length> characters of the prompt
...@@ -493,6 +493,7 @@ export const templatePrompt = (template: string, prompt: string) => { ...@@ -493,6 +493,7 @@ export const templatePrompt = (template: string, prompt: string) => {
} }
return template; return template;
};
export const approximateToHumanReadable = (nanoseconds: number) => { export const approximateToHumanReadable = (nanoseconds: number) => {
const seconds = Math.floor((nanoseconds / 1e9) % 60); const seconds = Math.floor((nanoseconds / 1e9) % 60);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment