forked from langchain-ai/langchainjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Made requesed changes * Formatted --------- Co-authored-by: Vis <vishakanshanthakumar@gmail.com>
- Loading branch information
1 parent
3af7179
commit 4207132
Showing
8 changed files
with
244 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
# Azure Machine Learning Chat | ||
|
||
You can deploy models on Azure with the endpointUrl, apiKey, and deploymentName | ||
You must deploy models on Azure with the endpointUrl, apiKey, and deploymentName | ||
when creating the AzureMLChatParams to call upon later. Must import a ContentFormatter | ||
or create your own using the ChatContentFormatter interface. | ||
|
||
```typescript | ||
import { AzureMLChatParams, LlamaContentFormatter } from "langchain/chat_models/azure_ml"; | ||
import { | ||
AzureMLChatParams, | ||
LlamaContentFormatter, | ||
} from "langchain/chat_models/azure_ml"; | ||
|
||
const model = new AzureMLModel({ | ||
endpointUrl: "YOUR_ENDPOINT_URL", | ||
endpointApiKey: "YOUR_ENDPOINT_API_KEY", | ||
deploymentName: "YOUR_MODEL_DEPLOYMENT_NAME", | ||
contentFormatter: new LlamaContentFormatter() | ||
const model = new AzureMLOnlineEndpoint({ | ||
endpointUrl: "YOUR_ENDPOINT_URL", | ||
endpointApiKey: "YOUR_ENDPOINT_API_KEY", | ||
deploymentName: "YOUR_MODEL_DEPLOYMENT_NAME", | ||
contentFormatter: new LlamaContentFormatter(), | ||
}); | ||
|
||
const res = model.call(["Foo"]); | ||
const res = model.invoke(["Foo"]); | ||
console.log({ res }); | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
# Azure Machine Learning | ||
|
||
You can deploy models on Azure with the endpointUrl, apiKey, and deploymentName | ||
when creating the AzureMLModel to call upon later. Must import a ContentFormatter | ||
You must deploy models on Azure with the endpointUrl, apiKey, and deploymentName | ||
when creating the AzureMLOnlineEndpoint to call upon later. Must import a ContentFormatter | ||
or create your own using the ContentFormatter interface. | ||
|
||
```typescript | ||
import { AzureMLModel, LlamaContentFormatter } from "langchain/llms/azure_ml"; | ||
import { | ||
AzureMLOnlineEndpoint, | ||
LlamaContentFormatter, | ||
} from "langchain/llms/azure_ml"; | ||
|
||
const model = new AzureMLModel({ | ||
endpointUrl: "YOUR_ENDPOINT_URL", | ||
endpointApiKey: "YOUR_ENDPOINT_API_KEY", | ||
deploymentName: "YOUR_MODEL_DEPLOYMENT_NAME", | ||
contentFormatter: new LlamaContentFormatter() | ||
const model = new AzureMLOnlineEndpoint({ | ||
endpointUrl: "YOUR_ENDPOINT_URL", | ||
endpointApiKey: "YOUR_ENDPOINT_API_KEY", | ||
deploymentName: "YOUR_MODEL_DEPLOYMENT_NAME", | ||
contentFormatter: new LlamaContentFormatter(), | ||
}); | ||
|
||
const res = model.call("Foo"); | ||
const res = model.invoke("Foo"); | ||
console.log({ res }); | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import { AzureMLChatModel, LlamaContentFormatter } from "langchain/chat_models/azure_ml"; | ||
import { | ||
AzureMLChatOnlineEndpoint, | ||
LlamaContentFormatter, | ||
} from "langchain/chat_models/azure_ml"; | ||
|
||
const model = new AzureMLChatModel({ | ||
endpointUrl: "YOUR_ENDPOINT_URL", // Or set as process.env.AZURE_ML_ENDPOINTURL | ||
endpointApiKey: "YOUR_ENDPOINT_API_KEY", // Or set as process.env.AZURE_ML_APIKEY | ||
deploymentName: "YOUR_MODEL_DEPLOYMENT_NAME", // Or set as process.env.AZURE_ML_NAME | ||
contentFormatter: new LlamaContentFormatter(), // Only LLAMA currently supported. | ||
const model = new AzureMLChatOnlineEndpoint({ | ||
endpointUrl: "YOUR_ENDPOINT_URL", // Or set as process.env.AZURE_ML_ENDPOINTURL | ||
endpointApiKey: "YOUR_ENDPOINT_API_KEY", // Or set as process.env.AZURE_ML_APIKEY | ||
contentFormatter: new LlamaContentFormatter(), // Only LLAMA currently supported. | ||
}); | ||
|
||
const res = model.call("Foo"); | ||
const res = model.invoke("Foo"); | ||
|
||
console.log({ res }); | ||
console.log({ res }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import { AzureMLModel, LlamaContentFormatter } from "langchain/llms/azure_ml"; | ||
import { | ||
AzureMLOnlineEndpoint, | ||
LlamaContentFormatter, | ||
} from "langchain/llms/azure_ml"; | ||
|
||
const model = new AzureMLModel({ | ||
endpointUrl: "YOUR_ENDPOINT_URL", // Or set as process.env.AZURE_ML_ENDPOINTURL | ||
endpointApiKey: "YOUR_ENDPOINT_API_KEY", // Or set as process.env.AZURE_ML_APIKEY | ||
deploymentName: "YOUR_MODEL_DEPLOYMENT_NAME", // Or set as process.env.AZURE_ML_NAME | ||
contentFormatter: new LlamaContentFormatter(), // Or any of the other Models: GPT2ContentFormatter, HFContentFormatter, DollyContentFormatter | ||
const model = new AzureMLOnlineEndpoint({ | ||
endpointUrl: "YOUR_ENDPOINT_URL", // Or set as process.env.AZURE_ML_ENDPOINTURL | ||
endpointApiKey: "YOUR_ENDPOINT_API_KEY", // Or set as process.env.AZURE_ML_APIKEY | ||
deploymentName: "YOUR_MODEL_DEPLOYMENT_NAME", // Or set as process.env.AZURE_ML_NAME | ||
contentFormatter: new LlamaContentFormatter(), // Or any of the other Models: GPT2ContentFormatter, HFContentFormatter, DollyContentFormatter | ||
}); | ||
|
||
const res = model.call("Foo"); | ||
const res = model.invoke("Foo"); | ||
|
||
console.log({ res }); | ||
console.log({ res }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import { test, expect } from "@jest/globals"; | ||
import { AzureMLChatModel, LlamaContentFormatter } from "../azure_ml.js"; | ||
import { | ||
AzureMLChatOnlineEndpoint, | ||
LlamaContentFormatter, | ||
} from "../azure_ml.js"; | ||
|
||
test("Test AzureML LLama Call", async () => { | ||
const prompt = "Hi Llama!"; | ||
const chat = new AzureMLChatModel({ | ||
contentFormatter: new LlamaContentFormatter() | ||
}); | ||
const res = await chat.call([prompt]); | ||
expect(typeof res).toBe("string"); | ||
console.log(res); | ||
}); | ||
const prompt = "Hi Llama!"; | ||
const chat = new AzureMLChatOnlineEndpoint({ | ||
contentFormatter: new LlamaContentFormatter(), | ||
}); | ||
|
||
const res = await chat.call([prompt]); | ||
expect(typeof res).toBe("string"); | ||
|
||
console.log(res); | ||
}); |
Oops, something went wrong.