syntax = "proto3";

package protoflow;

import "content/content.proto";
import "ai.proto";
import "google/protobuf/empty.proto";

service ProtoflowService {
  rpc DownloadYouTubeVideo(YouTubeVideo) returns (YouTubeVideoResponse);
  rpc GetSessions(GetSessionsRequest) returns (GetSessionsResponse);
  rpc GetSession(GetSessionRequest) returns (GetSessionResponse);
  rpc DeleteSession(DeleteSessionRequest) returns (google.protobuf.Empty);

  rpc GetPrompts(GetPromptsRequest) returns (GetPromptsResponse);
  rpc NewPrompt(Prompt) returns (Prompt);

  rpc UploadContent(UploadContentRequest) returns (stream ChatResponse);

  rpc Infer(InferRequest) returns (stream InferResponse);

  rpc Chat(ChatRequest) returns (stream ChatResponse);
  rpc ConvertFile(ConvertFileRequest) returns (FilePath);
  rpc GenerateImages(GenerateImagesRequest) returns (GenerateImagesResponse);

  rpc AnalyzeConversation(AnalyzeConversationRequest) returns (ai.AnalyzeConversationResponse);
}
message AnalyzeConversationRequest {
  string text = 1;
}

message GenerateImagesRequest {
  string prompt = 1;
}

message GenerateImagesResponse {
  repeated string images = 1;
}

message DeleteSessionRequest {
  string id = 1;
}

message Prompt {
  string id = 1;
  string text = 2;
}

message GetPromptsRequest {}

message GetPromptsResponse {
  repeated Prompt prompts = 1;
}

message InferRequest {
  string prompt = 1;
  repeated string text = 2;
}

message InferResponse {
  string text = 1;
}

message UploadContentRequest {
  content.Content content = 1;
}

message UploadContentResponse {
  string id = 1;
}

message GetSessionRequest {
  string id = 1;
}

message GetSessionResponse {
  Session session = 1;
}

message GetSessionsRequest {
  uint64 page = 1;
  uint64 limit = 2;
}

message GetSessionsResponse {
  repeated Session sessions = 1;
}

message Token {
  uint32 id = 1;
  uint64 start_time = 2;
  uint64 end_time = 3;
  string text = 4;
  string p = 5;
}

message Segment {
  uint32 num = 1;
  repeated Token tokens = 2;
  string text = 3;
  uint64 start_time = 4;
  uint64 end_time = 5;
}

message Session {
  string id = 1;
  string name = 2;
  repeated Segment segments = 3;
}

message TranscriptionRequest {
  string file_path = 14;
  string model = 1;                        // Path to the model file
  string language = 2;                     // Spoken language
  bool translate = 3;                      // Translate from source language to English
  int64 offset = 4;                        // Time offset in nanoseconds to match Go's time.Duration
  int64 duration = 5;                      // Duration of audio to process in nanoseconds
  uint32 threads = 6;                      // Number of threads to use
  bool speedup = 7;                        // Enable speedup
  uint32 max_len = 8;                      // Maximum segment length in characters
  uint32 max_tokens = 9;                   // Maximum tokens per segment
  double word_threshold = 10;                  // Maximum segment score
  bool tokens = 11;                        // Display tokens
  bool colorize = 12;                      // Colorize tokens
  string out = 13;                         // Output format (srt, none or leave as empty string)
}

message RegisterFlags {
}

message OCRText {
  string text = 1;
}

message Image {
  bytes image = 1;
}

message ConvertFileRequest {
  string from = 1;
  string to = 2;
}

message ChatRequest {
  int32 capture_device = 1;
}

message ChatResponse {
  Segment segment = 1;
}

message YouTubeVideo {
  string id = 1;
  string file = 2;
}

message FilePath {
  string file = 1;
}

message YouTubeVideoResponse {
  string title = 1;
  FilePath file_path = 2;
  repeated content.Segment transcript = 3;
}
