parent
6c0b1fd5b0
commit
1948eddff3
@ -0,0 +1,25 @@
|
|||||||
|
# history_output_formatter Utility
|
||||||
|
|
||||||
|
The `history_output_formatter` function converts a `Conversation` object into various formats.
|
||||||
|
It supports lists, dictionaries, strings, JSON, YAML, and XML.
|
||||||
|
|
||||||
|
## Export to YAML
|
||||||
|
|
||||||
|
```python
|
||||||
|
from swarms.structs.conversation import Conversation
|
||||||
|
from swarms.utils.history_output_formatter import history_output_formatter
|
||||||
|
|
||||||
|
conversation = Conversation()
|
||||||
|
conversation.add("user", "Hello")
|
||||||
|
conversation.add("assistant", "Hi there!")
|
||||||
|
|
||||||
|
yaml_history = history_output_formatter(conversation, type="yaml")
|
||||||
|
print(yaml_history)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Export to XML
|
||||||
|
|
||||||
|
```python
|
||||||
|
xml_history = history_output_formatter(conversation, type="xml")
|
||||||
|
print(xml_history)
|
||||||
|
```
|
@ -0,0 +1,15 @@
|
|||||||
|
from swarms.structs.conversation import Conversation
|
||||||
|
from swarms.utils.history_output_formatter import history_output_formatter
|
||||||
|
|
||||||
|
# Create a simple conversation
|
||||||
|
conversation = Conversation()
|
||||||
|
conversation.add("user", "Hello")
|
||||||
|
conversation.add("assistant", "Hi there!")
|
||||||
|
|
||||||
|
# Export the conversation to YAML
|
||||||
|
yaml_output = history_output_formatter(conversation, type="yaml")
|
||||||
|
print("YAML Format:\n", yaml_output)
|
||||||
|
|
||||||
|
# Export the conversation to XML
|
||||||
|
xml_output = history_output_formatter(conversation, type="xml")
|
||||||
|
print("\nXML Format:\n", xml_output)
|
Loading…
Reference in new issue