Take chat history in consideration when running a prompt experiment #4452
-
I am trying to test the output of my agent but after a certain point in the discussion with the user. For example, I ask my agent to ask a bunch of questions and then try to schedule an appointment with the user. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
Hey @benjtlv! 👋 I'm here to help you with any bugs, questions, or contributions you have. Let me know how I can assist you! To include chat history in a dataset item for testing purposes in Langfuse, you can use the langfuse.create_dataset_item(
dataset_name="<dataset_name>",
input={
"chat_history": [
{"role": "user", "content": "Hello, how are you?"},
{"role": "assistant", "content": "I'm good, thank you! How can I assist you today?"}
]
},
expected_output={
"response": "I'm good, thank you! How can I assist you today?"
},
metadata={
"model": "llama3",
}
) This approach allows you to include the chat history as part of the input, which can be useful for testing the output of your agent at a specific point in the conversation [1]. |
Beta Was this translation helpful? Give feedback.
-
Great question and related to history placeholder in prompt management: https://github.com/orgs/langfuse/discussions/2210 For now, I'd suggest to add a {{history}} placeholder in your prompt template to add the message history via a variable in the dataset item input |
Beta Was this translation helpful? Give feedback.
-
@marcklingen thank you for your response. But what about the response from dosubot? Good enough or misleading? |
Beta Was this translation helpful? Give feedback.
-
I've added this thread to track adding support for these "special variables" more natively: https://github.com/orgs/langfuse/discussions/4454 |
Beta Was this translation helpful? Give feedback.
Great question and related to history placeholder in prompt management: https://github.com/orgs/langfuse/discussions/2210
For now, I'd suggest to add a {{history}} placeholder in your prompt template to add the message history via a variable in the dataset item input