From fa3892da911f3e0f1e03714f55f6ebcda5a2a4bc Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 21 Feb 2024 16:50:26 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20clean=20up=20hf=20inference=20pr?= =?UTF-8?q?ovider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/llm/llms/HuggingFaceInferenceAPI.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/core/llm/llms/HuggingFaceInferenceAPI.ts b/core/llm/llms/HuggingFaceInferenceAPI.ts index 81c29e79a..1bd6d3a2a 100644 --- a/core/llm/llms/HuggingFaceInferenceAPI.ts +++ b/core/llm/llms/HuggingFaceInferenceAPI.ts @@ -1,12 +1,9 @@ import { BaseLLM } from ".."; -import { CompletionOptions, LLMOptions, ModelProvider } from "../.."; +import { CompletionOptions, ModelProvider } from "../.."; import { streamSse } from "../stream"; class HuggingFaceInferenceAPI extends BaseLLM { static providerName: ModelProvider = "huggingface-inference-api"; - static defaultOptions: Partial | undefined = { - apiBase: "https://api-inference.huggingface.co", - }; private _convertArgs(options: CompletionOptions) { return { @@ -21,7 +18,13 @@ class HuggingFaceInferenceAPI extends BaseLLM { prompt: string, options: CompletionOptions ): AsyncGenerator { - const response = await this.fetch(`${this.apiBase}`, { + if (!this.apiBase) { + throw new Error( + "No API base URL provided. Please add the `apiBase` field in your config.json." + ); + } + + const response = await this.fetch(this.apiBase, { headers: { Authorization: `Bearer ${this.apiKey}`, "Content-Type": "application/json",