Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/examples-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ jobs:

# DSPy examples
- { path: 'examples/dspy/dspy_calculator.py', name: 'DSPy ReAct Agent' }

# Haystack examples
- { path: 'examples/haystack/haystack_example.py', name: 'Haystack OpenAI' }
# Add more examples as needed


Expand Down Expand Up @@ -189,4 +192,4 @@ jobs:
echo "βœ… All examples passed!" >> $GITHUB_STEP_SUMMARY
else
echo "❌ Some examples failed. Check the logs above." >> $GITHUB_STEP_SUMMARY
fi
fi
5 changes: 2 additions & 3 deletions docs/v1/integrations/haystack.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ AgentOps makes monitoring your Haystack agents seamless. Haystack, much like Aut

## Full Examples

You can refer to the following examples -
You can refer to the following example -

- [Philosopher Agent](https://github.com/AgentOps-AI/agentops/blob/main/examples/haystack_examples/haystack_anthropic_example.ipynb)
- [Mathematician Agent](https://github.com/AgentOps-AI/agentops/blob/main/examples/haystack_examples/haystack_openai_example.ipynb)
- [Simple Haystack example (OpenAI)](https://github.com/AgentOps-AI/agentops/blob/main/examples/haystack/haystack_example.py)


<script type="module" src="/scripts/github_stars.js"></script>
Expand Down
34 changes: 34 additions & 0 deletions examples/haystack/haystack_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os

import agentops
from haystack.components.generators.openai import OpenAIGenerator


def main():
agentops.init(os.getenv("AGENTOPS_API_KEY"))

tracer = agentops.start_trace(
trace_name="Haystack OpenAI Example",
tags=["haystack", "openai", "agentops-example"],
)

prompt = "In one sentence, what is AgentOps?"
generator = OpenAIGenerator(model="gpt-4o-mini")
result = generator.run(prompt=prompt)
replies = result.get("replies") or []
print("Haystack reply:", replies[0] if replies else "<no reply>")

print("\n" + "=" * 50)
print("Now let's verify that our LLM calls were tracked properly...")
try:
validation_result = agentops.validate_trace_spans(trace_context=tracer)
agentops.print_validation_summary(validation_result)
except agentops.ValidationError as e:
print(f"\n❌ Error validating spans: {e}")
raise

agentops.end_trace(tracer, end_state="Success")


if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions examples/haystack/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
haystack-ai>=2.0.0
openai>=1.0.0
Loading