from keywordsai_tracing.decorators import workflow, task
from keywordsai_tracing.main import KeywordsAITelemetry
from keywordsai_tracing.contexts.span import keywordsai_span_attributes
k_tl = KeywordsAITelemetry()
@task(name="joke_creation")
def create_joke():
# This is the joke creation task
@workflow(name="pirate_joke_generator")
def joke_workflow():
# This is the joke creation workflow
@workflow(name="pirate_joke_plus_audience_reactions")
def pirate_joke_plus_audience():
with keywordsai_span_attributes(
keywordsai_params={
"trace_group_identifier": "pirate_joke_id"
}):
joke = joke_workflow() # This show case the basic workflow usage and compatibility with the OpenAI SDK
return "python"
@workflow(name="pirate_joke_plus_audience_reactions")
def another_workflow():
with keywordsai_span_attributes(
keywordsai_params={
"trace_group_identifier": "pirate_joke_id" # same trace group identifier as the previous workflow
}):
# This is the another workflow
return "python"