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",