File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ public extension CallbackEvents {
4848
4949public struct AgentFinish < Output: AgentOutputParsable > {
5050 public enum ReturnValue {
51- case success ( Output )
52- case failure ( String )
51+ case structured ( Output )
52+ case unstructured ( String )
5353 }
5454
5555 public var returnValue : ReturnValue
@@ -132,7 +132,7 @@ public extension Agent {
132132 switch earlyStoppedHandleType {
133133 case . force:
134134 return AgentFinish (
135- returnValue: . failure ( " Agent stopped due to iteration limit or time limit. " ) ,
135+ returnValue: . unstructured ( " Agent stopped due to iteration limit or time limit. " ) ,
136136 log: " "
137137 )
138138 case . generate:
@@ -144,7 +144,7 @@ public extension Agent {
144144 case let . finish( finish) :
145145 return finish
146146 case . actions:
147- return . init( returnValue: . failure ( output. content ?? " " ) , log: output. content ?? " " )
147+ return . init( returnValue: . unstructured ( output. content ?? " " ) , log: output. content ?? " " )
148148 }
149149 }
150150 }
Original file line number Diff line number Diff line change @@ -101,8 +101,8 @@ public actor AgentExecutor<InnerAgent: Agent>: Chain
101101
102102 public nonisolated func parseOutput( _ output: Output ) -> String {
103103 switch output. finalOutput {
104- case let . failure ( error) : return error
105- case let . success ( output) : return output. botReadableContent
104+ case let . unstructured ( error) : return error
105+ case let . structured ( output) : return output. botReadableContent
106106 }
107107 }
108108
@@ -173,10 +173,10 @@ extension AgentExecutor {
173173
174174 do {
175175 let result = try InnerAgent . Output. parse ( action. observation ?? " " )
176- return . init( returnValue: . success ( result) , log: action. observation ?? " " )
176+ return . init( returnValue: . structured ( result) , log: action. observation ?? " " )
177177 } catch {
178178 return . init(
179- returnValue: . failure ( action. observation ?? " no observation " ) ,
179+ returnValue: . unstructured ( action. observation ?? " no observation " ) ,
180180 log: action. observation ?? " "
181181 )
182182 }
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ public class ChatAgent: Agent {
134134 _ = try throughAnswerParser. parse ( & parsableContent)
135135 let answer = String ( parsableContent)
136136 let output = answer. trimmingCharacters ( in: . whitespacesAndNewlines)
137- return . finish( AgentFinish ( returnValue: . success ( output) , log: text) )
137+ return . finish( AgentFinish ( returnValue: . structured ( output) , log: text) )
138138 } catch {
139139 Logger . langchain. info ( " Could not parse LLM output final answer: \( error) " )
140140 return nil
@@ -188,7 +188,7 @@ public class ChatAgent: Agent {
188188 answer = " Sorry, I don't know. "
189189 }
190190
191- return . finish( AgentFinish ( returnValue: . success ( String ( answer) ) , log: text) )
191+ return . finish( AgentFinish ( returnValue: . structured ( String ( answer) ) , log: text) )
192192 }
193193}
194194
Original file line number Diff line number Diff line change @@ -167,12 +167,12 @@ public class FunctionCallingChatAgent<Output: AgentOutputParsable & Decodable>:
167167 do {
168168 let output = try Output . parse ( functionCall. arguments)
169169 return . finish( . init(
170- returnValue: . success ( output) ,
170+ returnValue: . structured ( output) ,
171171 log: functionCall. arguments
172172 ) )
173173 } catch {
174174 return . finish( . init(
175- returnValue: . failure ( error. localizedDescription) ,
175+ returnValue: . unstructured ( error. localizedDescription) ,
176176 log: functionCall. arguments
177177 ) )
178178 }
@@ -201,8 +201,8 @@ public class FunctionCallingChatAgent<Output: AgentOutputParsable & Decodable>:
201201 return . actions( actions)
202202 case let . finish( finish) :
203203 switch finish. returnValue {
204- case let . failure ( x) , let . success ( x) :
205- return . finish( . init( returnValue: . failure ( x) , log: finish. log) )
204+ case let . unstructured ( x) , let . structured ( x) :
205+ return . finish( . init( returnValue: . unstructured ( x) , log: finish. log) )
206206 }
207207 }
208208 }
You can’t perform that action at this time.
0 commit comments