Skip to content

Commit

Permalink
docs: update chat engine docs (#1648)
Browse files Browse the repository at this point in the history
  • Loading branch information
thucpn authored Feb 12, 2025
1 parent 6a4a737 commit a87efb9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-eggs-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@llamaindex/doc": patch
---

docs: update chat engine docs
17 changes: 17 additions & 0 deletions apps/next/src/content/docs/llamaindex/modules/chat_engine.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,26 @@ const chatEngine = new ContextChatEngine({ retriever });
const response = await chatEngine.chat({ message: query });
```

In short, you can use the chat engine by calling `index.asChatEngine()`. It will return a `ContextChatEngine` to start chatting.

```typescript
const chatEngine = index.asChatEngine();
```

You can also pass in options to the chat engine.

```typescript
const chatEngine = index.asChatEngine({
similarityTopK: 5,
systemPrompt: "You are a helpful assistant.",
});
```


The `chat` function also supports streaming, just add `stream: true` as an option:

```typescript
const chatEngine = index.asChatEngine();
const stream = await chatEngine.chat({ message: query, stream: true });
for await (const chunk of stream) {
process.stdout.write(chunk.response);
Expand Down

0 comments on commit a87efb9

Please sign in to comment.