diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94e08fa..eb2a3df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,12 +17,16 @@ jobs: - name: checkout repository uses: actions/checkout@v4 - - name: Build + - name: Replace secrets for auth.yaml run: | + sed -i "s/OPENAI_API_KEY/${{ secrets.OPENAI_API_KEY }}/g" ./conf/auth.yaml + sed -i "s/QWEN_API_KEY/${{ secrets.QWEN_API_KEY }}/g" ./conf/auth.yaml sed -i "s/OSS_ACCESS_ENDPOINT/${{ secrets.OSS_ACCESS_ENDPOINT }}/g" ./conf/auth.yaml sed -i "s/OSS_ACCESS_KEY_ID/${{ secrets.OSS_ACCESS_KEY_ID }}/g" ./conf/auth.yaml sed -i "s/OSS_ACCESS_KEY_SECRET/${{ secrets.OSS_ACCESS_KEY_SECRET }}/g" ./conf/auth.yaml - sed -i "s/OPENAI_API_KEY/${{ secrets.OPENAI_API_KEY }}/g" ./conf/auth.yaml + + - name: Build + run: | bazel build --action_env=CC=clang-14 //... mkdir -p output/bin output/conf mv ./bazel-bin/src/ielts_ai output/bin/ diff --git a/WORKSPACE b/WORKSPACE index 4181f5e..cdd0a8d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -17,16 +17,16 @@ http_archive( http_archive( name = "com_github_d7ead_liboai", build_file = "//bazel:liboai.BUILD", - sha256 = "71d1c7fe55fdec465e3f1ec376104c1bac92e014f5984a9024749a73e6a312ff", - strip_prefix = "liboai-1.0.7/liboai", - urls = ["https://github.com/pkusunjy/liboai/archive/v1.0.7.tar.gz"], + sha256 = "83108eb34c71b6bf0d18d8b7071a76a6c1609fea60f32afedaf7f69c95f0b827", + strip_prefix = "liboai-1.0.11/liboai", + urls = ["https://github.com/pkusunjy/liboai/archive/v1.0.11.tar.gz"], ) http_archive( name = "com_github_pkusunjy_openai_server_proto", - sha256 = "5c6cf3341f68cc9ac54534363fe2e0c923bfa22c1583a476934cd98d2e2f2540", - strip_prefix = "openai-server-proto-1.1.6", - urls = ["https://github.com/pkusunjy/openai-server-proto/archive/v1.1.6.tar.gz"], + sha256 = "d4d1e58c1f72e4ac93068e9f4bbc381d9a5ea1ddc37407635d175138b06ee92c", + strip_prefix = "openai-server-proto-1.1.13", + urls = ["https://github.com/pkusunjy/openai-server-proto/archive/v1.1.13.tar.gz"], ) http_archive( diff --git a/conf/auth.yaml b/conf/auth.yaml index 18eecf8..d002477 100644 --- a/conf/auth.yaml +++ b/conf/auth.yaml @@ -1,4 +1,10 @@ +# ai api keys openai_api_key: OPENAI_API_KEY +qwen_api_key: QWEN_API_KEY +# ai url roots +openai_url_root: https://mikiai-tokyo-onctmshaci.ap-northeast-1.fcapp.run/v1 +qwen_url_root: https://dashscope.aliyuncs.com/compatible-mode/v1 +# aliyun object storage service oss_endpoint: OSS_ACCESS_ENDPOINT oss_access_key_id: OSS_ACCESS_KEY_ID oss_access_key_secret: OSS_ACCESS_KEY_SECRET \ No newline at end of file diff --git a/src/ielts_ai.cpp b/src/ielts_ai.cpp index 22f776d..c43b1c9 100644 --- a/src/ielts_ai.cpp +++ b/src/ielts_ai.cpp @@ -45,14 +45,6 @@ int32_t main(int32_t argc, char* argv[]) { return 0; } - std::string openai_api_key = token_instance.get_token_by_name("openai_api_key"); - LOG(INFO) << "openai_api_key: " << openai_api_key; - - if (!liboai::Authorization::Authorizer().SetKey(openai_api_key)) { - LOG(WARNING) << "OPENAI_API_KEY not found, server quit"; - return 0; - } - grpc::EnableDefaultHealthCheckService(true); grpc::reflection::InitProtoReflectionServerBuilderPlugin(); diff --git a/src/service/BUILD b/src/service/BUILD index a333991..0d6bfea 100644 --- a/src/service/BUILD +++ b/src/service/BUILD @@ -25,6 +25,7 @@ cc_library( "//src/plugin:log_sink", "//src/plugin:oss", "//src/plugin:prompt", + "//src/plugin:token", "@boost.scope_exit", "@com_github_d7ead_liboai//:oai", "@com_github_grpc_grpc//:grpc++", diff --git a/src/service/ielts_ai.cpp b/src/service/ielts_ai.cpp index b8165e3..4e103f5 100644 --- a/src/service/ielts_ai.cpp +++ b/src/service/ielts_ai.cpp @@ -3,18 +3,26 @@ namespace chat_completion { int32_t IeltsAI::initialize() { + auto& token_instance = plugin::TokenFactory::instance(); + // audio auth + _audio_auth.SetKey(token_instance.get_token_by_name("openai_api_key")); + _chat_auth.SetKey(token_instance.get_token_by_name("qwen_api_key")); // audio _audio = std::make_unique(); if (_audio == nullptr) { LOG(WARNING) << "liboai audio ctor failed"; return -1; } + _audio->SetAuth(_audio_auth); + _audio->UpdateOpenAIRoot(token_instance.get_token_by_name("openai_url_root")); // chat _chat_completion = std::make_unique(); if (_chat_completion == nullptr) { LOG(WARNING) << "liboai completion ctor failed"; return -1; } + _chat_completion->SetAuth(_chat_auth); + _chat_completion->UpdateOpenAIRoot(token_instance.get_token_by_name("qwen_url_root")); // aliyun oss _oss = std::make_unique(); if (_oss == nullptr || _oss->initialize() != 0) { @@ -65,7 +73,7 @@ grpc::Status IeltsAI::transcribe_judge(grpc::ServerContext* ctx, const ChatMessa resp->set_content(transcribe_res); // 4. TODO: delete aliyun oos absl::Time step4 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " get from oss cost: " << absl::ToDoubleMilliseconds(step2 - step1) << " transcribe cost: " << absl::ToDoubleMilliseconds(step3 - step2) << " unlink cost: " << absl::ToDoubleMilliseconds(step4 - step3) @@ -73,4 +81,54 @@ grpc::Status IeltsAI::transcribe_judge(grpc::ServerContext* ctx, const ChatMessa return grpc::Status::OK; } +grpc::Status IeltsAI::text_to_speech(grpc::ServerContext* ctx, const ChatMessage* req, ChatMessage* resp) { + if (_audio == nullptr) { + LOG(WARNING) << "text_to_speech not ready"; + return grpc::Status(grpc::StatusCode::FAILED_PRECONDITION, "text_to_speech not ready"); + } + // 1. call api + absl::Time step1 = absl::Now(); + LOG(INFO) << "received stage:" << req->stage() << " text: " << req->content(); + std::string voice = req->stage() == 1 ? "alloy" : "nova"; + std::string input = req->content(); + + auto res = _audio->speech("tts-1", voice, input); + + std::string local_filename = absl::StrFormat("text_to_speech_%s_%llu.mp3", req->userid(), req->logid()); + { + std::ofstream ocout(local_filename, std::ios::binary); + ocout << res.content; + ocout.close(); + } + + BOOST_SCOPE_EXIT(&req, &local_filename) { + // delete audio file on disk + if (unlink(local_filename.c_str()) < 0) { + char buf[256]; + strerror_r(errno, buf, 256); + LOG(WARNING) << "logid " << req->logid() << "unlink failed file: " << local_filename << ", errno: " << errno + << ", errmsg: " << buf; + } + } + BOOST_SCOPE_EXIT_END + // 2. upload to oss + absl::Time step2 = absl::Now(); + if (_oss->put_object(local_filename, local_filename) != 0) { + LOG(WARNING) << "OssClient put_object failed"; + return grpc::Status(grpc::StatusCode::FAILED_PRECONDITION, "oss error"); + } + // 3. response + absl::Time step3 = absl::Now(); + LOG(INFO) << "logid " << req->logid() << " text_to_speech input: " << input << " result: " << local_filename; + + resp->set_content(local_filename); + // 4. TODO: delete aliyun oos + absl::Time step4 = absl::Now(); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() + << " text_to_speech cost: " << absl::ToDoubleMilliseconds(step2 - step1) + << " upload_oss cost: " << absl::ToDoubleMilliseconds(step3 - step2) + << ", total cost: " << absl::ToDoubleMilliseconds(step3 - step1); + return grpc::Status::OK; +} + } // namespace chat_completion \ No newline at end of file diff --git a/src/service/ielts_ai.h b/src/service/ielts_ai.h index 45e515c..953b959 100644 --- a/src/service/ielts_ai.h +++ b/src/service/ielts_ai.h @@ -16,8 +16,10 @@ #include "chat_completion/chat_completion.grpc.pb.h" #include "components/audio.h" #include "components/chat.h" +#include "core/authorization.h" #include "src/plugin/oss.h" #include "src/plugin/prompt.h" +#include "src/plugin/token.h" namespace chat_completion { @@ -26,8 +28,9 @@ class IeltsAI final : public ChatService::Service { IeltsAI() = default; virtual ~IeltsAI() = default; int32_t initialize(); - // 音频转文字 + // 音频文字互转 grpc::Status transcribe_judge(grpc::ServerContext*, const ChatMessage*, ChatMessage*) override; + grpc::Status text_to_speech(grpc::ServerContext*, const ChatMessage*, ChatMessage*) override; // 雅思口语P1 grpc::Status ielts_speaking_p1_generate(grpc::ServerContext*, const ChatMessage*, grpc::ServerWriter*) override; @@ -100,6 +103,8 @@ class IeltsAI final : public ChatService::Service { void stream_handler() {} private: + liboai::Authorization _audio_auth{}; + liboai::Authorization _chat_auth{}; std::unique_ptr _audio{nullptr}; std::unique_ptr _chat_completion{nullptr}; std::string _model{"qwen-plus"}; diff --git a/src/service/ielts_speaking_p1.cpp b/src/service/ielts_speaking_p1.cpp index dd278ab..2b3363b 100644 --- a/src/service/ielts_speaking_p1.cpp +++ b/src/service/ielts_speaking_p1.cpp @@ -41,8 +41,8 @@ grpc::Status IeltsAI::ielts_speaking_p1_generate(grpc::ServerContext* ctx, const openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -85,8 +85,8 @@ grpc::Status IeltsAI::ielts_speaking_p1_enrich(grpc::ServerContext* ctx, const C openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } diff --git a/src/service/ielts_speaking_p2.cpp b/src/service/ielts_speaking_p2.cpp index fd9db70..2e62121 100644 --- a/src/service/ielts_speaking_p2.cpp +++ b/src/service/ielts_speaking_p2.cpp @@ -41,8 +41,8 @@ grpc::Status IeltsAI::ielts_speaking_p2_generate(grpc::ServerContext* ctx, const openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -85,8 +85,8 @@ grpc::Status IeltsAI::ielts_speaking_p2_enrich(grpc::ServerContext* ctx, const C openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -129,8 +129,8 @@ grpc::Status IeltsAI::ielts_speaking_p2_score(grpc::ServerContext* ctx, const Ch openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } diff --git a/src/service/ielts_speaking_p3.cpp b/src/service/ielts_speaking_p3.cpp index 262c2d3..a675a64 100644 --- a/src/service/ielts_speaking_p3.cpp +++ b/src/service/ielts_speaking_p3.cpp @@ -41,8 +41,8 @@ grpc::Status IeltsAI::ielts_speaking_p3_generate(grpc::ServerContext* ctx, const openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -85,8 +85,8 @@ grpc::Status IeltsAI::ielts_speaking_p3_enrich(grpc::ServerContext* ctx, const C openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } diff --git a/src/service/ielts_words.cpp b/src/service/ielts_words.cpp index c638d03..7a146fb 100644 --- a/src/service/ielts_words.cpp +++ b/src/service/ielts_words.cpp @@ -40,8 +40,8 @@ grpc::Status IeltsAI::ielts_speaking_words_synonyms(grpc::ServerContext* ctx, co openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -83,8 +83,8 @@ grpc::Status IeltsAI::ielts_speaking_words_usage(grpc::ServerContext* ctx, const openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -127,8 +127,8 @@ grpc::Status IeltsAI::ielts_writing_words_theme(grpc::ServerContext* ctx, const openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -170,8 +170,8 @@ grpc::Status IeltsAI::ielts_writing_words_synonyms(grpc::ServerContext* ctx, con openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -213,8 +213,8 @@ grpc::Status IeltsAI::ielts_writing_words_combination(grpc::ServerContext* ctx, openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } diff --git a/src/service/ielts_writing_t1.cpp b/src/service/ielts_writing_t1.cpp index e7d89fc..3f3a46d 100644 --- a/src/service/ielts_writing_t1.cpp +++ b/src/service/ielts_writing_t1.cpp @@ -40,7 +40,7 @@ grpc::Status IeltsAI::ielts_writing_t1_enrich(grpc::ServerContext* ctx, const Ch openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() << ", enrich total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -83,7 +83,7 @@ grpc::Status IeltsAI::ielts_writing_t1_score(grpc::ServerContext* ctx, const Cha openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() << ", score total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } diff --git a/src/service/ielts_writing_t2.cpp b/src/service/ielts_writing_t2.cpp index 8e7329a..087a6b7 100644 --- a/src/service/ielts_writing_t2.cpp +++ b/src/service/ielts_writing_t2.cpp @@ -40,7 +40,7 @@ grpc::Status IeltsAI::ielts_writing_t2_generate(grpc::ServerContext* ctx, const openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << "generate cost time " + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << "generate cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -84,7 +84,7 @@ grpc::Status IeltsAI::ielts_writing_t2_enrich(grpc::ServerContext* ctx, const Ch openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() << ", enrich total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -127,7 +127,7 @@ grpc::Status IeltsAI::ielts_writing_t2_score(grpc::ServerContext* ctx, const Cha openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() << ", score total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } diff --git a/src/service/toefl_speaking_p1.cpp b/src/service/toefl_speaking_p1.cpp index 3e23fec..11fd8a6 100644 --- a/src/service/toefl_speaking_p1.cpp +++ b/src/service/toefl_speaking_p1.cpp @@ -41,8 +41,8 @@ grpc::Status IeltsAI::toefl_speaking_p1_generate(grpc::ServerContext* ctx, const openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -85,8 +85,8 @@ grpc::Status IeltsAI::toefl_speaking_p1_enrich(grpc::ServerContext* ctx, const C openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -129,8 +129,8 @@ grpc::Status IeltsAI::toefl_speaking_p1_score(grpc::ServerContext* ctx, const Ch openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } diff --git a/src/service/toefl_writing_p1.cpp b/src/service/toefl_writing_p1.cpp index 2ad19a7..04875bc 100644 --- a/src/service/toefl_writing_p1.cpp +++ b/src/service/toefl_writing_p1.cpp @@ -40,8 +40,8 @@ grpc::Status IeltsAI::toefl_writing_p1_enrich(grpc::ServerContext* ctx, const Ch openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -83,8 +83,8 @@ grpc::Status IeltsAI::toefl_writing_p1_score(grpc::ServerContext* ctx, const Cha openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } diff --git a/src/service/toefl_writing_p2.cpp b/src/service/toefl_writing_p2.cpp index dd4c56a..86ebf8b 100644 --- a/src/service/toefl_writing_p2.cpp +++ b/src/service/toefl_writing_p2.cpp @@ -40,8 +40,8 @@ grpc::Status IeltsAI::toefl_writing_p2_enrich(grpc::ServerContext* ctx, const Ch openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -83,8 +83,8 @@ grpc::Status IeltsAI::toefl_writing_p2_score(grpc::ServerContext* ctx, const Cha openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } diff --git a/src/service/toefl_writing_p3.cpp b/src/service/toefl_writing_p3.cpp index 7b9331b..a857c84 100644 --- a/src/service/toefl_writing_p3.cpp +++ b/src/service/toefl_writing_p3.cpp @@ -40,8 +40,8 @@ grpc::Status IeltsAI::toefl_writing_p3_enrich(grpc::ServerContext* ctx, const Ch openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -83,8 +83,8 @@ grpc::Status IeltsAI::toefl_writing_p3_generate(grpc::ServerContext* ctx, const openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } diff --git a/src/service/translate.cpp b/src/service/translate.cpp index d35e655..391cd79 100644 --- a/src/service/translate.cpp +++ b/src/service/translate.cpp @@ -40,8 +40,8 @@ grpc::Status IeltsAI::cn_to_en(grpc::ServerContext* ctx, const ChatMessage* req, openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; } @@ -83,8 +83,8 @@ grpc::Status IeltsAI::en_to_cn(grpc::ServerContext* ctx, const ChatMessage* req, openai_resp.wait(); absl::Time step2 = absl::Now(); - LOG(INFO) << "logid " << req->logid() << " uid " << req->uid() << " content " << req->content() << " total cost time " - << absl::ToDoubleMilliseconds(step2 - step1); + LOG(INFO) << "logid " << req->logid() << " uid " << req->userid() << " content " << req->content() + << " total cost time " << absl::ToDoubleMilliseconds(step2 - step1); return grpc::Status::OK; }