Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AzureOpenAI and Skylark support stream ChatCompletion #2

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

lihq1403
Copy link

微软OpenAI 和 豆包 支持流式响应

@lihq1403
Copy link
Author

微软OpenAI 和 豆包 支持视觉

{
$buffer = '';
while (! $stream->eof()) {
if ('' === ($byte = $stream->read(1))) {
Copy link

Choose a reason for hiding this comment

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

这代码性能爆炸

Copy link

Choose a reason for hiding this comment

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

不影响大局,暂时先这样吧

src/Api/Skylark/Client.php Outdated Show resolved Hide resolved
src/Model/ChatglmModel.php Show resolved Hide resolved
src/Model/ModelInterface.php Show resolved Hide resolved
src/Model/OllamaModel.php Show resolved Hide resolved
src/Model/OpenAIModel.php Show resolved Hide resolved
src/Model/SkylarkModel.php Outdated Show resolved Hide resolved
src/Api/Skylark/SkylarkConfig.php Outdated Show resolved Hide resolved
src/Api/Skylark/SkylarkConfig.php Outdated Show resolved Hide resolved
src/Api/Skylark/SkylarkConfig.php Outdated Show resolved Hide resolved
@@ -54,7 +54,7 @@ public function chat(
array $tools = [],
bool $stream = false,
): ChatCompletionResponse {
$deploymentPath = $this->buildDeploymentPath($model);
$deploymentPath = $this->buildDeploymentPath();
Copy link
Member

Choose a reason for hiding this comment

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

为啥所有 $model 传参都去掉了?这样会让这个类在 DI 单例的情况下只能支持一种 Model

Copy link
Author

Choose a reason for hiding this comment

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

因为下面的那个

protected function buildDeploymentPath(): string
{
    return 'openai/deployments/' . $this->config->getDeploymentName();
}

中的 $this->config->getDeploymentName() 已经不提供入参了,语法检测会提示让我去掉

对于 AzureOpenAI 来说,传入一种配置,其实也就只能访问一个模型,因为 url 里面会有模型名,这里传入不同的 model 其实是无影响的,AzureOpenAI 的接口没有使用该参数


protected bool $debug = false;

protected string $model;
Copy link
Member

Choose a reason for hiding this comment

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

理论上应该想办法去掉这个 $this->model 才对

Copy link
Author

Choose a reason for hiding this comment

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

对,其实这个 model 没啥用,里面的 $clients 其实也只会有一个值

@huangzhhui
Copy link
Member

Skylark 应该直接废弃掉,讲道理现在火山的模型名字不叫做云雀了,应该统一叫豆包(Doubao)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants