From 988ceae514d90707e89a28f7666da323520aafee Mon Sep 17 00:00:00 2001 From: Eric Zhou Date: Thu, 21 Dec 2023 09:55:44 -0500 Subject: [PATCH] ran eslint on azure_ml files --- langchain/src/chat_models/azure_ml.ts | 19 ++++++++++--------- langchain/src/llms/azure_ml.ts | 20 +++++++++++++++++--- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/langchain/src/chat_models/azure_ml.ts b/langchain/src/chat_models/azure_ml.ts index 1e16297916b7..150ec6c33706 100644 --- a/langchain/src/chat_models/azure_ml.ts +++ b/langchain/src/chat_models/azure_ml.ts @@ -41,9 +41,7 @@ export class LlamaContentFormatter implements ChatContentFormatter { messages: BaseMessage[], modelArgs: Record ): string { - let msgs = messages.map((message) => { - this._convertMessageToRecord(message); - }); + const msgs = messages.map((message) => this._convertMessageToRecord(message)); return JSON.stringify({ input_data: { input_string: msgs, @@ -78,13 +76,19 @@ export class AzureMLChatOnlineEndpoint static lc_name() { return "AzureMLChatOnlineEndpoint"; } + static lc_description() { return "A class for interacting with AzureML Chat models."; } + endpointUrl: string; + endpointApiKey: string; + modelArgs?: Record; + contentFormatter: ChatContentFormatter; + httpClient: AzureMLHttpClient; constructor(fields: AzureMLChatParams) { @@ -100,9 +104,9 @@ export class AzureMLChatOnlineEndpoint } this.endpointUrl = - fields.endpointUrl || getEnvironmentVariable("AZUREML_URL") + ""; + fields.endpointUrl || `${getEnvironmentVariable("AZUREML_URL") }`; this.endpointApiKey = - fields.endpointApiKey || getEnvironmentVariable("AZUREML_API_KEY") + ""; + fields.endpointApiKey || `${getEnvironmentVariable("AZUREML_API_KEY") }`; this.httpClient = new AzureMLHttpClient( this.endpointUrl, this.endpointApiKey @@ -110,6 +114,7 @@ export class AzureMLChatOnlineEndpoint this.contentFormatter = fields.contentFormatter; this.modelArgs = fields?.modelArgs; } + get _identifying_params() { const modelKwargs = this.modelArgs || {}; return { @@ -122,10 +127,6 @@ export class AzureMLChatOnlineEndpoint return "azureml_chat"; } - _combineLLMOutput(): Record | undefined { - return []; - } - async _call( messages: BaseMessage[], modelArgs: Record diff --git a/langchain/src/llms/azure_ml.ts b/langchain/src/llms/azure_ml.ts index bcfe1cf40410..49f21a3633af 100644 --- a/langchain/src/llms/azure_ml.ts +++ b/langchain/src/llms/azure_ml.ts @@ -3,7 +3,9 @@ import { getEnvironmentVariable } from "../util/env.js"; export class AzureMLHttpClient { endpointUrl: string; + endpointApiKey: string; + deploymentName?: string; constructor( @@ -78,6 +80,7 @@ export class GPT2ContentFormatter implements ContentFormatter { parameters: modelArgs, }); } + formatResponsePayload(output: string): string { return JSON.parse(output)[0]["0"]; } @@ -93,8 +96,9 @@ export class HFContentFormatter implements ContentFormatter { parameters: modelArgs, }); } + formatResponsePayload(output: string): string { - return JSON.parse(output)[0]["generated_text"]; + return JSON.parse(output)[0].generated_text; } } @@ -110,6 +114,7 @@ export class DollyContentFormatter implements ContentFormatter { parameters: modelArgs, }); } + formatResponsePayload(output: string): string { return JSON.parse(output)[0]; } @@ -127,6 +132,7 @@ export class LlamaContentFormatter implements ContentFormatter { parameters: modelArgs, }); } + formatResponsePayload(output: string): string { return JSON.parse(output)[0]["0"]; } @@ -149,12 +155,15 @@ export class AzureMLOnlineEndpoint extends LLM implements AzureMLParams { _llmType() { return "azure_ml"; } + static lc_name() { return "AzureMLOnlineEndpoint"; } + static lc_description() { return "A class for interacting with AzureML models."; } + static lc_fields() { return { endpointUrl: { @@ -175,10 +184,15 @@ export class AzureMLOnlineEndpoint extends LLM implements AzureMLParams { } endpointUrl: string; + endpointApiKey: string; + deploymentName?: string; + contentFormatter: ContentFormatter; + modelArgs?: Record; + httpClient: AzureMLHttpClient; constructor(fields: AzureMLParams) { @@ -194,9 +208,9 @@ export class AzureMLOnlineEndpoint extends LLM implements AzureMLParams { } this.endpointUrl = - fields.endpointUrl || getEnvironmentVariable("AZUREML_URL") + ""; + fields.endpointUrl || `${getEnvironmentVariable("AZUREML_URL") }`; this.endpointApiKey = - fields.endpointApiKey || getEnvironmentVariable("AZUREML_API_KEY") + ""; + fields.endpointApiKey || `${getEnvironmentVariable("AZUREML_API_KEY") }`; this.deploymentName = fields.deploymentName; this.httpClient = new AzureMLHttpClient( this.endpointUrl,