Demonstrate workflow capabilities with caching. This function shows: - How to create and use custom workflows - The performance benefits of caching - Session state persistence - Response streaming
()
| 85 | |
| 86 | |
| 87 | def demonstrate_workflows(): |
| 88 | """ |
| 89 | Demonstrate workflow capabilities with caching. |
| 90 | |
| 91 | This function shows: |
| 92 | - How to create and use custom workflows |
| 93 | - The performance benefits of caching |
| 94 | - Session state persistence |
| 95 | - Response streaming |
| 96 | """ |
| 97 | |
| 98 | tracer = agentops.start_trace(trace_name="Agno Workflow Setup Demonstration") |
| 99 | try: |
| 100 | workflow = CacheWorkflow() |
| 101 | |
| 102 | response: Iterator[RunResponse] = workflow.run(message="Tell me a joke.") |
| 103 | |
| 104 | pprint_run_response(response, markdown=True, show_time=True) |
| 105 | |
| 106 | response: Iterator[RunResponse] = workflow.run(message="Tell me a joke.") |
| 107 | |
| 108 | pprint_run_response(response, markdown=True, show_time=True) |
| 109 | |
| 110 | agentops.end_trace(tracer, end_state="Success") |
| 111 | |
| 112 | except Exception: |
| 113 | agentops.end_trace(tracer, end_state="Error") |
| 114 | |
| 115 | # Let's check programmatically that spans were recorded in AgentOps |
| 116 | print("\n" + "=" * 50) |
| 117 | print("Now let's verify that our LLM calls were tracked properly...") |
| 118 | try: |
| 119 | agentops.validate_trace_spans(trace_context=tracer) |
| 120 | print("\n✅ Success! All LLM spans were properly recorded in AgentOps.") |
| 121 | except agentops.ValidationError as e: |
| 122 | print(f"\n❌ Error validating spans: {e}") |
| 123 | raise |
| 124 | |
| 125 | |
| 126 | demonstrate_workflows() |
no test coverage detected
searching dependent graphs…