MCPcopy Create free account
hub / github.com/apache/burr / update

Method update

burr/integrations/haystack.py:262–279  ·  view source on GitHub ↗

Update the state using the results of ``Component.run()``. The output socket name is mapped to the Burr state field name. Values returned by ``Component.run()`` that aren't in ``writes`` are ignored.

(self, result: dict, state: State)

Source from the content-addressed store, hash-verified

260 return self._component.run(**values)
261
262 def update(self, result: dict, state: State) -> State:
263 """Update the state using the results of ``Component.run()``.
264 The output socket name is mapped to the Burr state field name.
265
266 Values returned by ``Component.run()`` that aren't in ``writes`` are ignored.
267 """
268 # TODO we could want to handle ``.update()`` and ``.append()`` differently
269 state_update = {}
270
271 for state_field_name, output_socket_name in self._output_socket_mapping.items():
272 if state_field_name in self.writes:
273 try:
274 state_update[state_field_name] = result[output_socket_name]
275 except KeyError as e:
276 raise ValueError(
277 f"Socket `{output_socket_name}` missing from output of `Component.run()`"
278 ) from e
279 return state.update(**state_update)
280
281 def get_source(self) -> str:
282 """Return the source code of the Haystack ``Component``.

Calls

no outgoing calls

Tested by 2