1
This commit is contained in:
@@ -57,90 +57,6 @@ server {
|
|||||||
proxy_read_timeout 3600s;
|
proxy_read_timeout 3600s;
|
||||||
proxy_send_timeout 3600s;
|
proxy_send_timeout 3600s;
|
||||||
|
|
||||||
# location = /v1/chat/completions {
|
|
||||||
# client_body_buffer_size 16k;
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# 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 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
|
|
||||||
|
|
||||||
# if type(payload.messages) ~= "table" then
|
|
||||||
# return ngx.exec(backend)
|
|
||||||
# end
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# 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)
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
# location @ai_sggai_site_backend {
|
|
||||||
# proxy_pass http://10.1.0.1:3001;
|
|
||||||
# }
|
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://10.1.0.1:3001;
|
proxy_pass http://10.1.0.1:3001;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user