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.
Nc/fix axios adapter imports (langchain-ai#149)
* Fix axios adapter imports * Add missing dependency needed for hugginface llm * Fallback to axios (node-only) for openai streaming mode) as the axios fetch adapter doesn't directly support consuming SSE
- Loading branch information
Showing
6 changed files
with
38 additions
and
10 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
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,8 +1,26 @@ | ||
import { test } from "@jest/globals"; | ||
import { test, expect } from "@jest/globals"; | ||
import { OpenAI } from "../openai.js"; | ||
|
||
test("Test OpenAI", async () => { | ||
const model = new OpenAI({ maxTokens: 5, modelName: "text-ada-001" }); | ||
const res = await model.call("Print hello world"); | ||
console.log({ res }); | ||
}); | ||
|
||
test("Test OpenAI in streaming mode", async () => { | ||
let nrNewTokens = 0; | ||
const model = new OpenAI({ | ||
maxTokens: 5, | ||
modelName: "text-ada-001", | ||
streaming: true, | ||
callbackManager: { | ||
handleNewToken() { | ||
nrNewTokens += 1; | ||
}, | ||
}, | ||
}); | ||
const res = await model.call("Print hello world"); | ||
console.log({ res }); | ||
|
||
expect(nrNewTokens > 0).toBe(true); | ||
}); |
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 |
---|---|---|
|
@@ -38,4 +38,4 @@ | |
"dependencies": { | ||
"turbo": "^1.7.4" | ||
} | ||
} | ||
} |
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