Skip to content

Commit

Permalink
groq[patch]: set api key attr (#6864)
Browse files Browse the repository at this point in the history
Co-authored-by: jacoblee93 <jacoblee93@gmail.com>
  • Loading branch information
baskaryan and jacoblee93 authored Sep 23, 2024
1 parent 8fe60ef commit 6647485
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libs/langchain-groq/src/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ export class ChatGroq extends BaseChatModel<

streaming = false;

apiKey?: string;

static lc_name() {
return "ChatGroq";
}
Expand Down Expand Up @@ -690,6 +692,7 @@ export class ChatGroq extends BaseChatModel<
apiKey,
dangerouslyAllowBrowser: true,
});
this.apiKey = apiKey;
this.temperature = fields?.temperature ?? this.temperature;
this.modelName = fields?.model ?? fields?.modelName ?? this.model;
this.model = this.modelName;
Expand Down
8 changes: 8 additions & 0 deletions libs/langchain-groq/src/tests/chat_models.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ test("Serialization", () => {
`{"lc":1,"type":"constructor","id":["langchain","chat_models","groq","ChatGroq"],"kwargs":{"api_key":{"lc":1,"type":"secret","id":["GROQ_API_KEY"]}}}`
);
});

test("Serialization with no params", () => {
process.env.GROQ_API_KEY = "foo";
const model = new ChatGroq();
expect(JSON.stringify(model)).toEqual(
`{"lc":1,"type":"constructor","id":["langchain","chat_models","groq","ChatGroq"],"kwargs":{"api_key":{"lc":1,"type":"secret","id":["GROQ_API_KEY"]}}}`
);
});

0 comments on commit 6647485

Please sign in to comment.