Find answers from the community

Updated 2 years ago

How do we add a custom prompt to a chat

At a glance

The community member is asking how to add a custom prompt to a chat_engine with OpenAI. They mention that the examples they found in the Discord seem to use langchain and are potentially out-of-date, referencing gpt-index as the package name. The community member has looked at the documentation for chat engines, but is unsure of the right way to do this.

In the comments, another community member suggests that you can specify a system prompt as a kwarg, which works for every chat engine except the react one. They provide an example of index.as_chat_engine(system_prompt="talk like a pirate"). Another community member asks if they can pass the Prompt() class to it, but the response is that it only takes a string and converts it to a system message under the hood.

There is no explicitly marked answer in the comments.

Useful resources
How do we add a custom prompt to a chat_engine with OpenAI. The examples I found here in the Discord seem to use langchain and are potentially out-of-date (still referencing gpt-index as the package name). What's the right way to do this? Have looked here: https://gpt-index.readthedocs.io/en/stable/core_modules/query_modules/chat_engines/usage_pattern.html
L
c
3 comments
You can specify a system prompt as a kwarg. This works for every chat engine except the react one

Plain Text
index.as_chat_engine(system_prompt="talk like a pirate")
let me try that, can we pass the class Prompt() to it?
nah, it only takes a string, and converts it to a system message under the hood
Add a reply
Sign up and join the conversation on Discord