diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f509d11..94e08fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,8 +23,6 @@ jobs: 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 - sed -i "s/TOKEN_WX_APPID/${{ secrets.TOKEN_WX_APPID }}/g" ./conf/auth.yaml - sed -i "s/TOKEN_WX_SECRET/${{ secrets.TOKEN_WX_SECRET }}/g" ./conf/auth.yaml bazel build --action_env=CC=clang-14 //... mkdir -p output/bin output/conf mv ./bazel-bin/src/ielts_ai output/bin/ diff --git a/MODULE.bazel b/MODULE.bazel index dca7adb..8e32405 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,9 +6,7 @@ bazel_dep(name = "abseil-cpp", version = "20240116.2") bazel_dep(name = "boost.scope_exit", version = "1.83.0.bzl.1") bazel_dep(name = "boringssl", version = "0.0.0-20240530-2db0eb3") bazel_dep(name = "c-ares", version = "1.16.1") -# bazel_dep(name = "cpp-httplib", version = "0.7.15") bazel_dep(name = "googletest", version = "1.14.0.bcr.1") -bazel_dep(name = "gazelle", version = "0.37.0") bazel_dep(name = "grpc", version = "1.62.1", repo_name = "com_github_grpc_grpc") bazel_dep(name = "nlohmann_json", version = "3.11.3") bazel_dep(name = "rules_foreign_cc", version = "0.9.0") diff --git a/README.md b/README.md index 3c7603d..1b85acf 100644 --- a/README.md +++ b/README.md @@ -1,21 +1 @@ # openai-grpc-server - -## 1. Install dependencies required by grpc-gateway. - -## 2. Generate gRPC stubs - -``` -protoc -I . \ - --go_out ./ --go_opt paths=source_relative \ - --go-grpc_out ./ --go-grpc_opt paths=source_relative \ - proto/chat_completion/chat_completion.proto -``` - -## 3. Generate reverse-proxy using protoc-gen-grpc-gateway - -``` -protoc -I . --grpc-gateway_out ./ \ - --grpc-gateway_opt paths=source_relative \ - --grpc-gateway_opt generate_unbound_methods=true \ - proto/chat_completion/chat_completion.proto -``` diff --git a/WORKSPACE b/WORKSPACE index ab754d2..ce0cbe4 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -28,13 +28,6 @@ http_archive( urls = ["https://github.com/pkusunjy/openai-server-proto/archive/v1.1.6.tar.gz"], ) -http_archive( - name = "tacopie", - sha256 = "bbdebecdb68d5f9eb64170217000daf844e0aee18b8c4d3dd373d07efd9f7316", - strip_prefix = "tacopie-master", - url = "https://github.com/cylix/tacopie/archive/master.zip", -) - http_archive( name = "com_github_aliyun_oss_sdk", build_file = "//bazel:aliyun_oss_sdk.BUILD", diff --git a/conf/auth.yaml b/conf/auth.yaml index 67bf7c8..18eecf8 100644 --- a/conf/auth.yaml +++ b/conf/auth.yaml @@ -1,6 +1,4 @@ openai_api_key: OPENAI_API_KEY -wx_appid: TOKEN_WX_APPID -wx_secret: TOKEN_WX_SECRET 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/BUILD b/src/BUILD index c607c83..bcd4350 100644 --- a/src/BUILD +++ b/src/BUILD @@ -9,7 +9,6 @@ cc_binary( "//src/plugin:log_sink", "//src/plugin:oss", "//src/plugin:token", - "//src/service:auth", "//src/service:ielts_ai", "@abseil-cpp//absl/flags:flag", "@abseil-cpp//absl/flags:parse", diff --git a/src/ielts_ai.cpp b/src/ielts_ai.cpp index 62d9edd..22f776d 100644 --- a/src/ielts_ai.cpp +++ b/src/ielts_ai.cpp @@ -15,7 +15,6 @@ #include "liboai.h" #include "src/plugin/log_sink.h" #include "src/plugin/token.h" -#include "src/service/auth.h" #include "src/service/ielts_ai.h" ABSL_FLAG(uint16_t, port, 8123, "Server port for the service"); @@ -69,10 +68,6 @@ int32_t main(int32_t argc, char* argv[]) { builder.AddListeningPort(server_addr, grpc::SslServerCredentials(ssl_opts)); } - // auth - auth::AuthImpl auth_service; - builder.RegisterService(&auth_service); - // chat chat_completion::IeltsAI chat_service; if (chat_service.initialize() != 0) { diff --git a/src/service/BUILD b/src/service/BUILD index 7fcd3a4..4b2af76 100644 --- a/src/service/BUILD +++ b/src/service/BUILD @@ -2,22 +2,6 @@ package( default_visibility = ["//:__subpackages__"], ) -cc_library( - name = "auth", - srcs = [ - "auth.cpp", - ], - hdrs = [ - "auth.h", - ], - deps = [ - "//src/plugin:token", - "@com_github_grpc_grpc//:grpc++", - "@com_github_grpc_grpc//:grpc++_reflection", - "@com_github_pkusunjy_openai_server_proto//:auth_cc_grpc", - ], -) - cc_library( name = "ielts_ai", srcs = [ diff --git a/src/service/auth.cpp b/src/service/auth.cpp deleted file mode 100644 index 8f02567..0000000 --- a/src/service/auth.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "src/service/auth.h" - -#include "absl/log/log.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_split.h" -#include "absl/time/time.h" -#include "src/plugin/token.h" - -namespace auth { - -grpc::Status AuthImpl::get_wx_miniprogram_token(grpc::ServerContext* ctx, const AuthRequest* req, AuthResponse* resp) { - auto& instance = plugin::TokenFactory::instance(); - resp->set_appid(instance.get_token_by_name("wx_appid")); - resp->set_secret(instance.get_token_by_name("wx_secret")); - return grpc::Status::OK; -} - -grpc::Status AuthImpl::get_oss_token(grpc::ServerContext* ctx, const AuthRequest* req, AuthResponse* resp) { - auto& instance = plugin::TokenFactory::instance(); - resp->set_oss_endpoint(instance.get_token_by_name("oss_endpoint")); - resp->set_oss_access_key_id(instance.get_token_by_name("oss_access_key_id")); - resp->set_oss_access_key_secret(instance.get_token_by_name("oss_access_key_secret")); - return grpc::Status::OK; -} - -} // namespace auth \ No newline at end of file diff --git a/src/service/auth.h b/src/service/auth.h deleted file mode 100644 index 4353433..0000000 --- a/src/service/auth.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include <grpcpp/ext/proto_server_reflection_plugin.h> -#include <grpcpp/grpcpp.h> -#include <grpcpp/health_check_service_interface.h> - -#include "auth/auth.grpc.pb.h" - -namespace auth { - -class AuthImpl final : public AuthService::Service { - public: - AuthImpl() = default; - virtual ~AuthImpl() = default; - grpc::Status get_wx_miniprogram_token(grpc::ServerContext*, const AuthRequest*, AuthResponse*) override; - grpc::Status get_oss_token(grpc::ServerContext*, const AuthRequest*, AuthResponse*) override; -}; - -} // namespace auth