Skip to content

Commit

Permalink
feat: optional endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Googlefan committed Jun 6, 2024
1 parent 048163f commit e1c2b38
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/chat/llama.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { request } from "undici";
import type { Chat, ChatModel } from ".";
import { evar } from "../var";
import { evarOptional } from "../var";

const endpoint = evar("LLAMA_CPP_ENDPOINT");
const endpoint = evarOptional("LLAMA_CPP_ENDPOINT");

function resolveAttachment(attachment?: {
mime: string;
Expand All @@ -24,6 +24,9 @@ async function* generate(chat: Chat[], system?: string) {
text: system,
});
}
if (!endpoint) {
throw new Error("LLAMA_CPP_ENDPOINT not set");
}
const res = await request(endpoint, {
method: "POST",
headers: {
Expand Down

0 comments on commit e1c2b38

Please sign in to comment.