Skip to content

Commit 637d18d

Browse files
authored
Release/rebase 1.15 (#3691)
2 parents 2997e47 + 716542a commit 637d18d

File tree

18 files changed

+237
-54
lines changed

18 files changed

+237
-54
lines changed

.build-tools/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/dapr/components-contrib/build-tools
22

3-
go 1.23.0
3+
go 1.23.6
44

55
require (
66
github.com/dapr/components-contrib v0.0.0

.build-tools/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
4444
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
4545
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
4646
github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
47-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
48-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
47+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
48+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
4949
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
5050
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
5151
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=

.github/infrastructure/docker-compose-sqlserver.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '2'
1+
version: '3'
22
services:
33
sqlserver:
44
image: mcr.microsoft.com/mssql/server:2019-latest

.github/workflows/certification.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ jobs:
292292
fi
293293
294294
- name: Upload Cert Coverage Report File
295-
uses: actions/upload-artifact@v3
295+
uses: actions/upload-artifact@v4
296296
if: github.event_name == 'schedule'
297297
with:
298-
name: cert_code_cov
298+
name: ${{ matrix.component }}_cert_code_cov
299299
path: ${{ env.TEST_PATH }}/tmp/cert_code_cov_files
300300
retention-days: 7
301301

@@ -311,10 +311,10 @@ jobs:
311311
fi
312312
313313
- name: Upload result files
314-
uses: actions/upload-artifact@v3
314+
uses: actions/upload-artifact@v4
315315
if: always()
316316
with:
317-
name: result_files
317+
name: ${{ matrix.component }}_result_files
318318
path: tmp/result_files
319319
retention-days: 1
320320

@@ -349,11 +349,11 @@ jobs:
349349
350350
- name: Download test result artifact
351351
if: always() && env.PR_NUMBER != ''
352-
uses: actions/download-artifact@v3
352+
uses: actions/download-artifact@v4
353353
continue-on-error: true
354354
id: testresults
355355
with:
356-
name: result_files
356+
# name: not being specified which will result in all artifacts being downloaded
357357
path: tmp/result_files
358358

359359
- name: Build message

.github/workflows/conformance.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,10 @@ jobs:
329329
fi
330330
331331
- name: Upload result files
332-
uses: actions/upload-artifact@v3
332+
uses: actions/upload-artifact@v4
333333
if: always()
334334
with:
335-
name: result_files
335+
name: ${{ matrix.component }}_result_files
336336
path: tmp/result_files
337337
retention-days: 1
338338

@@ -343,17 +343,17 @@ jobs:
343343
cp cover.out tmp/conf_code_cov/${{ env.SOURCE_PATH_LINEAR }}.out
344344
345345
- name: Upload coverage report file
346-
uses: actions/upload-artifact@v3
346+
uses: actions/upload-artifact@v4
347347
if: github.event_name == 'schedule'
348348
with:
349-
name: conf_code_cov
349+
name: ${{ matrix.component }}_conf_code_cov
350350
path: tmp/conf_code_cov
351351
retention-days: 7
352352

353353
# Upload logs for test analytics to consume
354354
- name: Upload test results
355355
if: always()
356-
uses: actions/upload-artifact@main
356+
uses: actions/upload-artifact@v4
357357
with:
358358
name: ${{ matrix.component }}_conformance_test
359359
path: ${{ env.TEST_OUTPUT_FILE_PREFIX }}_conformance.*
@@ -381,11 +381,11 @@ jobs:
381381
382382
- name: Download test result artifact
383383
if: always() && env.PR_NUMBER != ''
384-
uses: actions/download-artifact@v3
384+
uses: actions/download-artifact@v4
385385
continue-on-error: true
386386
id: testresults
387387
with:
388-
name: result_files
388+
# name: not being specified which will result in all artifacts being downloaded
389389
path: tmp/result_files
390390

391391
- name: Build message

bindings/gcp/bucket/bucket.go

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func (g *GCPStorage) create(ctx context.Context, req *bindings.InvokeRequest) (*
164164
var err error
165165
metadata, err := g.metadata.mergeWithRequestMetadata(req)
166166
if err != nil {
167-
return nil, fmt.Errorf("gcp bucket binding error. error merge metadata : %w", err)
167+
return nil, fmt.Errorf("gcp bucket binding error while merging metadata : %w", err)
168168
}
169169

170170
var name string
@@ -186,14 +186,23 @@ func (g *GCPStorage) create(ctx context.Context, req *bindings.InvokeRequest) (*
186186
}
187187

188188
h := g.client.Bucket(g.metadata.Bucket).Object(name).NewWriter(ctx)
189-
defer h.Close()
189+
// Cannot do `defer h.Close()` as Close() will flush the bytes and need to have error handling.
190190
if _, err = io.Copy(h, r); err != nil {
191-
return nil, fmt.Errorf("gcp bucket binding error. Uploading: %w", err)
191+
cerr := h.Close()
192+
if cerr != nil {
193+
return nil, fmt.Errorf("gcp bucket binding error while uploading and closing: %w", err)
194+
}
195+
return nil, fmt.Errorf("gcp bucket binding error while uploading: %w", err)
196+
}
197+
198+
err = h.Close()
199+
if err != nil {
200+
return nil, fmt.Errorf("gcp bucket binding error while flushing: %w", err)
192201
}
193202

194203
objectURL, err := url.Parse(fmt.Sprintf(objectURLBase, g.metadata.Bucket, name))
195204
if err != nil {
196-
return nil, fmt.Errorf("gcp bucket binding error. error building url response: %w", err)
205+
return nil, fmt.Errorf("gcp bucket binding error while building url response: %w", err)
197206
}
198207

199208
resp := createResponse{
@@ -202,7 +211,7 @@ func (g *GCPStorage) create(ctx context.Context, req *bindings.InvokeRequest) (*
202211

203212
b, err := json.Marshal(resp)
204213
if err != nil {
205-
return nil, fmt.Errorf("gcp binding error. error marshalling create response: %w", err)
214+
return nil, fmt.Errorf("gcp bucket binding error while marshalling the create response: %w", err)
206215
}
207216

208217
return &bindings.InvokeResponse{
@@ -213,7 +222,7 @@ func (g *GCPStorage) create(ctx context.Context, req *bindings.InvokeRequest) (*
213222
func (g *GCPStorage) get(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) {
214223
metadata, err := g.metadata.mergeWithRequestMetadata(req)
215224
if err != nil {
216-
return nil, fmt.Errorf("gcp binding error. error merge metadata : %w", err)
225+
return nil, fmt.Errorf("gcp binding error while merging metadata : %w", err)
217226
}
218227

219228
var key string
@@ -231,13 +240,13 @@ func (g *GCPStorage) get(ctx context.Context, req *bindings.InvokeRequest) (*bin
231240
return nil, errors.New("object not found")
232241
}
233242

234-
return nil, fmt.Errorf("gcp bucketgcp bucket binding error: error downloading bucket object: %w", err)
243+
return nil, fmt.Errorf("gcp bucketgcp bucket binding error while downloading object: %w", err)
235244
}
236245
defer rc.Close()
237246

238247
data, err := io.ReadAll(rc)
239248
if err != nil {
240-
return nil, fmt.Errorf("gcp bucketgcp bucket binding error: io.ReadAll: %v", err)
249+
return nil, fmt.Errorf("gcp bucketgcp bucket binding error while reading: %v", err)
241250
}
242251

243252
if metadata.EncodeBase64 {
@@ -299,7 +308,7 @@ func (g *GCPStorage) list(ctx context.Context, req *bindings.InvokeRequest) (*bi
299308

300309
jsonResponse, err := json.Marshal(result)
301310
if err != nil {
302-
return nil, fmt.Errorf("gcp bucketgcp bucket binding error. list operation. cannot marshal blobs to json: %w", err)
311+
return nil, fmt.Errorf("gcp bucketgcp bucket binding error while listing: cannot marshal blobs to json: %w", err)
303312
}
304313

305314
return &bindings.InvokeResponse{
@@ -348,7 +357,7 @@ func (g *GCPStorage) GetComponentMetadata() (metadataInfo metadata.MetadataMap)
348357
func (g *GCPStorage) sign(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) {
349358
metadata, err := g.metadata.mergeWithRequestMetadata(req)
350359
if err != nil {
351-
return nil, fmt.Errorf("gcp binding error. error merge metadata : %w", err)
360+
return nil, fmt.Errorf("gcp binding error while merging metadata : %w", err)
352361
}
353362

354363
var key string
@@ -371,7 +380,7 @@ func (g *GCPStorage) sign(ctx context.Context, req *bindings.InvokeRequest) (*bi
371380
SignURL: signURL,
372381
})
373382
if err != nil {
374-
return nil, fmt.Errorf("gcp bucket binding error: error marshalling sign response: %w", err)
383+
return nil, fmt.Errorf("gcp bucket binding error while marshalling sign response: %w", err)
375384
}
376385
return &bindings.InvokeResponse{
377386
Data: jsonResponse,
@@ -381,7 +390,7 @@ func (g *GCPStorage) sign(ctx context.Context, req *bindings.InvokeRequest) (*bi
381390
func (g *GCPStorage) signObject(bucket, object, ttl string) (string, error) {
382391
d, err := time.ParseDuration(ttl)
383392
if err != nil {
384-
return "", fmt.Errorf("gcp bucket binding error: error parsing signTTL: %w", err)
393+
return "", fmt.Errorf("gcp bucket binding error while parsing signTTL: %w", err)
385394
}
386395
opts := &storage.SignedURLOptions{
387396
Scheme: storage.SigningSchemeV4,

conversation/deepseek/deepseek.go

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
Copyright 2025 The Dapr Authors
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
package deepseek
17+
18+
import (
19+
"context"
20+
"reflect"
21+
22+
"github.com/dapr/components-contrib/conversation"
23+
"github.com/dapr/components-contrib/metadata"
24+
"github.com/dapr/kit/logger"
25+
kmeta "github.com/dapr/kit/metadata"
26+
27+
deepseek_go "github.com/cohesion-org/deepseek-go"
28+
)
29+
30+
type Deepseek struct {
31+
llm *deepseek_go.Client
32+
md DeepseekMetadata
33+
34+
logger logger.Logger
35+
}
36+
37+
func NewDeepseek(logger logger.Logger) conversation.Conversation {
38+
o := &Deepseek{
39+
logger: logger,
40+
}
41+
42+
return o
43+
}
44+
45+
func (d *Deepseek) Init(ctx context.Context, meta conversation.Metadata) error {
46+
md := DeepseekMetadata{}
47+
err := kmeta.DecodeMetadata(meta.Properties, &md)
48+
if err != nil {
49+
return err
50+
}
51+
52+
d.llm = deepseek_go.NewClient(md.Key)
53+
d.md = md
54+
return nil
55+
}
56+
57+
func (d *Deepseek) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
58+
metadataStruct := DeepseekMetadata{}
59+
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.ConversationType)
60+
return
61+
}
62+
63+
func (d *Deepseek) Converse(ctx context.Context, r *conversation.ConversationRequest) (res *conversation.ConversationResponse, err error) {
64+
messages := make([]deepseek_go.ChatCompletionMessage, 0, len(r.Inputs))
65+
66+
for _, input := range r.Inputs {
67+
messages = append(messages, deepseek_go.ChatCompletionMessage{
68+
Role: string(input.Role),
69+
Content: input.Message,
70+
})
71+
}
72+
73+
request := &deepseek_go.ChatCompletionRequest{
74+
Model: deepseek_go.DeepSeekChat,
75+
Messages: messages,
76+
}
77+
78+
if d.md.MaxTokens > 0 {
79+
request.MaxTokens = d.md.MaxTokens
80+
}
81+
82+
if r.Temperature > 0 {
83+
request.Temperature = float32(r.Temperature)
84+
}
85+
86+
resp, err := d.llm.CreateChatCompletion(ctx, request)
87+
if err != nil {
88+
return nil, err
89+
}
90+
91+
outputs := make([]conversation.ConversationResult, 0, len(resp.Choices))
92+
93+
for i := range resp.Choices {
94+
outputs = append(outputs, conversation.ConversationResult{
95+
Result: resp.Choices[i].Message.Content,
96+
Parameters: r.Parameters,
97+
})
98+
}
99+
100+
res = &conversation.ConversationResponse{
101+
Outputs: outputs,
102+
}
103+
104+
return res, nil
105+
}
106+
107+
func (d *Deepseek) Close() error {
108+
return nil
109+
}

conversation/deepseek/metadata.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright 2025 The Dapr Authors
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
// DeepseekMetadata is a common metadata structure for langchain supported implementations.
17+
18+
package deepseek
19+
20+
type DeepseekMetadata struct {
21+
Key string `json:"key"`
22+
MaxTokens int `json:"maxTokens"`
23+
}

conversation/deepseek/metadata.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# yaml-language-server: $schema=../../../component-metadata-schema.json
2+
schemaVersion: v1
3+
type: conversation
4+
name: deepseek
5+
version: v1
6+
status: alpha
7+
title: "Deepseek"
8+
urls:
9+
- title: Reference
10+
url: https://docs.dapr.io/reference/components-reference/supported-conversation/setup-deepseek/
11+
authenticationProfiles:
12+
- title: "API Key"
13+
description: "Authenticate using an API key"
14+
metadata:
15+
- name: key
16+
type: string
17+
required: true
18+
sensitive: true
19+
description: |
20+
API key for Deepseek.
21+
example: "**********"
22+
default: ""
23+
metadata:
24+
- name: maxTokens
25+
required: false
26+
description: |
27+
Max tokens for each request
28+
type: int
29+
example: 2048

0 commit comments

Comments
 (0)