Skip to content

Commit f698ed8

Browse files
Merge branch 'master' of github.com:apache/apisix into limit-count-configable-resp-headers
2 parents ef80c08 + e3c904a commit f698ed8

File tree

7 files changed

+66
-10
lines changed

7 files changed

+66
-10
lines changed

apisix-master-0.rockspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ dependencies = {
7171
"ext-plugin-proto = 0.6.1",
7272
"casbin = 1.41.9-1",
7373
"inspect == 3.1.1",
74-
"lualdap = 1.2.6-1",
7574
"lua-resty-rocketmq = 0.3.0-0",
7675
"opentelemetry-lua = 0.2-3",
7776
"net-url = 0.9-1",

apisix/plugins/ai-proxy/drivers/openai.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ function _M.request(conf, request_table, ctx)
4242
end
4343

4444
local ok, err = httpc:connect({
45-
scheme = parsed_url.scheme or "https",
46-
host = parsed_url.host or DEFAULT_HOST,
47-
port = parsed_url.port or DEFAULT_PORT,
45+
scheme = endpoint and parsed_url.scheme or "https",
46+
host = endpoint and parsed_url.host or DEFAULT_HOST,
47+
port = endpoint and parsed_url.port or DEFAULT_PORT,
4848
ssl_verify = conf.ssl_verify,
49-
ssl_server_name = parsed_url.host or DEFAULT_HOST,
49+
ssl_server_name = endpoint and parsed_url.host or DEFAULT_HOST,
5050
pool_size = conf.keepalive and conf.keepalive_pool,
5151
})
5252

5353
if not ok then
5454
return nil, "failed to connect to LLM server: " .. err
5555
end
5656

57-
local path = (parsed_url.path or DEFAULT_PATH)
57+
local path = (endpoint and parsed_url.path or DEFAULT_PATH)
5858

5959
local headers = (conf.auth.header or {})
6060
headers["Content-Type"] = "application/json"

ci/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ GRPC_SERVER_EXAMPLE_VER=20210819
182182

183183
linux_get_dependencies () {
184184
apt update
185-
apt install -y cpanminus build-essential libncurses5-dev libreadline-dev libssl-dev perl libpcre3 libpcre3-dev libldap2-dev
185+
apt install -y cpanminus build-essential libncurses5-dev libreadline-dev libssl-dev perl libpcre3 libpcre3-dev
186186
apt-get install -y libyaml-dev
187187
wget https://github.com/mikefarah/yq/releases/download/3.4.1/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq
188188
}

ci/linux-install-openresty.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ sudo add-apt-repository -y "deb https://openresty.org/package/${arch_path}ubuntu
3535
sudo add-apt-repository -y "deb http://repos.apiseven.com/packages/${arch_path}debian bullseye main"
3636

3737
sudo apt-get update
38-
sudo apt-get install -y libldap2-dev openresty-pcre-dev openresty-zlib-dev build-essential gcc g++ cpanminus
38+
sudo apt-get install -y openresty-pcre-dev openresty-zlib-dev build-essential gcc g++ cpanminus
3939

4040
SSL_LIB_VERSION=${SSL_LIB_VERSION-openssl}
4141
ENABLE_FIPS=${ENABLE_FIPS:-"false"}

t/APISIX.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ _EOC_
465465
$block->set_value("stream_config", $stream_config);
466466
}
467467

468+
my $custom_trusted_cert = $block->custom_trusted_cert // 'cert/apisix.crt';
469+
468470
my $stream_server_config = $block->stream_server_config // <<_EOC_;
469471
listen 2005 ssl;
470472
ssl_certificate cert/apisix.crt;
@@ -737,7 +739,7 @@ _EOC_
737739
http3 off;
738740
ssl_certificate cert/apisix.crt;
739741
ssl_certificate_key cert/apisix.key;
740-
lua_ssl_trusted_certificate cert/apisix.crt;
742+
lua_ssl_trusted_certificate $custom_trusted_cert;
741743
742744
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
743745

t/plugin/ai-proxy2.t

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,58 @@ POST /anything
198198
--- error_code: 200
199199
--- response_body
200200
passed
201+
202+
203+
204+
=== TEST 5: set route without overriding the endpoint_url
205+
--- config
206+
location /t {
207+
content_by_lua_block {
208+
local t = require("lib.test_admin").test
209+
local code, body = t('/apisix/admin/routes/1',
210+
ngx.HTTP_PUT,
211+
[[{
212+
"uri": "/anything",
213+
"plugins": {
214+
"ai-proxy": {
215+
"auth": {
216+
"header": {
217+
"Authorization": "some-key"
218+
}
219+
},
220+
"model": {
221+
"provider": "openai",
222+
"name": "gpt-4",
223+
"options": {
224+
"max_tokens": 512,
225+
"temperature": 1.0
226+
}
227+
}
228+
}
229+
},
230+
"upstream": {
231+
"type": "roundrobin",
232+
"nodes": {
233+
"httpbin.org": 1
234+
}
235+
}
236+
}]]
237+
)
238+
239+
if code >= 300 then
240+
ngx.status = code
241+
end
242+
ngx.say(body)
243+
}
244+
}
245+
--- response_body
246+
passed
247+
248+
249+
250+
=== TEST 6: send request
251+
--- custom_trusted_cert: /etc/ssl/certs/ca-certificates.crt
252+
--- request
253+
POST /anything
254+
{ "messages": [ { "role": "system", "content": "You are a mathematician" }, { "role": "user", "content": "What is 1+1?"} ] }
255+
--- error_code: 401

utils/install-dependencies.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function install_dependencies_with_apt() {
7878
sudo apt-get update
7979

8080
# install some compilation tools
81-
sudo apt-get install -y curl make gcc g++ cpanminus libpcre3 libpcre3-dev libldap2-dev libyaml-dev unzip openresty-zlib-dev openresty-pcre-dev
81+
sudo apt-get install -y curl make gcc g++ cpanminus libpcre3 libpcre3-dev libyaml-dev unzip openresty-zlib-dev openresty-pcre-dev
8282
}
8383

8484
# Identify the different distributions and call the corresponding function

0 commit comments

Comments
 (0)