Skip to content

Commit

Permalink
Standardize llama.cpp endpoint with baseURL (#1305)
Browse files Browse the repository at this point in the history
* Standardize llama.cpp endpoint with `baseURL`

* cleaner
  • Loading branch information
nsarrazin committed Jun 25, 2024
1 parent ed1011d commit 08541fb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/server/endpoints/llamacpp/endpointLlamacpp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export const endpointLlamacppParametersSchema = z.object({
weight: z.number().int().positive().default(1),
model: z.any(),
type: z.literal("llamacpp"),
url: z.string().url().default("http://127.0.0.1:8080"),
url: z.string().url().default("http://127.0.0.1:8080"), // legacy, feel free to remove in breaking change update
baseURL: z.string().url().optional(),
accessToken: z
.string()
.min(1)
Expand All @@ -19,7 +20,7 @@ export const endpointLlamacppParametersSchema = z.object({
export function endpointLlamacpp(
input: z.input<typeof endpointLlamacppParametersSchema>
): Endpoint {
const { url, model } = endpointLlamacppParametersSchema.parse(input);
const { baseURL, url, model } = endpointLlamacppParametersSchema.parse(input);
return async ({ messages, preprompt, continueMessage, generateSettings }) => {
const prompt = await buildPrompt({
messages,
Expand All @@ -30,7 +31,7 @@ export function endpointLlamacpp(

const parameters = { ...model.parameters, ...generateSettings };

const r = await fetch(`${url}/completion`, {
const r = await fetch(`${baseURL ?? url}/completion`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down

0 comments on commit 08541fb

Please sign in to comment.