11
11
12
12
namespace Symfony \AI \Platform \Result ;
13
13
14
+ use Symfony \AI \Platform \Exception \ExceptionInterface ;
14
15
use Symfony \AI \Platform \Exception \UnexpectedResultTypeException ;
15
16
use Symfony \AI \Platform \Vector \Vector ;
16
17
@@ -32,6 +33,9 @@ public function __construct(
32
33
) {
33
34
}
34
35
36
+ /**
37
+ * @throws ExceptionInterface
38
+ */
35
39
public function getResult (): ResultInterface
36
40
{
37
41
return $ this ->await ();
@@ -42,6 +46,9 @@ public function getRawResult(): RawResultInterface
42
46
return $ this ->rawResult ;
43
47
}
44
48
49
+ /**
50
+ * @throws ExceptionInterface
51
+ */
45
52
public function await (): ResultInterface
46
53
{
47
54
if (!$ this ->isConverted ) {
@@ -58,21 +65,33 @@ public function await(): ResultInterface
58
65
return $ this ->convertedResult ;
59
66
}
60
67
68
+ /**
69
+ * @throws ExceptionInterface
70
+ */
61
71
public function asText (): string
62
72
{
63
73
return $ this ->as (TextResult::class)->getContent ();
64
74
}
65
75
76
+ /**
77
+ * @throws ExceptionInterface
78
+ */
66
79
public function asObject (): object
67
80
{
68
81
return $ this ->as (ObjectResult::class)->getContent ();
69
82
}
70
83
84
+ /**
85
+ * @throws ExceptionInterface
86
+ */
71
87
public function asBinary (): string
72
88
{
73
89
return $ this ->as (BinaryResult::class)->getContent ();
74
90
}
75
91
92
+ /**
93
+ * @throws ExceptionInterface
94
+ */
76
95
public function asBase64 (): string
77
96
{
78
97
$ result = $ this ->as (BinaryResult::class);
@@ -84,19 +103,26 @@ public function asBase64(): string
84
103
85
104
/**
86
105
* @return Vector[]
106
+ *
107
+ * @throws ExceptionInterface
87
108
*/
88
109
public function asVectors (): array
89
110
{
90
111
return $ this ->as (VectorResult::class)->getContent ();
91
112
}
92
113
114
+ /**
115
+ * @throws ExceptionInterface
116
+ */
93
117
public function asStream (): \Generator
94
118
{
95
119
yield from $ this ->as (StreamResult::class)->getContent ();
96
120
}
97
121
98
122
/**
99
123
* @return ToolCall[]
124
+ *
125
+ * @throws ExceptionInterface
100
126
*/
101
127
public function asToolCalls (): array
102
128
{
@@ -105,6 +131,8 @@ public function asToolCalls(): array
105
131
106
132
/**
107
133
* @param class-string $type
134
+ *
135
+ * @throws ExceptionInterface
108
136
*/
109
137
private function as (string $ type ): ResultInterface
110
138
{
0 commit comments