bzp2010 commented on code in PR #11499:
URL: https://github.com/apache/apisix/pull/11499#discussion_r1728413935


##########
apisix/init.lua:
##########
@@ -722,7 +722,19 @@ function _M.http_access_phase()
         plugin.run_plugin("access", plugins, api_ctx)
     end
 
-    _M.handle_upstream(api_ctx, route, enable_websocket)
+    if not api_ctx.custom_upstream_ip then
+        _M.handle_upstream(api_ctx, route, enable_websocket)
+    end

Review Comment:
   There is no longer any place to use `ctx.custom_upstream_ip`, this should be 
modified.



##########
apisix/plugins/ai-proxy/schema.lua:
##########
@@ -0,0 +1,167 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+local _M = {}
+
+local auth_schema = {
+    type = "object",
+    properties = {
+        source = {
+            type = "string",
+            enum = {"header", "param"}
+        },
+        name = {
+            type = "string",
+            description = "Name of the param/header carrying Authorization or 
API key.",
+            minLength = 1,
+        },
+        value = {
+            type = "string",
+            description = "Full auth-header/param value.",
+            minLength = 1,
+             -- TODO encrypted = true,
+        },
+    },
+    required = { "source", "name", "value" },
+    additionalProperties = false,
+}
+
+local model_options_schema = {

Review Comment:
   So each model in each provider may have different options? 🤔



##########
apisix/plugins/ai-proxy.lua:
##########
@@ -0,0 +1,92 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+local core = require("apisix.core")
+local schema = require("apisix.plugins.ai-proxy.schema")
+local require = require
+local pcall = pcall
+
+local ngx_req = ngx.req
+local ngx = ngx
+
+local plugin_name = "ai-proxy"
+local _M = {
+    version = 0.5,
+    priority = 1004,
+    name = plugin_name,
+    schema = schema,
+}
+
+
+function _M.check_schema(conf)
+    local ai_driver = pcall(require, "apisix.plugins.ai-proxy.drivers." .. 
conf.model.provider)
+    if not ai_driver then
+        return false, "provider: " .. conf.model.provider .. " is not 
supported."
+    end
+    return core.schema.check(schema.plugin_schema, conf)
+end
+
+
+local CONTENT_TYPE_JSON = "application/json"
+
+
+function _M.access(conf, ctx)
+    local route_type = conf.route_type
+    ctx.ai_proxy = {}
+
+    local ct = core.request.header(ctx, "Content-Type") or CONTENT_TYPE_JSON
+    if ct ~= CONTENT_TYPE_JSON and ct ~= CONTENT_TYPE_JSON .. ";charset=utf8" 
then

Review Comment:
   What I mean is that we would be better using startsWith to check if the 
string starts with a value.



##########
apisix/plugins/traffic-split.lua:
##########
@@ -18,12 +18,9 @@ local core       = require("apisix.core")
 local upstream   = require("apisix.upstream")
 local schema_def = require("apisix.schema_def")
 local roundrobin = require("resty.roundrobin")
-local ipmatcher  = require("resty.ipmatcher")

Review Comment:
   We'd prefer not to modify it in this PR, you can indeed create reusable code 
snippets first, but please modify the call in traffic-split in another PR.



##########
apisix/plugins/ai-proxy.lua:
##########
@@ -0,0 +1,92 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+local core = require("apisix.core")
+local schema = require("apisix.plugins.ai-proxy.schema")
+local require = require
+local pcall = pcall
+
+local ngx_req = ngx.req
+local ngx = ngx
+
+local plugin_name = "ai-proxy"
+local _M = {
+    version = 0.5,
+    priority = 1004,
+    name = plugin_name,
+    schema = schema,
+}
+
+
+function _M.check_schema(conf)
+    local ai_driver = pcall(require, "apisix.plugins.ai-proxy.drivers." .. 
conf.model.provider)
+    if not ai_driver then
+        return false, "provider: " .. conf.model.provider .. " is not 
supported."
+    end
+    return core.schema.check(schema.plugin_schema, conf)
+end
+
+
+local CONTENT_TYPE_JSON = "application/json"
+
+
+function _M.access(conf, ctx)
+    local route_type = conf.route_type
+    ctx.ai_proxy = {}
+
+    local ct = core.request.header(ctx, "Content-Type") or CONTENT_TYPE_JSON
+    if ct ~= CONTENT_TYPE_JSON and ct ~= CONTENT_TYPE_JSON .. ";charset=utf8" 
then

Review Comment:
   The latter can't be asserted either, so why can't I use utf16 encoding?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to