1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! Agent source port trait for LLM-as-data-source.
//!
//! Defines the interface for using an AI agent (LLM) as a data source
//! within the pipeline. Unlike [`AIProvider`](crate::ports::AIProvider),
//! which extracts structured data from existing content, an agent source
//! *generates* content by executing a prompt — making it suitable for
//! summarisation, enrichment, or synthetic data generation steps in a DAG.
use async_trait;
use ;
use Value;
use crateResult;
/// Configuration for an agent source invocation.
///
/// # Example
///
/// ```
/// use stygian_graph::ports::agent_source::AgentRequest;
/// use serde_json::json;
///
/// let req = AgentRequest {
/// prompt: "Summarise this article".into(),
/// context: Some("The article text goes here...".into()),
/// parameters: json!({"temperature": 0.3}),
/// };
/// ```
/// Response from an agent source invocation.
///
/// # Example
///
/// ```
/// use stygian_graph::ports::agent_source::AgentResponse;
/// use serde_json::json;
///
/// let resp = AgentResponse {
/// content: "Here is a concise summary…".into(),
/// metadata: json!({"tokens_used": 142}),
/// };
/// ```
/// Port trait for LLM agent data sources.
///
/// Implementations wrap an LLM provider and expose it as a pipeline-compatible
/// data source.
///
/// # Example
///
/// ```no_run
/// use stygian_graph::ports::agent_source::{AgentSourcePort, AgentRequest};
/// use serde_json::json;
///
/// # async fn example(agent: impl AgentSourcePort) {
/// let req = AgentRequest {
/// prompt: "List the key takeaways".into(),
/// context: Some("...article text...".into()),
/// parameters: json!({}),
/// };
/// let resp = agent.invoke(req).await.unwrap();
/// println!("{}", resp.content);
/// # }
/// ```