Skip to content

Commit

Permalink
more updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Apr 9, 2024
1 parent 02d8860 commit 640c1cb
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { PromptLayerOpenAI } from "langchain/llms/openai";

const model = new PromptLayerOpenAI({
temperature: 0.9,
apiKey: "YOUR-AOAI-API-KEY", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiKey: "YOUR-AOAI-API-KEY", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiInstanceName: "YOUR-AOAI-INSTANCE-NAME", // In Node.js defaults to process.env.AZURE_OPENAI_API_INSTANCE_NAME
azureOpenAIApiDeploymentName: "YOUR-AOAI-DEPLOYMENT-NAME", // In Node.js defaults to process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME
azureOpenAIApiCompletionsDeploymentName:
Expand Down
4 changes: 2 additions & 2 deletions docs/core_docs/docs/integrations/platforms/microsoft.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { OpenAIEmbeddings } from "@langchain/openai";

```typescript
const embeddings = new OpenAIEmbeddings({
apiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiVersion: "YOUR-API-VERSION", // In Node.js defaults to process.env.AZURE_OPENAI_API_VERSION
azureOpenAIApiInstanceName: "{MY_INSTANCE_NAME}", // In Node.js defaults to process.env.AZURE_OPENAI_API_INSTANCE_NAME
azureOpenAIApiDeploymentName: "{DEPLOYMENT_NAME}", // In Node.js defaults to process.env.AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME
Expand All @@ -68,7 +68,7 @@ import { ChatOpenAI } from "@langchain/openai";
```typescript
const model = new ChatOpenAI({
temperature: 0.9,
apiKey: "SOME_SECRET_VALUE", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiKey: "SOME_SECRET_VALUE", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiVersion: "YOUR-API-VERSION", // In Node.js defaults to process.env.AZURE_OPENAI_API_VERSION
azureOpenAIApiInstanceName: "{MY_INSTANCE_NAME}", // In Node.js defaults to process.env.AZURE_OPENAI_API_INSTANCE_NAME
azureOpenAIApiDeploymentName: "{DEPLOYMENT_NAME}", // In Node.js defaults to process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ npm install @langchain/openai
import { OpenAIEmbeddings } from "@langchain/openai";

const embeddings = new OpenAIEmbeddings({
apiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiVersion: "YOUR-API-VERSION", // In Node.js defaults to process.env.AZURE_OPENAI_API_VERSION
azureOpenAIApiInstanceName: "{MY_INSTANCE_NAME}", // In Node.js defaults to process.env.AZURE_OPENAI_API_INSTANCE_NAME
azureOpenAIApiDeploymentName: "{DEPLOYMENT_NAME}", // In Node.js defaults to process.env.AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME
Expand All @@ -103,7 +103,7 @@ For example, here's how you would connect to the domain `https://westeurope.api.
import { OpenAIEmbeddings } from "@langchain/openai";

const embeddings = new OpenAIEmbeddings({
apiKey: "YOUR-API-KEY",
azureOpenAIApiKey: "YOUR-API-KEY",
azureOpenAIApiVersion: "YOUR-API-VERSION",
azureOpenAIApiDeploymentName: "{DEPLOYMENT_NAME}",
azureOpenAIBasePath:
Expand Down
2 changes: 1 addition & 1 deletion examples/src/models/chat/integration_azure_openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ChatOpenAI } from "@langchain/openai";

const model = new ChatOpenAI({
temperature: 0.9,
apiKey: "SOME_SECRET_VALUE", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiKey: "SOME_SECRET_VALUE", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiVersion: "YOUR-API-VERSION", // In Node.js defaults to process.env.AZURE_OPENAI_API_VERSION
azureOpenAIApiInstanceName: "{MY_INSTANCE_NAME}", // In Node.js defaults to process.env.AZURE_OPENAI_API_INSTANCE_NAME
azureOpenAIApiDeploymentName: "{DEPLOYMENT_NAME}", // In Node.js defaults to process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ChatOpenAI } from "@langchain/openai";

const model = new ChatOpenAI({
temperature: 0.9,
apiKey: "SOME_SECRET_VALUE", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiKey: "SOME_SECRET_VALUE", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiVersion: "YOUR-API-VERSION", // In Node.js defaults to process.env.AZURE_OPENAI_API_VERSION
azureOpenAIApiDeploymentName: "{DEPLOYMENT_NAME}", // In Node.js defaults to process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME
azureOpenAIBasePath:
Expand Down
2 changes: 1 addition & 1 deletion examples/src/models/chat/integration_fireworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { ChatFireworks } from "@langchain/community/chat_models/fireworks";
const model = new ChatFireworks({
temperature: 0.9,
// In Node.js defaults to process.env.FIREWORKS_API_KEY
fireworksApiKey: "YOUR-API-KEY",
apiKey: "YOUR-API-KEY",
});
2 changes: 1 addition & 1 deletion examples/src/models/chat/integration_togetherai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HumanMessage } from "@langchain/core/messages";
const model = new ChatTogetherAI({
temperature: 0.9,
// In Node.js defaults to process.env.TOGETHER_AI_API_KEY
togetherAIApiKey: "YOUR-API-KEY",
apiKey: "YOUR-API-KEY",
});

console.log(await model.invoke([new HumanMessage("Hello there!")]));
2 changes: 1 addition & 1 deletion examples/src/models/chat/integration_togetherai_json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const responseSchema = {
};
const modelWithJsonSchema = new ChatTogetherAI({
temperature: 0,
togetherAIApiKey: process.env.TOGETHER_AI_API_KEY,
apiKey: process.env.TOGETHER_AI_API_KEY,
model: "mistralai/Mixtral-8x7B-Instruct-v0.1",
}).bind({
response_format: {
Expand Down
2 changes: 1 addition & 1 deletion examples/src/models/chat/integration_togetherai_tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const calculatorTool = convertToOpenAITool(new Calculator());
const modelWithCalculator = new ChatTogetherAI({
temperature: 0,
// This is the default env variable name it will look for if none is passed.
togetherAIApiKey: process.env.TOGETHER_AI_API_KEY,
apiKey: process.env.TOGETHER_AI_API_KEY,
// Together JSON mode/tool calling only supports a select number of models
model: "mistralai/Mixtral-8x7B-Instruct-v0.1",
}).bind({
Expand Down
2 changes: 1 addition & 1 deletion examples/src/models/llm/fireworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { Fireworks } from "@langchain/community/llms/fireworks";
const model = new Fireworks({
temperature: 0.9,
// In Node.js defaults to process.env.FIREWORKS_API_KEY
fireworksApiKey: "YOUR-API-KEY",
apiKey: "YOUR-API-KEY",
});
4 changes: 2 additions & 2 deletions langchain/src/chat_models/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ type Kwargs = Record<string, any>;
* ```typescript
* const model = new ChatAnthropic({
* temperature: 0.9,
* apiKey: 'YOUR-API-KEY',
* anthropicApiKey: 'YOUR-API-KEY',
* });
* const res = await model.invoke({ input: 'Hello!' });
* console.log(res);
Expand All @@ -175,7 +175,7 @@ export class ChatAnthropic<

get lc_secrets(): { [key: string]: string } | undefined {
return {
apiKey: "ANTHROPIC_API_KEY",
anthropicApiKey: "ANTHROPIC_API_KEY",
};
}

Expand Down
2 changes: 1 addition & 1 deletion libs/langchain-anthropic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import { ChatAnthropicMessages } from "@langchain/anthropic";

const model = new ChatAnthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
modelName: "claude-3-sonnet-20240229",
model: "claude-3-sonnet-20240229",
});
const response = await model.stream(new HumanMessage("Hello world!"));
```
Expand Down
3 changes: 2 additions & 1 deletion libs/langchain-azure-openai/src/llms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class AzureOpenAI<

get lc_secrets(): { [key: string]: string } | undefined {
return {
apiKey: "AZURE_OPENAI_API_KEY",
openAIApiKey: "OPENAI_API_KEY",
azureOpenAIApiKey: "AZURE_OPENAI_API_KEY",
azureOpenAIEndpoint: "AZURE_OPENAI_API_ENDPOINT",
Expand Down Expand Up @@ -136,7 +137,7 @@ export class AzureOpenAI<
const openAiApiKey =
fields?.openAIApiKey ?? getEnvironmentVariable("OPENAI_API_KEY");

this.azureOpenAIApiKey =
this.azureOpenAIApiKey = fields?.apiKey ??
fields?.azureOpenAIApiKey ??
getEnvironmentVariable("AZURE_OPENAI_API_KEY") ??
openAiApiKey;
Expand Down
6 changes: 5 additions & 1 deletion libs/langchain-azure-openai/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ export declare interface OpenAIBaseInput {
/** Whether to stream the results or not. Enabling disables tokenUsage reporting */
streaming: boolean;

/** Model name to use */
/**
* Model name to use
* Alias for `model`
*/
modelName: string;
/** Model name to use */
model?: string;
Expand Down Expand Up @@ -195,6 +198,7 @@ export interface AzureOpenAIEmbeddingsParams extends EmbeddingsParams {
* The model name to provide as part of this embeddings request.
* Not applicable to Azure OpenAI, where deployment information should be included in the Azure
* resource URI that's connected to.
* Alias for `model`
*/
modelName?: string;
/**
Expand Down
6 changes: 3 additions & 3 deletions libs/langchain-community/src/chat_models/fireworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type ChatFireworksCallOptions = Partial<
* ```typescript
* const model = new ChatFireworks({
* temperature: 0.9,
* fireworksApiKey: "YOUR-API-KEY",
* apiKey: "YOUR-API-KEY",
* });
*
* const response = await model.invoke("Hello, how are you?");
Expand Down Expand Up @@ -90,8 +90,8 @@ export class ChatFireworks extends ChatOpenAI<ChatFireworksCallOptions> {

super({
...fields,
modelName: fields?.model || "accounts/fireworks/models/llama-v2-13b-chat",
openAIApiKey: fireworksApiKey,
model: fields?.model || "accounts/fireworks/models/llama-v2-13b-chat",
apiKey: fireworksApiKey,
configuration: {
baseURL: "https://api.fireworks.ai/inference/v1",
},
Expand Down
4 changes: 2 additions & 2 deletions libs/langchain-community/src/chat_models/togetherai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export class ChatTogetherAI extends ChatOpenAI<ChatTogetherAICallOptions> {

super({
...fields,
modelName: fields?.model || "mistralai/Mixtral-8x7B-Instruct-v0.1",
openAIApiKey: togetherAIApiKey,
model: fields?.model || "mistralai/Mixtral-8x7B-Instruct-v0.1",
apiKey: togetherAIApiKey,
configuration: {
baseURL: "https://api.together.xyz/v1/",
},
Expand Down
2 changes: 1 addition & 1 deletion libs/langchain-community/src/llms/togetherai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export class TogetherAI extends LLM<TogetherAICallOptions> {

private constructBody(prompt: string, options?: this["ParsedCallOptions"]) {
const body = {
model: options?.modelName ?? this?.model,
model: options?.model ?? options?.modelName ?? this?.model,
prompt,
temperature: this?.temperature ?? options?.temperature,
top_k: this?.topK ?? options?.topK,
Expand Down

0 comments on commit 640c1cb

Please sign in to comment.