dto.go 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package claude
  2. type ClaudeMetadata struct {
  3. UserId string `json:"user_id"`
  4. }
  5. type ClaudeMediaMessage struct {
  6. Type string `json:"type"`
  7. Text string `json:"text,omitempty"`
  8. Source *ClaudeMessageSource `json:"source,omitempty"`
  9. Usage *ClaudeUsage `json:"usage,omitempty"`
  10. StopReason *string `json:"stop_reason,omitempty"`
  11. PartialJson string `json:"partial_json,omitempty"`
  12. // tool_calls
  13. Id string `json:"id,omitempty"`
  14. Name string `json:"name,omitempty"`
  15. Input any `json:"input,omitempty"`
  16. Content string `json:"content,omitempty"`
  17. ToolUseId string `json:"tool_use_id,omitempty"`
  18. }
  19. type ClaudeMessageSource struct {
  20. Type string `json:"type"`
  21. MediaType string `json:"media_type"`
  22. Data string `json:"data"`
  23. }
  24. type ClaudeMessage struct {
  25. Role string `json:"role"`
  26. Content any `json:"content"`
  27. }
  28. type Tool struct {
  29. Name string `json:"name"`
  30. Description string `json:"description,omitempty"`
  31. InputSchema InputSchema `json:"input_schema"`
  32. }
  33. type InputSchema struct {
  34. Type string `json:"type"`
  35. Properties any `json:"properties,omitempty"`
  36. Required any `json:"required,omitempty"`
  37. }
  38. type ClaudeRequest struct {
  39. Model string `json:"model"`
  40. Prompt string `json:"prompt,omitempty"`
  41. System string `json:"system,omitempty"`
  42. Messages []ClaudeMessage `json:"messages,omitempty"`
  43. MaxTokens uint `json:"max_tokens,omitempty"`
  44. MaxTokensToSample uint `json:"max_tokens_to_sample,omitempty"`
  45. StopSequences []string `json:"stop_sequences,omitempty"`
  46. Temperature float64 `json:"temperature,omitempty"`
  47. TopP float64 `json:"top_p,omitempty"`
  48. TopK int `json:"top_k,omitempty"`
  49. //ClaudeMetadata `json:"metadata,omitempty"`
  50. Stream bool `json:"stream,omitempty"`
  51. Tools []Tool `json:"tools,omitempty"`
  52. ToolChoice any `json:"tool_choice,omitempty"`
  53. }
  54. type ClaudeError struct {
  55. Type string `json:"type"`
  56. Message string `json:"message"`
  57. }
  58. type ClaudeResponse struct {
  59. Id string `json:"id"`
  60. Type string `json:"type"`
  61. Content []ClaudeMediaMessage `json:"content"`
  62. Completion string `json:"completion"`
  63. StopReason string `json:"stop_reason"`
  64. Model string `json:"model"`
  65. Error ClaudeError `json:"error"`
  66. Usage ClaudeUsage `json:"usage"`
  67. Index int `json:"index"` // stream only
  68. ContentBlock *ClaudeMediaMessage `json:"content_block"`
  69. Delta *ClaudeMediaMessage `json:"delta"` // stream only
  70. Message *ClaudeResponse `json:"message"` // stream only: message_start
  71. }
  72. type ClaudeUsage struct {
  73. InputTokens int `json:"input_tokens"`
  74. OutputTokens int `json:"output_tokens"`
  75. }