modify: aibox_sophon_adapter plugins
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
from chongming_worker import rpc_method
|
||||
from ..models.pydantic import AnalyzePostRequest, AnalyzePostResponse
|
||||
from ..global_var import get_ark_client
|
||||
from ..global_var import get_client, get_is_aicc
|
||||
|
||||
@rpc_method(
|
||||
subject="doubao.analyze",
|
||||
@@ -11,7 +11,7 @@ from ..global_var import get_ark_client
|
||||
)
|
||||
async def analyze(request: AnalyzePostRequest) -> AnalyzePostResponse:
|
||||
print(f"[DEBUG] analyze called with prompt={request.prompt}, image_base64 length={len(request.image_base64)}")
|
||||
client = get_ark_client()
|
||||
client = get_client()
|
||||
if client is None:
|
||||
return AnalyzePostResponse(result="", error="客户端未初始化")
|
||||
|
||||
@@ -29,6 +29,12 @@ async def analyze(request: AnalyzePostRequest) -> AnalyzePostResponse:
|
||||
prompt = request.prompt or ""
|
||||
|
||||
try:
|
||||
# AICC 模式的 AsyncOpenAI 不支持 thinking 参数,需通过 extra_body 传递
|
||||
if get_is_aicc():
|
||||
create_kwargs = {"extra_body": {"thinking": {"type": "disabled"}}}
|
||||
else:
|
||||
create_kwargs = {"thinking": {"type": "disabled"}}
|
||||
|
||||
response = await client.chat.completions.create(
|
||||
model=os.getenv("DOUBAO_MODEL", "doubao-seed-evolving"),
|
||||
messages=[
|
||||
@@ -40,7 +46,7 @@ async def analyze(request: AnalyzePostRequest) -> AnalyzePostResponse:
|
||||
]
|
||||
} # type: ignore
|
||||
],
|
||||
thinking={"type": "disabled"}
|
||||
**create_kwargs # type: ignore
|
||||
)
|
||||
result = response.choices[0].message.content # type: ignore
|
||||
return AnalyzePostResponse(result=result) # type: ignore
|
||||
|
||||
Reference in New Issue
Block a user