使用higress代理了一个多模态的服务
使用python访问服务
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
#
# Copyright (c) 2025 Goertek. All Rights Reserved
#
"""
Description
File : demo_deploy.py Date : 2025/03/19 09:51:58 """
""" demo_deploy.py """
import requests import json import base64
def encode_image(image_path): with open(image_path, "rb") as image_file: return base64.b64encode(image_file.read()).decode('utf-8')
def test_post(image_path):
1.urlurl = 'http://xxxx/v1/chat/completions'
# 2.data
# image_path = "1.png"
base64_image = encode_image(image_path) # 编码本地图片
# print(base64_image)
data = {
"model": "mllm_v1",
"messages": [
{
"role": "system",
"content": "你是一个有用无害的ai助手"
},
{
"role": "user",
"content":
[
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{base64_image}"}},
{"type": "text", "text": "请描述图片内容"},
],
}
],
"temperature": 0,
"max_tokens": 2048
}
# 3.将字典转换为 JSON 字符串
json_payload = json.dumps(data)
# 4.发送 POST 请求
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer xxxxx'}
response = requests.post(url, data=json_payload, headers=headers)
# 5.打印响应内容
print(response)
print(response.json())
if name == 'main': image_path = '1.png' test_post(image_path)
3. 调用多模态网关服务1.png(大小10KB)成功,2.png(大小6000KB)失败
4. 直接调用多模态服务(不使用网关),2者都成功
5. higress-log
2025-04-21T08:41:53.782373Z info envoy wasm external/envoy/source/extensions/filters/http/wasm/wasm_filter.h:50 wasm vm is crashed, try to recover thread=89 2025-04-21T08:41:53.787312Z debug envoy wasm external/envoy/source/extensions/common/wasm/wasm.cc:148 Thread-Local Wasm created 25 now active thread=89 2025-04-21T08:41:53.788695Z info envoy wasm external/envoy/source/extensions/common/wasm/wasm.cc:216 wasm vm recover from crash success thread=89 2025-04-21T08:41:53.788709Z info envoy wasm external/envoy/source/extensions/filters/http/wasm/wasm_filter.h:52 wasm vm recover success thread=89 2025-04-21T08:41:53.788718Z debug envoy wasm external/envoy/source/extensions/common/wasm/wasm.cc:191 ~Wasm 24 remaining active thread=89 2025-04-21T08:41:53.789504Z info envoy wasm external/envoy/source/extensions/common/wasm/context.cc:1395 wasm log higress-system.model-router.internal: [extensions/model_router/plugin.cc:161]::onHeader() SetRequestBodyBufferLimit: 104857600 thread=89 2025-04-21T08:41:57.491677Z error envoy wasm external/envoy/source/extensions/common/wasm/wasm_vm.cc:41 Function: proxy_on_request_body failed: Uncaught RuntimeError: unreachable\nProxy-Wasm plugin in-VM backtrace:\n 0: 0x214ee - _Exit\n 1: 0x214d9 - abort\n 2: 0x2b2a2 - operator new(unsigned long)\n 3: 0x2b11c - void* std::2::libcpp_operator_new(unsigned long)\n 4: 0x2b114 - std::2::libcpp_allocate(unsigned long, unsigned long)\n 5: 0x2b100 - std::2::allocator::allocate(unsigned long)\n 6: 0x2b092 - std::2::allocator_traits<std::2::allocator >::allocate(std::2::allocator&, unsigned long)\n 7: 0x2b7b4 - std::2::basic_string<char, std::__2::char_traits, std::2::allocator >::grow_by(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)\n 8: 0x2bce5 - std::__2::basic_string<char, std::2::char_traits, std::2::allocator >::push_back(char)\n 9: 0x1a88e - nlohmann::detail::lexer<nlohmann::basic_json<std::2::map, std::2::vector, std::2::basic_string<char, std::__2::char_traits, std::2::allocator >, bool, long long, unsigned long long, double, std::2::allocator, nlohmann::adl_serializer> >::scan_string() thread=89 2025-04-21T08:41:57.491826Z debug envoy wasm external/envoy/source/extensions/common/wasm/context.cc:1392 wasm log higress-system.basic-auth-1.0.0: [./common/route_rule_matcher.h:118]::checkAuthRule() no match config thread=89 2025-04-21T08:41:57.491875Z debug envoy wasm external/envoy/source/extensions/common/wasm/context.cc:1392 wasm log higress-system.key-auth.internal: [./common/route_rule_matcher.h:118]::checkAuthRule() no match config thread=89 2025-04-21T08:41:57.492014Z debug envoy wasm external/envoy/source/extensions/common/wasm/context.cc:1392 wasm log higress-system.ai-proxy.internal: [ai-proxy] [nil] [dfd082ef-a509-421f-9d03-66c59787b432] [onHttpRequestHeader] no active provider, skip processing thread=89 {"ai_log":"-","authority":"aihub-api.goertek.com:30080","bytes_received":"5930002","bytes_sent":"0","downstream_local_address":"10.42.149.7:80","downstream_remote_address":"10.27.106.248:55425","duration":"3709","istio_policy_status":"-","method":"POST","path":"/v1/chat/completions","protocol":"HTTP/1.1","request_id":"dfd082ef-a509-421f-9d03-66c59787b432","requested_server_name":"-","response_code":"404","response_flags":"NR","route_name":"-","start_time":"2025-04-21T08:41:53.782Z","trace_id":"-","upstream_cluster":"-","upstream_host":"-","upstream_local_address":"-","upstream_service_time":"-","upstream_transport_failure_reason":"-","user_agent":"python-requests/2.32.3","x_forwarded_for":"10.27.106.248","response_code_details":"route_not_found","consumer":"-"}
6. higress-config配置
