Lab works fine. Low priority issue.
The output of the workflow lab in the terminal looks something like this
{"customer_issue":"The API returns a 403 error when creating invoices, but our API key hasn't changed.","category":"Technical","confidence":1}A 403 error typically indicates a permissions issue. Please ensure that your API key has the necessary permissions to create invoices and that it has not expired or been restricted. If the issue persists, try regenerating your API key and updating it in your integration.{"customer_issue":"Is there a way to export all invoices as a CSV?","category":"General","confidence":1}Yes, you can export all invoices as a CSV file from the Invoices section of your ContosoPay dashboard. Simply select the "Export" option and choose CSV as the format. If you need more detailed instructions, please let us know.{"customer_issue":"I was charged twice for the same invoice last Friday and my customer is also seeing two receipts. Can someone fix this?","category":"Billing","confidence":1}Escalate billing issue to human support team.
It is difficult to see the three tickets and responses.
Adding a helper function to the initial code will help. Sample
# new imports
import json
import os
import re
from dotenv import load_dotenv
...
def print_workflow_output(output_text):
tickets = re.findall(r"(\{.*?\})(.*?)(?=\{|$)", output_text, re.DOTALL)
if not tickets:
print(output_text)
return
for ticket_number, (ticket_json, response_text) in enumerate(tickets, start=1):
ticket = json.loads(ticket_json)
print("\n" + "=" * 80)
print(f"Ticket {ticket_number}: {ticket['category']} ({ticket['confidence']:.0%} confidence)")
print("-" * 80)
print(f"Issue: {ticket['customer_issue']}")
print("\nResponse:")
print(response_text.strip())
print("=" * 80 + "\n")
...
# user's final print statement while processing the workflow run is invoking the helper function
for event in stream:
if (event.type == "response.completed"):
print("\nResponse completed:")
response = openai_client.responses.retrieve(event.response.id)
print_workflow_output(response.output_text)
Then the output is more readable
Response completed:
================================================================================
Ticket 1: Technical (100% confidence)
--------------------------------------------------------------------------------
Issue: The API returns a 403 error when creating invoices, but our API key hasn't changed.
Response:
A 403 error typically indicates a permissions issue. Please ensure that your API key has the necessary permissions to create invoices and that it is being sent in the correct header. If the issue persists, try regenerating your API key and updating it in your integration.
================================================================================
Ticket 2: General (100% confidence)
--------------------------------------------------------------------------------
Issue: Is there a way to export all invoices as a CSV?
Response:
Yes, you can export all invoices as a CSV file from the Invoices section of your ContosoPay dashboard. Simply select the "Export" option and choose CSV as the format. If you need more detailed instructions, please let us know.
================================================================================
Ticket 3: Billing (100% confidence)
--------------------------------------------------------------------------------
Issue: I was charged twice for the same invoice last Friday and my customer is also seeing two receipts. Can someone fix this?
Response:
Escalate billing issue to human support team.
================================================================================
Lab works fine. Low priority issue.
The output of the workflow lab in the terminal looks something like this
{"customer_issue":"The API returns a 403 error when creating invoices, but our API key hasn't changed.","category":"Technical","confidence":1}A 403 error typically indicates a permissions issue. Please ensure that your API key has the necessary permissions to create invoices and that it has not expired or been restricted. If the issue persists, try regenerating your API key and updating it in your integration.{"customer_issue":"Is there a way to export all invoices as a CSV?","category":"General","confidence":1}Yes, you can export all invoices as a CSV file from the Invoices section of your ContosoPay dashboard. Simply select the "Export" option and choose CSV as the format. If you need more detailed instructions, please let us know.{"customer_issue":"I was charged twice for the same invoice last Friday and my customer is also seeing two receipts. Can someone fix this?","category":"Billing","confidence":1}Escalate billing issue to human support team.It is difficult to see the three tickets and responses.
Adding a helper function to the initial code will help. Sample
Then the output is more readable