Skip to content
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

docs[patch]: Use llama3 in example docs #6180

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/core_docs/docs/integrations/chat/ollama.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import OllamaExample from "@examples/models/chat/integration_ollama.ts";

<CodeBlock language="typescript">{OllamaExample}</CodeBlock>

:::tip
See a LangSmith trace of the above example [here](https://smith.langchain.com/public/c4f3cb1a-4496-40bd-854c-898118b21809/r)
:::

## Tools

Ollama now offers support for native tool calling. The example below demonstrates how you can invoke a tool from an Ollama model.
Expand Down Expand Up @@ -61,7 +65,7 @@ import OllamaJSONModeExample from "@examples/models/chat/integration_ollama_json
<CodeBlock language="typescript">{OllamaJSONModeExample}</CodeBlock>

:::tip
You can see a simple LangSmith trace of this [here](https://smith.langchain.com/public/1fbd5660-b7fd-41c3-9d3a-a6ecc735277c/r)
You can see a simple LangSmith trace of this [here](https://smith.langchain.com/public/54c0430c-0d59-4121-b1ca-34ac1e95e0bb/r)
:::

## Multimodal models
Expand Down
24 changes: 17 additions & 7 deletions examples/src/models/chat/integration_ollama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StringOutputParser } from "@langchain/core/output_parsers";

const model = new ChatOllama({
baseUrl: "http://localhost:11434", // Default value
model: "llama2", // Default value
model: "llama3",
});

const stream = await model
Expand All @@ -18,13 +18,23 @@ for await (const chunk of stream) {
console.log(chunks.join(""));

/*
Thank you for your question! I'm happy to help. However, I must point out that the phrase "I love programming" is not grammatically correct in German. The word "love" does not have a direct translation in German, and it would be more appropriate to say "I enjoy programming" or "I am passionate about programming."
The translation of "I love programming" into German is:
In German, you can express your enthusiasm for something like this:
Ich liebe Programmieren.
* Ich möchte Programmieren (I want to program)
* Ich mag Programmieren (I like to program)
* Ich bin passioniert über Programmieren (I am passionate about programming)
Here's a breakdown of the translation:
I hope this helps! Let me know if you have any other questions.
* Ich = I
* liebe = love
* Programmieren = programming (note: this word is the infinitive form, which is often used in informal contexts or when speaking about one's profession or hobby)
If you want to make it sound more formal or use the correct verb conjugation for "I", you can say:
Ich bin ein großer Fan von Programmieren.
This translates to:
I am a big fan of programming.
In this sentence, "bin" is the first person singular present tense of the verb "sein", which means "to be". The phrase "ein großer Fan" means "a big fan".
*/
15 changes: 8 additions & 7 deletions examples/src/models/chat/integration_ollama_json_mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const prompt = ChatPromptTemplate.fromMessages([

const model = new ChatOllama({
baseUrl: "http://localhost:11434", // Default value
model: "llama2", // Default value
model: "llama3",
format: "json",
});

Expand All @@ -26,11 +26,12 @@ console.log(result);

/*
AIMessage {
content: '{\n' +
'"original": "I love programming",\n' +
'"translated": "Ich liebe Programmierung"\n' +
'}',
response_metadata: { ... },
usage_metadata: { ... }
"content": "{\n\"original\": \"I love programming\",\n\"translated\": \"Ich liebe Programmieren\"\n}",
"response_metadata": { ... },
"usage_metadata": {
"input_tokens": 47,
"output_tokens": 20,
"total_tokens": 67
}
}
*/
Loading