syntax = "proto3";

package next_edu_cloud.ai.v1;

service AiService {
  rpc Chat(ChatRequest) returns (ChatResponse);
  rpc StreamChat(ChatRequest) returns (stream ChatChunk);
  rpc GenerateQuestion(GenerateQuestionRequest) returns (GeneratedQuestion);
  rpc OptimizeExpression(OptimizeExpressionRequest) returns (OptimizedExpression);
}

message ChatRequest {
  repeated ChatMessage messages = 1;
  string model = 2;
  double temperature = 3;
}

message ChatMessage {
  string role = 1;
  string content = 2;
}

message ChatResponse {
  string content = 1;
  string model = 2;
  Usage usage = 3;
}

message Usage {
  int32 prompt_tokens = 1;
  int32 completion_tokens = 2;
  int32 total_tokens = 3;
}

message ChatChunk {
  string content = 1;
  bool done = 2;
}

message GenerateQuestionRequest {
  string prompt = 1;
  string subject = 2;
  string difficulty = 3;
}

message GeneratedQuestion {
  string question = 1;
  string answer = 2;
  string explanation = 3;
}

message OptimizeExpressionRequest {
  string text = 1;
  string context = 2;
}

message OptimizedExpression {
  string optimized = 1;
  repeated string suggestions = 2;
}
