A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://ts.llamaindex.ai/docs/llamaindex/modules/rag/chat_engine below:

Build LLM-powered document agents and workflows

The chat engine is a quick and simple way to chat with the data in your index.

const retriever = index.asRetriever();
const chatEngine = new ContextChatEngine({ retriever });

// start chatting
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.

const chatEngine = index.asChatEngine();

You can also pass in options to the chat engine.

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:

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4