Skip to content

Commit a174df1

Browse files
authored
lsc: update copyright and license and downgrade go version (#803)
- Downgrade `model/gemini` to go1.24.0 - Add License header - Replace `interface{}` with `any`
1 parent 681453c commit a174df1

File tree

50 files changed

+331
-101
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+331
-101
lines changed

agent/callbacks_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func TestAgentCallbacks_ContextPropagation(t *testing.T) {
362362
})
363363

364364
// Register after callback that reads the context value.
365-
var capturedValue interface{}
365+
var capturedValue any
366366
callbacks.RegisterAfterAgent(func(ctx context.Context, args *AfterAgentArgs) (*AfterAgentResult, error) {
367367
// Read the value from context.
368368
capturedValue = ctx.Value(testKey)

agent/dify/dify_converter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ func (c *customTestRequestConverter) ConvertToDifyRequest(
615615
) (*dify.ChatMessageRequest, error) {
616616
req := &dify.ChatMessageRequest{
617617
Query: "CUSTOM: " + invocation.Message.Content,
618-
Inputs: map[string]interface{}{
618+
Inputs: map[string]any{
619619
"custom_metadata": "added_by_converter",
620620
},
621621
}

codeexecutor/jupyter/jupyter.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,26 +134,26 @@ func New(opts ...Option) (*CodeExecutor, error) {
134134
return nil, err
135135
}
136136

137-
loggingConfig := map[string]interface{}{
138-
"loggers": map[string]interface{}{
139-
"KernelGatewayApp": map[string]interface{}{
137+
loggingConfig := map[string]any{
138+
"loggers": map[string]any{
139+
"KernelGatewayApp": map[string]any{
140140
"level": c.logLevel,
141141
"handlers": []string{"console"},
142142
},
143143
},
144144
}
145-
logHandlers := map[string]interface{}{}
145+
logHandlers := map[string]any{}
146146

147147
if len(c.logFile) > 0 {
148-
logHandlers["file"] = map[string]interface{}{
148+
logHandlers["file"] = map[string]any{
149149
"class": "logging.handlers.RotatingFileHandler",
150150
"level": c.logLevel,
151151
"maxBytes": c.logMaxBytes,
152152
"filename": c.logFile,
153153
}
154154
loggingConfig["handlers"] = logHandlers
155-
loggingConfig["loggers"] = map[string]interface{}{
156-
"KernelGatewayApp": map[string]interface{}{
155+
loggingConfig["loggers"] = map[string]any{
156+
"KernelGatewayApp": map[string]any{
157157
"level": c.logLevel,
158158
"handlers": []string{"file", "console"},
159159
},

codeexecutor/jupyter/jupyter_client.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ type executionMessage struct {
6969
MsgType string `json:"msg_type"`
7070
MsgID string `json:"msg_id"`
7171
} `json:"header"`
72-
Content map[string]interface{} `json:"content"`
73-
Metadata map[string]interface{} `json:"metadata"`
72+
Content map[string]any `json:"content"`
73+
Metadata map[string]any `json:"metadata"`
7474
ParentHeader struct {
7575
MsgID string `json:"msg_id"`
7676
} `json:"parent_header"`
@@ -243,7 +243,7 @@ func (c *Client) startKernel(kernelName string) (string, error) {
243243
}
244244

245245
func (c *Client) waitForReady() (bool, error) {
246-
msgID, err := c.sendMessage(map[string]interface{}{}, "shell", "kernel_info_request")
246+
msgID, err := c.sendMessage(map[string]any{}, "shell", "kernel_info_request")
247247
if err != nil {
248248
return false, err
249249
}
@@ -267,22 +267,22 @@ func (c *Client) waitForReady() (bool, error) {
267267
}
268268

269269
// sendMessage sends a message to the kernel
270-
func (c *Client) sendMessage(content map[string]interface{}, channel string, messageType string) (string, error) {
270+
func (c *Client) sendMessage(content map[string]any, channel string, messageType string) (string, error) {
271271
timestamp := time.Now().Format(time.RFC3339)
272272
messageID := uuid.New().String()
273-
message := map[string]interface{}{
274-
"header": map[string]interface{}{
273+
message := map[string]any{
274+
"header": map[string]any{
275275
"username": "trpc-agent-go",
276276
"version": "5.0",
277277
"session": c.sessionID,
278278
"msg_id": messageID,
279279
"msg_type": messageType,
280280
"date": timestamp,
281281
},
282-
"parent_header": map[string]interface{}{},
283-
"metadata": map[string]interface{}{},
282+
"parent_header": map[string]any{},
283+
"metadata": map[string]any{},
284284
"content": content,
285-
"buffers": []interface{}{},
285+
"buffers": []any{},
286286
"channel": channel,
287287
}
288288
if c.ws == nil {
@@ -297,11 +297,11 @@ func (c *Client) sendMessage(content map[string]interface{}, channel string, mes
297297

298298
// runCode executes the given code, now only return text output
299299
func (c *Client) runCode(code string) (string, error) {
300-
msgID, err := c.sendMessage(map[string]interface{}{
300+
msgID, err := c.sendMessage(map[string]any{
301301
"code": code,
302302
"silent": false,
303303
"store_history": true,
304-
"user_expressions": map[string]interface{}{},
304+
"user_expressions": map[string]any{},
305305
"allow_stdin": false,
306306
"stop_on_error": true,
307307
}, "shell", "execute_request")

codeexecutor/jupyter/jupyter_client_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
//
2+
// Tencent is pleased to support the open source community by making trpc-agent-go available.
3+
//
4+
// Copyright (C) 2025 Tencent. All rights reserved.
5+
//
6+
// trpc-agent-go is licensed under the Apache License Version 2.0.
7+
//
8+
//
9+
110
package jupyter
211

312
import (
@@ -131,7 +140,7 @@ func (t jupyterHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
131140
return
132141
}
133142
res.Header.MsgType = "status"
134-
res.Content = map[string]interface{}{"execution_state": "idle"}
143+
res.Content = map[string]any{"execution_state": "idle"}
135144
ws.WriteJSON(res)
136145
}
137146

@@ -209,13 +218,13 @@ func Test_waitForReady(t *testing.T) {
209218

210219
func Test_sendMessage(t *testing.T) {
211220
cli := newInvalidClient()
212-
_, err := cli.sendMessage(map[string]interface{}{}, "test", "test")
221+
_, err := cli.sendMessage(map[string]any{}, "test", "test")
213222
assert.Error(t, err)
214223

215224
srv := newServer(t)
216225
defer srv.Close()
217226

218-
_, err = srv.cli.sendMessage(map[string]interface{}{}, "test", "test")
227+
_, err = srv.cli.sendMessage(map[string]any{}, "test", "test")
219228
assert.NoError(t, err)
220229
}
221230

evaluation/evalset/evalset_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestEvalSetJSONRoundTrip(t *testing.T) {
108108
assert.NotNil(t, firstCase.SessionInput)
109109
assert.Equal(t, "demo-app", firstCase.SessionInput.AppName)
110110
assert.Equal(t, "user-42", firstCase.SessionInput.UserID)
111-
assert.Equal(t, map[string]interface{}{"language": "en", "isPremium": true}, firstCase.SessionInput.State)
111+
assert.Equal(t, map[string]any{"language": "en", "isPremium": true}, firstCase.SessionInput.State)
112112
assert.NotNil(t, firstCase.CreationTimestamp)
113113
assert.WithinDuration(t, time.Unix(1700000200, 0).UTC(), firstCase.CreationTimestamp.Time, time.Nanosecond)
114114

@@ -127,19 +127,19 @@ func TestEvalSetJSONRoundTrip(t *testing.T) {
127127
assert.NotNil(t, firstInvocation.IntermediateData)
128128
assert.Len(t, firstInvocation.IntermediateData.ToolUses, 1)
129129
assert.Equal(t, "calculator", firstInvocation.IntermediateData.ToolUses[0].Name)
130-
assert.Equal(t, map[string]interface{}{"operation": "add", "a": float64(1), "b": float64(2)},
130+
assert.Equal(t, map[string]any{"operation": "add", "a": float64(1), "b": float64(2)},
131131
firstInvocation.IntermediateData.ToolUses[0].Args)
132132

133133
assert.Len(t, firstInvocation.IntermediateData.ToolResponses, 1)
134-
expectedToolResponse := map[string]interface{}{"result": float64(3)}
134+
expectedToolResponse := map[string]any{"result": float64(3)}
135135
assert.Equal(t, "calculator", firstInvocation.IntermediateData.ToolResponses[0].Name)
136136
assert.Equal(t, expectedToolResponse, firstInvocation.IntermediateData.ToolResponses[0].Response)
137137

138-
expectedIntermediateResponses := [][]interface{}{
138+
expectedIntermediateResponses := [][]any{
139139
{
140140
"assistant",
141-
[]interface{}{
142-
map[string]interface{}{"text": "Let me compute that."},
141+
[]any{
142+
map[string]any{"text": "Let me compute that."},
143143
},
144144
},
145145
}

evaluation/evalset/inmemory/inmemory_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestManager(t *testing.T) {
5353
SessionInput: &evalset.SessionInput{
5454
AppName: "app",
5555
UserID: "user1",
56-
State: map[string]interface{}{"premium": true},
56+
State: map[string]any{"premium": true},
5757
},
5858
Conversation: []*evalset.Invocation{
5959
{InvocationID: "inv1"},
@@ -82,7 +82,7 @@ func TestManager(t *testing.T) {
8282
EvalID: "case1",
8383
SessionInput: &evalset.SessionInput{
8484
AppName: "app-updated",
85-
State: map[string]interface{}{"level": 2},
85+
State: map[string]any{"level": 2},
8686
},
8787
Conversation: []*evalset.Invocation{
8888
{InvocationID: "inv1"},
@@ -97,7 +97,7 @@ func TestManager(t *testing.T) {
9797
updatedCase, err := mgr.GetCase(ctx, "app", "set1", "case1")
9898
assert.NoError(t, err)
9999
assert.Equal(t, "app-updated", updatedCase.SessionInput.AppName)
100-
assert.Equal(t, map[string]interface{}{"level": 2}, updatedCase.SessionInput.State)
100+
assert.Equal(t, map[string]any{"level": 2}, updatedCase.SessionInput.State)
101101
assert.Len(t, updatedCase.Conversation, 2)
102102

103103
evalSetAfterUpdate, err := mgr.Get(ctx, "app", "set1")
@@ -109,7 +109,7 @@ func TestManager(t *testing.T) {
109109
EvalID: "case2",
110110
SessionInput: &evalset.SessionInput{
111111
AppName: "app",
112-
State: map[string]interface{}{"role": "tester"},
112+
State: map[string]any{"role": "tester"},
113113
},
114114
}
115115
err = mgr.AddCase(ctx, "app", "set1", secondCase)
@@ -206,7 +206,7 @@ func TestManagerValidationAndErrors(t *testing.T) {
206206
err = mgr.UpdateCase(ctx, "ghost", "set", &evalset.EvalCase{
207207
EvalID: "case",
208208
SessionInput: &evalset.SessionInput{
209-
State: map[string]interface{}{"k": "v"},
209+
State: map[string]any{"k": "v"},
210210
},
211211
})
212212
assert.NoError(t, err)

evaluation/service/internal/inference/inference.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func convertToolCallsToFunctionCalls(toolCalls *model.ToolCall) (*genai.Function
204204
if toolCalls.Function.Name == "" {
205205
return nil, errors.New("tool call function name is empty")
206206
}
207-
var args map[string]interface{}
207+
var args map[string]any
208208
if len(toolCalls.Function.Arguments) > 0 {
209209
if err := json.Unmarshal(toolCalls.Function.Arguments, &args); err != nil {
210210
return nil, fmt.Errorf("unmarshal tool arguments: %w", err)

examples/agui/server/langfuse/sse.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
//
2+
// Tencent is pleased to support the open source community by making trpc-agent-go available.
3+
//
4+
// Copyright (C) 2025 Tencent. All rights reserved.
5+
//
6+
// trpc-agent-go is licensed under the Apache License Version 2.0.
7+
//
8+
//
9+
110
package main
211

312
import (

examples/dify/advanced_usage/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (c *CustomRequestConverter) ConvertToDifyRequest(
104104

105105
req := &difySDK.ChatMessageRequest{
106106
Query: invocation.Message.Content,
107-
Inputs: make(map[string]interface{}),
107+
Inputs: make(map[string]any),
108108
}
109109

110110
// Set user ID
@@ -138,8 +138,8 @@ func (c *CustomRequestConverter) ConvertToDifyRequest(
138138
}
139139

140140
// extractUserPreferences extracts user preferences from runtime state
141-
func extractUserPreferences(state map[string]any) map[string]interface{} {
142-
prefs := make(map[string]interface{})
141+
func extractUserPreferences(state map[string]any) map[string]any {
142+
prefs := make(map[string]any)
143143

144144
// Extract common preferences
145145
if lang, ok := state["user_language"]; ok {

0 commit comments

Comments
 (0)