cog icon indicating copy to clipboard operation
cog copied to clipboard

Support OpenAI-compatible ChatMessage type

Open andreasjansson opened this issue 10 months ago • 2 comments

For language models, it'd be good to support an input type that's consistent with the OpenAI API.

I imagine something like this:

from cog import Input
from cog.types import ChatMessage

def run(
    messages: list[ChatMessage] = Input(),
) -> str:
    print(messages)
    return f"HELLO {messages[0]['role']}"

andreasjansson avatar Mar 04 '25 16:03 andreasjansson

Progress: https://github.com/replicate/cog/pull/2261

zeke avatar Apr 18 '25 20:04 zeke

Implementation in cog-runtime: https://github.com/replicate/cog-runtime/pull/71

zeke avatar Apr 18 '25 21:04 zeke