From b8f2bf13ab6c5839dfcdc5c16e9480361684e592 Mon Sep 17 00:00:00 2001 From: zxstty Date: Tue, 28 Oct 2025 17:32:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=97=ADopenai=20client=E7=9A=84ssl?= =?UTF-8?q?=E8=AF=81=E4=B9=A6=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/llm/function.py | 10 ++++++++-- apps/llm/reasoning.py | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/llm/function.py b/apps/llm/function.py index 760eb7ec..96a27572 100644 --- a/apps/llm/function.py +++ b/apps/llm/function.py @@ -6,6 +6,7 @@ import logging import re from textwrap import dedent from typing import Any +import httpx from jinja2 import BaseLoader from jinja2.sandbox import SandboxedEnvironment @@ -48,7 +49,7 @@ class FunctionLLM: self._params["timeout"] = 300 if self._config.backend == "ollama": import ollama - + if not self._config.api_key: self._client = ollama.AsyncClient(host=self._config.endpoint) else: @@ -64,11 +65,16 @@ class FunctionLLM: if not self._config.api_key: self._client = openai.AsyncOpenAI( - base_url=self._config.endpoint) + base_url=self._config.endpoint, + http_client=httpx.AsyncClient( + verify=False) # 关闭 openai 的 SSL 验证 + ) else: self._client = openai.AsyncOpenAI( base_url=self._config.endpoint, api_key=self._config.api_key, + http_client=httpx.AsyncClient( + verify=False) # 关闭 openai 的 SSL 验证 ) async def _call_openai( diff --git a/apps/llm/reasoning.py b/apps/llm/reasoning.py index 1944273b..d7c8c12c 100644 --- a/apps/llm/reasoning.py +++ b/apps/llm/reasoning.py @@ -4,7 +4,7 @@ import logging from collections.abc import AsyncGenerator from dataclasses import dataclass - +import httpx from openai import AsyncOpenAI from openai.types.chat import ChatCompletionChunk @@ -111,12 +111,14 @@ class ReasoningLLM: if not self._config.key: self._client = AsyncOpenAI( base_url=self._config.endpoint, + http_client=httpx.AsyncClient(verify=False) # 关闭 SSL 验证 ) return self._client = AsyncOpenAI( api_key=self._config.key, base_url=self._config.endpoint, + http_client=httpx.AsyncClient(verify=False) # 关闭 SSL 验证 ) @staticmethod -- Gitee