Skip to content

Conversation

@hynky1999
Copy link
Contributor

No description provided.

… `inference_example_chunked.py` generations type, and introduce two new demo files.
@guipenedo
Copy link
Collaborator

For proper typing, something like:

from dataclasses import dataclass, field
from typing import Any, Dict, List, Literal, Optional, Union


Role = Literal["system", "user", "assistant", "tool"]


@dataclass
class ToolCall:
    id: Optional[str] = None
    name: Optional[str] = None
    arguments: Dict[str, Any] = field(default_factory=dict)


ContentPart = Union[
    str,                              # plain text
    Dict[str, Any],                   # image/audio/etc blocks
]


@dataclass
class Message:
    role: Role

    # Main user-visible output
    content: Optional[Union[str, List[ContentPart]]] = None

    # Tool / function calling
    tool_calls: List[ToolCall] = field(default_factory=list)
    tool_call_id: Optional[str] = None   # used on tool responses

    # Optional metadata (model/provider specific)
    reasoning: Optional[str] = None
    name: Optional[str] = None           # function name / tool name
    metadata: Dict[str, Any] = field(default_factory=dict)

@hynky1999
Copy link
Contributor Author

hynky1999 commented Dec 19, 2025

For proper typing, something like:

I am not sure it's good idea to add typing. To me the only reason we are adding the raw response is to enable users to extract stuff on top of what we already parse so we should be as flexible as possible there so I would just keep it as is.

@guipenedo
Copy link
Collaborator

This is as flexible as possible as they can get any field they need. The api is a format and this dataclass covers most of the current implementations, I don't see any reason to not add it like this (and you're usually the type obsessed, surprised at the role reversal)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants