From c1312694976dc56ca1bde7305d03684f3a58a539 Mon Sep 17 00:00:00 2001 From: wdh-home <243823965@qq.com> Date: Mon, 18 May 2026 23:05:27 +0800 Subject: [PATCH] 1 --- conf/conf.d/ai.sggai.site.conf | 138 ++++++++++++++++----------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/conf/conf.d/ai.sggai.site.conf b/conf/conf.d/ai.sggai.site.conf index 784d691..e717b0d 100644 --- a/conf/conf.d/ai.sggai.site.conf +++ b/conf/conf.d/ai.sggai.site.conf @@ -57,89 +57,89 @@ server { proxy_read_timeout 3600s; proxy_send_timeout 3600s; - location = /v1/chat/completions { - client_body_buffer_size 16k; +# location = /v1/chat/completions { +# client_body_buffer_size 16k; - content_by_lua_block { - local backend = "@ai_sggai_site_backend" - local max_body_bytes = 1024 +# content_by_lua_block { +# local backend = "@ai_sggai_site_backend" +# local max_body_bytes = 1024 - if ngx.req.get_method() ~= "POST" then - return ngx.exec(backend) - end +# if ngx.req.get_method() ~= "POST" then +# return ngx.exec(backend) +# end - local content_length = tonumber(ngx.var.http_content_length) - if not content_length then - return ngx.exec(backend) - end +# local content_length = tonumber(ngx.var.http_content_length) +# if not content_length then +# return ngx.exec(backend) +# end - if content_length > max_body_bytes then - return ngx.exec(backend) - end +# if content_length > max_body_bytes then +# return ngx.exec(backend) +# end - ngx.req.read_body() +# ngx.req.read_body() - local body = ngx.req.get_body_data() - if not body or #body > max_body_bytes then - return ngx.exec(backend) - end +# local body = ngx.req.get_body_data() +# if not body or #body > max_body_bytes then +# return ngx.exec(backend) +# end - local cjson = require "cjson.safe" - local short_post_log = { - method = ngx.req.get_method(), - uri = ngx.var.request_uri, - content_length = content_length, - content_type = ngx.var.http_content_type, - user_agent = ngx.var.http_user_agent, - body = body - } - ngx.log(ngx.NOTICE, "[ai.sggai.site] short POST request: ", cjson.encode(short_post_log) or body) +# local cjson = require "cjson.safe" +# local short_post_log = { +# method = ngx.req.get_method(), +# uri = ngx.var.request_uri, +# content_length = content_length, +# content_type = ngx.var.http_content_type, +# user_agent = ngx.var.http_user_agent, +# body = body +# } +# ngx.log(ngx.NOTICE, "[ai.sggai.site] short POST request: ", cjson.encode(short_post_log) or body) - local payload = cjson.decode(body) - if type(payload) ~= "table" or payload.stream ~= false then - return ngx.exec(backend) - end +# local payload = cjson.decode(body) +# if type(payload) ~= "table" or payload.stream ~= false then +# return ngx.exec(backend) +# end - if type(payload.messages) ~= "table" then - return ngx.exec(backend) - end +# if type(payload.messages) ~= "table" then +# return ngx.exec(backend) +# end - local has_hi_content = false +# local has_hi_content = false - for _, message in ipairs(payload.messages) do - if type(message) == "table" and message.content == "hi" then - has_hi_content = true - break - end - end +# for _, message in ipairs(payload.messages) do +# if type(message) == "table" and message.content == "hi" then +# has_hi_content = true +# break +# end +# end - if not has_hi_content then - return ngx.exec(backend) - end +# if not has_hi_content then +# return ngx.exec(backend) +# end - ngx.status = ngx.HTTP_OK - ngx.header["Content-Type"] = "application/json; charset=utf-8" - ngx.say([[{ - "id": "chatcmpl-mock", - "object": "chat.completion", - "created": 1716030000, - "model": "xxx", - "choices": [ - { - "index": 0, - "message": { "role": "assistant", "content": "ok" }, - "finish_reason": "stop" - } - ], - "usage": { "prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2 } -}]]) - return ngx.exit(ngx.HTTP_OK) - } - } +# ngx.status = ngx.HTTP_OK +# ngx.header["Content-Type"] = "application/json; charset=utf-8" +# ngx.say([[{ +# "id": "chatcmpl-mock", +# "object": "chat.completion", +# "created": 1716030000, +# "model": "xxx", +# "choices": [ +# { +# "index": 0, +# "message": { "role": "assistant", "content": "ok" }, +# "finish_reason": "stop" +# } +# ], +# "usage": { "prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2 } +# }]]) +# return ngx.exit(ngx.HTTP_OK) +# } +# } - location @ai_sggai_site_backend { - proxy_pass http://10.1.0.1:3001; - } +# location @ai_sggai_site_backend { +# proxy_pass http://10.1.0.1:3001; +# } location / { proxy_pass http://10.1.0.1:3001;