Skip to main content
CogOS can process multiple input formats, automatically converting them into text suitable for the CM agent.

Auto-Detection

The simplest approach — auto_convert() handles format detection:
from cogos.converters import auto_convert

text = auto_convert(any_data)  # handles str, list[dict], dict, JSON strings

Available Converters

ConverterInput TypeDescription
PlainTextConverterstrPass-through with cleanup
MarkdownConverterstrMarkdown content / files
ChatHistoryConverterlist[dict]OpenAI message format
RAGConverterlist[dict]RAG chunks with metadata
JSONConverterdict / strArbitrary JSON data
auto_convert()anyAuto-detects format

Chat History

Convert OpenAI-compatible message arrays:
from cogos.converters import ChatHistoryConverter

messages = [
    {"role": "user", "content": "Hi, I'm Alice"},
    {"role": "assistant", "content": "Hello Alice!"},
]
text = ChatHistoryConverter().convert(messages)

RAG Chunks

Convert retrieval-augmented generation chunks with metadata:
from cogos.converters import RAGConverter

chunks = [
    {"text": "Important fact.", "metadata": {"source": "doc.md"}},
]
text = RAGConverter().convert(chunks)

Custom Converters

Subclass InputConverter and implement convert():
from cogos.converters import InputConverter

class MyConverter(InputConverter):
    def can_handle(self, data) -> bool:
        return isinstance(data, MyCustomType)

    def convert(self, data) -> str:
        return str(data)