Skip to content

[Feature] Siliconflow series online model support#793

Merged
wzh1994 merged 16 commits intoLazyAGI:mainfrom
csf0326:main
Oct 27, 2025
Merged

[Feature] Siliconflow series online model support#793
wzh1994 merged 16 commits intoLazyAGI:mainfrom
csf0326:main

Conversation

@csf0326
Copy link
Contributor

@csf0326 csf0326 commented Oct 14, 2025

📌 PR 内容 / PR Description

  • 增加了对硅基流动api的适配

🔍 相关 Issue / Related Issue

✅ 变更类型 / Type of Change

  • 修复 Bug / Bug fix (non-breaking change that fixes an issue)
  • 新功能 / New feature (non-breaking change that adds functionality)
  • 重构 / Refactor (no functionality change, code structure optimized)
  • 重大变更 / Breaking change (fix or feature that would cause existing functionality to change)
  • 文档更新 / Documentation update (changes to docs only)
  • 性能优化 / Performance optimization

🧪 如何测试 / How Has This Been Tested?

使用/LazyLLM/tests/charge_tests/test_siliconflow.py 测试用例进行测试
pytest test_siliconflow.py

📷 截图 / Demo (Optional)

⚡ 更新后的用法示例 / Usage After Update

import sys
#替换成本地的lazyllm的路径
sys.path.append('/home/mnt/zhuchaoshuai/LazyLLM')
import lazyllm
from lazyllm import OnlineChatModule,OnlineEmbeddingModule,OnlineMultiModalModule
from lazyllm.module.llms.onlinemodule.supplier.sliconflow import SiliconFlowModule

# 测试chat模块
llm = OnlineChatModule(source='siliconflow')
results = llm("你好,介绍自己")

#测试多模态模型
llm = OnlineChatModule(source='siliconflow', model='Qwen/Qwen2.5-VL-72B-Instruct')
print(llm('你好,这是什么?', lazyllm_files=['your_picture_path.png']))

# #测试embed模块
llm = OnlineEmbeddingModule(source='siliconflow')
results = llm("苹果")

#测试rerank模块
llm = OnlineEmbeddingModule(source='siliconflow',type='rerank')
results = llm(["苹果", ['苹果','香蕉','橘子']])

#测试文生图
llm = OnlineMultiModalModule(source='siliconflow',function='text2image')
results = llm("生成一个可爱的小猫")

# #测试文生语音
llm = OnlineMultiModalModule(source='siliconflow',function='tts')
results = llm("你好,你好你好你叫什么名字",voice='fnlp/MOSS-TTSD-v0.5:anna')

# print(results) 
# 

🔄 重构前 / 重构后对比 (仅当 Type 为 Refactor) / Refactor Before & After (only for Refactor)

重构前 / Before:

重构后 / After:

⚠️ 注意事项 / Additional Notes

@ChenJiahaoST ChenJiahaoST changed the title add siliconflow api [Feature] Siliconflow series online model support Oct 14, 2025
@ChenJiahaoST ChenJiahaoST marked this pull request as draft October 15, 2025 03:20
@ChenJiahaoST ChenJiahaoST marked this pull request as ready for review October 15, 2025 11:08
'Content-Type': 'application/json'
}

def _make_request(self, endpoint, payload, timeout=60):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数只有SiliconFlowTextToImageModule用到了,是不是应该定义到SiliconFlowTextToImageModule中

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

raise Exception(f'API request failed: {response.text}')
return response.json()

def _make_binary_request(self, endpoint, payload, timeout=60):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数只有SiliconFlowTTS用到了,挪到SiliconFlowTTS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

}
return encode_query_with_filepaths(None, [file_path])

def __call__(self, text: str, response_format: str = 'mp3',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要重写__call__,会丢失很多能力,比如参数透传,或者自动缓存等。可以看看能不能通过重写forward满足需求

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

return_trace: bool = False, **kwargs):
SiliconFlowMultiModal.__init__(self, model_name=model_name or SiliconFlowTextToImageModule.MODEL_NAME,
base_url=base_url, return_trace=return_trace, api_key=api_key, **kwargs)
OnlineMultiModalBase.__init__(self,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还是那个问题,不要每个变量占单独一行,后面同样的问题一起改一下

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.已修改。
2.ci案例最后一行是有空行的
3.ci api key配置已沟通

@mergify mergify bot added the lint_pass label Oct 24, 2025
@wzh1994 wzh1994 merged commit 1eac591 into LazyAGI:main Oct 27, 2025
39 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants