realtime.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package dto
  2. const (
  3. RealtimeEventTypeError = "error"
  4. RealtimeEventTypeSessionUpdate = "session.update"
  5. RealtimeEventTypeConversationCreate = "conversation.item.create"
  6. RealtimeEventTypeResponseCreate = "response.create"
  7. )
  8. type RealtimeEvent struct {
  9. EventId string `json:"event_id"`
  10. Type string `json:"type"`
  11. //PreviousItemId string `json:"previous_item_id"`
  12. Session *RealtimeSession `json:"session,omitempty"`
  13. Item *RealtimeItem `json:"item,omitempty"`
  14. Error *OpenAIError `json:"error,omitempty"`
  15. }
  16. type RealtimeSession struct {
  17. Modalities []string `json:"modalities"`
  18. Instructions string `json:"instructions"`
  19. Voice string `json:"voice"`
  20. InputAudioFormat string `json:"input_audio_format"`
  21. OutputAudioFormat string `json:"output_audio_format"`
  22. InputAudioTranscription InputAudioTranscription `json:"input_audio_transcription"`
  23. TurnDetection interface{} `json:"turn_detection"`
  24. Tools []RealTimeTool `json:"tools"`
  25. ToolChoice string `json:"tool_choice"`
  26. Temperature float64 `json:"temperature"`
  27. MaxResponseOutputTokens int `json:"max_response_output_tokens"`
  28. }
  29. type InputAudioTranscription struct {
  30. Model string `json:"model"`
  31. }
  32. type RealTimeTool struct {
  33. Type string `json:"type"`
  34. Name string `json:"name"`
  35. Description string `json:"description"`
  36. Parameters any `json:"parameters"`
  37. }
  38. type RealtimeItem struct {
  39. Id string `json:"id"`
  40. Type string `json:"type"`
  41. Status string `json:"status"`
  42. Role string `json:"role"`
  43. Content RealtimeContent `json:"content"`
  44. Name *string `json:"name,omitempty"`
  45. ToolCalls any `json:"tool_calls,omitempty"`
  46. CallId string `json:"call_id,omitempty"`
  47. }
  48. type RealtimeContent struct {
  49. Type string `json:"type"`
  50. Text string `json:"text,omitempty"`
  51. Audio string `json:"audio,omitempty"` // Base64-encoded audio bytes.
  52. Transcript string `json:"transcript,omitempty"`
  53. }