Skip to content

feat: 新增阿里 qwen-omni 接口支持 #18

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .licenserc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"**/*.go": "// Copyright 2021 ecodeclub",
"**/*.{yml,yaml,sql}": "# Copyright 2021 ecodeclub",
"**/*.{yml,yaml}": "# Copyright 2021 ecodeclub",
"**/*.{sql}": "-- Copyright 2021 ecodeclub",

"**/*.sh": "# Copyright 2021 ecodeclub",

"ignore": [
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,11 @@ tidy:
check:
@$(MAKE) fmt
@$(MAKE) tidy
#@$(MAKE) lint
#@$(MAKE) lint

# 生成gRPC相关文件
.PHONY: grpc
grpc:
@buf format -w ./api/gen
@buf lint
@buf generate
31 changes: 27 additions & 4 deletions api/gen/ai/v1/ai.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions api/gen/ai/v1/ai_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/proto/ai/v1/ai.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ service AIService {
message LLMRequest {
string id = 1;
string text = 2;
string contentType=3;
}

message StreamEvent {
Expand Down
18 changes: 16 additions & 2 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2021 ecodeclub
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

version: v2
managed:
enabled: true
Expand All @@ -6,8 +20,8 @@ managed:
value: github.com/ecodeclub/ai-gateway-go/api/proto/gen
plugins:
- remote: buf.build/protocolbuffers/go
out: ./api/proto/gen
out: ./api/gen
opt: paths=source_relative
- remote: buf.build/grpc/go
out: ./api/proto/gen
out: ./api/gen
opt: paths=source_relative
14 changes: 14 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2021 ecodeclub
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

version: v2
modules:
- path: api/proto
Expand Down
1 change: 1 addition & 0 deletions errs/errs.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ import (
)

var ErrBizConfigNotFound = errors.New("biz config not found")
var ErrApiNotSupport = errors.New("api not support")
14 changes: 12 additions & 2 deletions internal/domain/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@

package domain

type ContentType string

const (
ContentTypeText ContentType = "text"
ContentTypeVideo ContentType = "video_url"
ContentTypeImage ContentType = "image_url"
ContentTypeAudio ContentType = "audio_url"
)

type LLMRequest struct {
Id string
Text string
Id string
Text string
ContentType ContentType
}
type StreamEvent struct {
ReasoningContent string
Expand Down
4 changes: 2 additions & 2 deletions internal/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
func (server *Server) Invoke(ctx context.Context, r *ai.LLMRequest) (*ai.LLMResponse, error) {
resp, err := server.svc.Invoke(
ctx,
domain.LLMRequest{Id: r.GetId(), Text: r.GetText()})
domain.LLMRequest{Id: r.GetId(), Text: r.GetText(), ContentType: domain.ContentType(r.GetContentType())})

Check warning on line 37 in internal/grpc/server.go

View check run for this annotation

Codecov / codecov/patch

internal/grpc/server.go#L37

Added line #L37 was not covered by tests

if err != nil {
return &ai.LLMResponse{}, err
Expand All @@ -48,7 +48,7 @@

ch, err := server.svc.Stream(
ctx,
domain.LLMRequest{Id: r.GetId(), Text: r.GetText()})
domain.LLMRequest{Id: r.GetId(), Text: r.GetText(), ContentType: domain.ContentType(r.GetContentType())})

Check warning on line 51 in internal/grpc/server.go

View check run for this annotation

Codecov / codecov/patch

internal/grpc/server.go#L51

Added line #L51 was not covered by tests

if err != nil {
return err
Expand Down
Loading