import os
import trulayer
from haystack import Pipeline
from haystack.components.generators import OpenAIGenerator
from trulayer.instruments.haystack import instrument_haystack
trulayer.init(api_key=os.environ["TRULAYER_API_KEY"], project_name="my-app")
pipe = Pipeline()
pipe.add_component("llm", OpenAIGenerator(model="gpt-4o-mini"))
with trulayer.trace("haystack-run") as trace:
instrument_haystack(pipe, trace)
result = pipe.run({"llm": {"prompt": "What is the capital of France?"}})
print(result["llm"]["replies"][0])