Find answers from the community

Updated last year

I m noticing the chatprompts dont have

I'm noticing the chatprompts dont have much effect on the output from OpenAI. Where can we see what the string looks like when its being sent to OpenAI for completion? I guess I just want to understand where the the prompts come into play in the pipeline
L
c
20 comments
If you turn on debug logging, you'll see the full text

Plain Text
import logging
import sys

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
In addition to the query string, there is a prompt template that the query string and retrieved context get thrown into
What do we need to pass to as_chat_engine? It seems that text_qa_template and refine_template kwargs dont work
or have no effect
which chat engine are you using? The default? They are all slightly different
or i guess the default
So passing in text_qa_template and refine_template works, but it only applies to the actual query engine itself

For example, the flow is
  • User sends message
  • Agent decides which tool to use
  • If it picks a tool, it writes it's own input to that tool
  • In this case, it would call your query engine, where the templates are used
  • Then the agent sees the answer, decides if anymore tools should be used, and re-writes the tool ouput(s) using the chat history to answer the original user message
In this flow, the templates only get used if the agent decides to use a query engine tool
If you want to have some control over the agent behaviour, you can pass in a system_prompt string

index.as_chat_engine(..., system_prompt="Talk like a pirate")
Aha! That worked
Can we combine Prompts with the chat engine by forcing the chat engine to use a query tool?
yea you can force one tool to at least be called every time

Plain Text
index.as_chat_engine(..., function_call="query_engine_tool")
im assuming that the string "query_engine_tool" is a variable that isinstance QueryEngineTool from the index?
It's actually the name of the query engine tool, the string there is the default name πŸ™‚
how does that relate to a QueryEngineTool that we define?
or do we not need to define one?
When you do index.as_chat_engine() it defines one for you

If you do OpenAIAgent.from_tools(), then you will have already defined the tool manually, and hopefully given that tool a name+description πŸ™‚
Add a reply
Sign up and join the conversation on Discord