For chatbots and assistants, pass conversation history when fetching prompts:
# Your conversation historyhistory = [ {'role': 'user', 'content': 'What is pasta?'}, {'role': 'assistant', 'content': 'Pasta is an Italian dish...'}]# Fetch prompt with historyformatted_prompt = fp_client.prompts.get_formatted(project_id=project_id,template_name="chat-assistant",environment="latest",variables={"user_question": "How do I make it?"},history=history # Freeplay handles formatting)
# After the user rates your responsefp_client.customer_feedback.update( completion_id=completion.completion_id, feedback={ 'thumbs_up': True, 'user_comment': 'Very helpful!' })
For agents and complex workflows, use traces to group related completions:
# Create a trace for multi-step workflowtrace_info = session.create_trace( input="Research and write a blog post about AI", agent_name="blog_writer", custom_metadata={"version": "2.0"})# Log each LLM call with the trace_id# ... your LLM calls here ...# Record final outputtrace_info.record_output(project_id=project_id,output="[Final blog post content]")