Skip to content

Commit

Permalink
Adds docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Jun 11, 2024
1 parent 765e75e commit f5059dc
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 23 deletions.
25 changes: 25 additions & 0 deletions docs/core_docs/docs/integrations/chat/deep_infra.mdx
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>
25 changes: 25 additions & 0 deletions docs/core_docs/docs/integrations/llms/deep_infra.mdx
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>
18 changes: 0 additions & 18 deletions examples/src/llms/deepinfra.ts

This file was deleted.

6 changes: 3 additions & 3 deletions examples/src/models/chat/integration_deepinfra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ const chat = new ChatDeepInfra({

const messages = [new HumanMessage("Hello")];

chat.invoke(messages).then((response: any) => {
console.log(response);
});
const res = await chat.invoke(messages);

console.log(res);
4 changes: 4 additions & 0 deletions examples/src/models/llm/deepinfra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ 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 });
2 changes: 0 additions & 2 deletions libs/langchain-community/src/chat_models/deepinfra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ export class ChatDeepInfra
false,
options?.signal
).then<ChatCompletionResponse>((data) => {

if (data?.code) {
throw new Error(data?.message);
}
Expand Down Expand Up @@ -184,7 +183,6 @@ export class ChatDeepInfra
stream: boolean,
signal?: AbortSignal
) {

const body = {
temperature: this.temperature,
max_tokens: this.maxTokens,
Expand Down

0 comments on commit f5059dc

Please sign in to comment.