Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Result object of endpoint function unused #2807

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/components/nodes/chatmodels/ChatHuggingFace/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class HuggingFaceInference extends LLM implements HFInput {
this.frequencyPenalty = fields?.frequencyPenalty ?? this.frequencyPenalty
this.endpoint = fields?.endpoint ?? ''
this.apiKey = fields?.apiKey ?? getEnvironmentVariable('HUGGINGFACEHUB_API_KEY')
if (!this.apiKey) {
if (!this.apiKey && !this.endpoint) {
throw new Error(
'Please set an API key for HuggingFace Hub in the environment variable HUGGINGFACEHUB_API_KEY or in the apiKey field of the HuggingFaceInference constructor.'
)
Expand All @@ -77,7 +77,7 @@ export class HuggingFaceInference extends LLM implements HFInput {
/** @ignore */
async _call(prompt: string, options: this['ParsedCallOptions']): Promise<string> {
const { HfInference } = await HuggingFaceInference.imports()
const hf = new HfInference(this.apiKey)
const hf: any = new HfInference(this.apiKey)
const obj: any = {
parameters: {
// make it behave similar to openai, returning only the generated text
Expand All @@ -91,7 +91,7 @@ export class HuggingFaceInference extends LLM implements HFInput {
inputs: prompt
}
if (this.endpoint) {
hf.endpoint(this.endpoint)
hf = hf.endpoint(this.endpoint)
} else {
obj.model = this.model
}
Expand Down
6 changes: 3 additions & 3 deletions packages/components/nodes/llms/HuggingFaceInference/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class HuggingFaceInference extends LLM implements HFInput {
this.frequencyPenalty = fields?.frequencyPenalty ?? this.frequencyPenalty
this.endpoint = fields?.endpoint ?? ''
this.apiKey = fields?.apiKey ?? getEnvironmentVariable('HUGGINGFACEHUB_API_KEY')
if (!this.apiKey) {
if (!this.apiKey && !this.endpoint) {
throw new Error(
'Please set an API key for HuggingFace Hub in the environment variable HUGGINGFACEHUB_API_KEY or in the apiKey field of the HuggingFaceInference constructor.'
)
Expand All @@ -77,7 +77,7 @@ export class HuggingFaceInference extends LLM implements HFInput {
/** @ignore */
async _call(prompt: string, options: this['ParsedCallOptions']): Promise<string> {
const { HfInference } = await HuggingFaceInference.imports()
const hf = new HfInference(this.apiKey)
const hf: any = new HfInference(this.apiKey)
const obj: any = {
parameters: {
// make it behave similar to openai, returning only the generated text
Expand All @@ -91,7 +91,7 @@ export class HuggingFaceInference extends LLM implements HFInput {
inputs: prompt
}
if (this.endpoint) {
hf.endpoint(this.endpoint)
hf = hf.endpoint(this.endpoint)
} else {
obj.model = this.model
}
Expand Down