types.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package chat
  2. import "encoding/json"
  3. // Message represents a chat message.
  4. // Role is typically: "system", "user", "assistant", "tool".
  5. // ToolCalls is used for assistant messages that request tool/function calls.
  6. // ReasoningContent optionally carries chain-of-thought style content for templates that support it.
  7. // Content is the visible message content.
  8. //
  9. // Note: We intentionally keep this struct generic and close to common chat template expectations.
  10. //
  11. //nolint:revive // exported API
  12. type Message struct {
  13. Role string `json:"role"`
  14. Content string `json:"content"`
  15. ReasoningContent string `json:"reasoning_content,omitempty"`
  16. ToolCalls []ToolCall `json:"tool_calls,omitempty"`
  17. }
  18. // ToolCall represents a single tool/function call requested by the assistant.
  19. // Arguments may be either a raw JSON object or a string (some models emit stringified JSON).
  20. //
  21. //nolint:revive // exported API
  22. type ToolCall struct {
  23. Name string `json:"name"`
  24. Arguments json.RawMessage `json:"arguments"`
  25. }
  26. // Options control chat template rendering.
  27. //
  28. //nolint:revive // exported API
  29. type Options struct {
  30. AddGenerationPrompt bool
  31. EnableThinking bool
  32. Tools []any
  33. }