Skip to content

Commit 419f40c

Browse files
Add working Haystack example, wire into CI, and update docs (#1230)
* examples: add Haystack 2.x OpenAI example; wire into examples CI; fix docs links Co-Authored-By: Alex <[email protected]> * examples(haystack): fix import path for OpenAIGenerator (Haystack 2.x) and use named argument Co-Authored-By: Alex <[email protected]> * examples(haystack): add post-run validation via agentops.validate_trace_spans and print summary Co-Authored-By: Alex <[email protected]> * examples(haystack): start a trace and validate against it; end with end_trace to ensure session URL and proper validation Co-Authored-By: Alex <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Alex <[email protected]>
1 parent f5e7d50 commit 419f40c

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

.github/workflows/examples-integration-test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ jobs:
105105

106106
# DSPy examples
107107
- { path: 'examples/dspy/dspy_calculator.py', name: 'DSPy ReAct Agent' }
108+
109+
# Haystack examples
110+
- { path: 'examples/haystack/haystack_example.py', name: 'Haystack OpenAI' }
108111
# Add more examples as needed
109112

110113

@@ -189,4 +192,4 @@ jobs:
189192
echo "✅ All examples passed!" >> $GITHUB_STEP_SUMMARY
190193
else
191194
echo "❌ Some examples failed. Check the logs above." >> $GITHUB_STEP_SUMMARY
192-
fi
195+
fi

docs/v1/integrations/haystack.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ AgentOps makes monitoring your Haystack agents seamless. Haystack, much like Aut
6969

7070
## Full Examples
7171

72-
You can refer to the following examples -
72+
You can refer to the following example -
7373

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

7776

7877
<script type="module" src="/scripts/github_stars.js"></script>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import os
2+
3+
import agentops
4+
from haystack.components.generators.openai import OpenAIGenerator
5+
6+
7+
def main():
8+
agentops.init(os.getenv("AGENTOPS_API_KEY"))
9+
10+
tracer = agentops.start_trace(
11+
trace_name="Haystack OpenAI Example",
12+
tags=["haystack", "openai", "agentops-example"],
13+
)
14+
15+
prompt = "In one sentence, what is AgentOps?"
16+
generator = OpenAIGenerator(model="gpt-4o-mini")
17+
result = generator.run(prompt=prompt)
18+
replies = result.get("replies") or []
19+
print("Haystack reply:", replies[0] if replies else "<no reply>")
20+
21+
print("\n" + "=" * 50)
22+
print("Now let's verify that our LLM calls were tracked properly...")
23+
try:
24+
validation_result = agentops.validate_trace_spans(trace_context=tracer)
25+
agentops.print_validation_summary(validation_result)
26+
except agentops.ValidationError as e:
27+
print(f"\n❌ Error validating spans: {e}")
28+
raise
29+
30+
agentops.end_trace(tracer, end_state="Success")
31+
32+
33+
if __name__ == "__main__":
34+
main()

examples/haystack/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
haystack-ai>=2.0.0
2+
openai>=1.0.0

0 commit comments

Comments
 (0)