-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
community[major]: DeepInfra llm and chat #5672
Merged
jacoblee93
merged 27 commits into
langchain-ai:main
from
ovuruska:feat/deepinfra-llm-and-chat
Jun 11, 2024
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
d48eb29
Init
ovuruska f361789
fix(type errors)
ovuruska 09b9fee
feat(deepinfra embeddings)
ovuruska c778987
fix(default model)
ovuruska b50fa6b
Merge pull request #1 from ovuruska/DeepInfra-embeddings-integration
ovuruska 945f7b9
fix(deepinfra): axios is removed
ovuruska 87e5977
ref(deepinfra): remove redundant cast
ovuruska d50c600
format(deepinfra)
ovuruska 76242e8
doc(deepinfra)
ovuruska 29707e7
doc(deepinfra)
ovuruska e2f2f50
Merge branch 'main' into main
ovuruska e495ed1
Update deepinfra.mdx
jacoblee93 69bb8ff
Merge branch 'main' of https://github.com/hwchase17/langchainjs into …
jacoblee93 ce10418
Format
jacoblee93 90ee4fd
Merge branch 'langchain-ai:main' into main
ovuruska fafea9b
feat(deepinfra): implement llm and chat.
ovuruska 08929fe
ref(deepinfra): lint and prettier
ovuruska 936bdd4
ref(deepinfra): remove console.log
ovuruska 69ef80a
fix(chatdeepinfra): body
ovuruska 49ac1a2
fix(import map): deepinfra
ovuruska 699ec9e
fix(gitignore)
ovuruska 4e2355f
Merge branch 'main' into feat/deepinfra-llm-and-chat
ovuruska 98f34c5
revert(.gitignore)
ovuruska a791836
Merge remote-tracking branch 'origin/feat/deepinfra-llm-and-chat' int…
ovuruska 1ce74c4
revert(.gitignore)
ovuruska 765e75e
Merge branch 'main' of https://github.com/hwchase17/langchainjs into …
jacoblee93 f5059dc
Adds docs
jacoblee93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
sidebar_label: Deep Infra | ||
--- | ||
|
||
import CodeBlock from "@theme/CodeBlock"; | ||
|
||
# ChatDeepInfra | ||
|
||
LangChain supports chat models hosted by [Deep Infra](https://deepinfra.com/) through the `ChatDeepInfra` wrapper. | ||
First, you'll need to install the `@langchain/community` package: | ||
|
||
import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx"; | ||
|
||
<IntegrationInstallTooltip></IntegrationInstallTooltip> | ||
|
||
```bash npm2yarn | ||
npm install @langchain/community | ||
``` | ||
|
||
You'll need to obtain an API key and set it as an environment variable named `DEEPINFRA_API_TOKEN` | ||
(or pass it into the constructor), then call the model as shown below: | ||
|
||
import Example from "@examples/models/chat/integration_deepinfra.ts"; | ||
|
||
<CodeBlock language="typescript">{Example}</CodeBlock> |
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,25 @@ | ||
--- | ||
sidebar_label: Deep Infra | ||
--- | ||
|
||
import CodeBlock from "@theme/CodeBlock"; | ||
|
||
# DeepInfra | ||
|
||
LangChain supports LLMs hosted by [Deep Infra](https://deepinfra.com/) through the `DeepInfra` wrapper. | ||
First, you'll need to install the `@langchain/community` package: | ||
|
||
import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx"; | ||
|
||
<IntegrationInstallTooltip></IntegrationInstallTooltip> | ||
|
||
```bash npm2yarn | ||
npm install @langchain/community | ||
``` | ||
|
||
You'll need to obtain an API key and set it as an environment variable named `DEEPINFRA_API_TOKEN` | ||
(or pass it into the constructor), then call the model as shown below: | ||
|
||
import Example from "@examples/models/llm/deepinfra.ts"; | ||
|
||
<CodeBlock language="typescript">{Example}</CodeBlock> |
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,17 @@ | ||
import { ChatDeepInfra } from "@langchain/community/chat_models/deepinfra"; | ||
import { HumanMessage } from "@langchain/core/messages"; | ||
|
||
const apiKey = process.env.DEEPINFRA_API_TOKEN; | ||
|
||
const model = "meta-llama/Meta-Llama-3-70B-Instruct"; | ||
|
||
const chat = new ChatDeepInfra({ | ||
model, | ||
apiKey, | ||
}); | ||
|
||
const messages = [new HumanMessage("Hello")]; | ||
|
||
const res = await chat.invoke(messages); | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { DeepInfraLLM } from "@langchain/community/llms/deepinfra"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey there! I've reviewed the code and flagged a change related to accessing environment variables for the maintainers to review. Please take a look at the comment for more details. Let me know if you need further assistance! |
||
|
||
const apiKey = process.env.DEEPINFRA_API_TOKEN; | ||
const model = "meta-llama/Meta-Llama-3-70B-Instruct"; | ||
|
||
const llm = new DeepInfraLLM({ | ||
temperature: 0.7, | ||
maxTokens: 20, | ||
model, | ||
apiKey, | ||
maxRetries: 5, | ||
}); | ||
|
||
const res = await llm.invoke( | ||
"What is the next step in the process of making a good game?" | ||
); | ||
|
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there! I've reviewed the code changes, and it looks like the addition of accessing the environment variable
DEEPINFRA_API_TOKEN
usingprocess.env
has been flagged for your review. Please take a look at the related change and ensure it aligns with the project's requirements. Let me know if you need further assistance!