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.
* Make openai a direct dependency * Improve streaming test * Add chatgpt LLM * Add doc
- Loading branch information
Showing
9 changed files
with
424 additions
and
75 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# OpenAI Chat | ||
|
||
This guide goes through how to use the OpenAI Chat LLM wrapper. This is designed to use the ChatGPT family of models from OpenAI. You can find more information on them [here](https://platform.openai.com/docs/guides/chat). | ||
|
||
```typescript | ||
import { OpenAIChat } from "langchain/llms"; | ||
|
||
const model = new OpenAIChat({ modelName: "gpt-3.5-turbo" }); | ||
const res = await model.call( | ||
"What would be a good company name a company that makes colorful socks?" | ||
); | ||
console.log({ res }); | ||
``` | ||
|
||
## Prefix messages | ||
|
||
You can also pass messages that the model should add before your prompt. This is useful for adding context to the model, or past conversation history. | ||
|
||
```typescript | ||
const model = new OpenAIChat({ | ||
modelName: "gpt-3.5-turbo", | ||
prefixMessages: [ | ||
{ role: "user", content: "My name is John" }, | ||
{ role: "assistant", content: "Hi there" }, | ||
], | ||
}); | ||
const res = await model.call("What is my name"); | ||
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
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
Oops, something went wrong.