Spaces:
Sleeping
Sleeping
Download open_cortex/runtime/messages.py from JeCabrera/open-cortex: direct link, hf CLI and curl.
- Browser
- Download file 408 Bytes
-
https://huggingface.co/spaces/JeCabrera/open-cortex/resolve/main/open_cortex/runtime/messages.py
- Command line
-
hf download hf://spaces/JeCabrera/open-cortex/open_cortex/runtime/messages.py
-
curl -L -o messages.py https://huggingface.co/spaces/JeCabrera/open-cortex/resolve/main/open_cortex/runtime/messages.py
408 Bytes
| from dataclasses import dataclass | |
| from typing import Literal | |
| Role = Literal["system", "user", "assistant"] | |
| class ChatMessage: | |
| role: Role | |
| content: str | |
| def to_llama_messages(messages: list[ChatMessage]) -> list[dict[str, str]]: | |
| return [ | |
| { | |
| "role": message.role, | |
| "content": message.content, | |
| } | |
| for message in messages | |
| ] |