Skip to content

Commit 16a6fd6

Browse files
committed
Update version to v1.0.8
1 parent b3a285a commit 16a6fd6

3 files changed

Lines changed: 32 additions & 15 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ OpenAI-compatible proxy server for the CommandCode API. It exposes `/v1/chat/com
44

55
Repository: https://github.com/dev2k6/command-code-proxy-server
66

7-
Version: `v1.0.7`
7+
Version: `v1.0.8`
88

99
## Features
1010

@@ -219,7 +219,7 @@ https://api.github.com/repos/dev2k6/command-code-proxy-server/tags
219219
If the latest GitHub tag is newer than the current app version, the version line is displayed as:
220220

221221
```text
222-
v1.0.7 (latest: v1.x.x)
222+
v1.0.8 (latest: v1.x.x)
223223
```
224224

225225
## CommandCode version header

internal/proxy/convert.go

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,23 @@ func ConvertMessages(openAIMsgs []api.OpenAIMessage) []api.CCMessage {
5050

5151
if m.Role == "assistant" && len(m.ToolCalls) > 0 {
5252
contentParts := parseContent(m.Content, toolNames)
53+
addedTools := map[string]bool{}
54+
for _, part := range contentParts {
55+
if part.Type == "tool-call" && part.ToolCallID != nil {
56+
addedTools[*part.ToolCallID] = true
57+
}
58+
}
5359
for _, tc := range m.ToolCalls {
60+
if addedTools[tc.ID] {
61+
continue
62+
}
5463
contentParts = append(contentParts, api.CCContentPart{
55-
Type: "tool_use",
56-
ID: strPtr(tc.ID),
57-
Name: strPtr(tc.Function.Name),
58-
Input: parseToolInput(tc.Function.Arguments),
64+
Type: "tool-call",
65+
ToolCallID: strPtr(tc.ID),
66+
ToolName: strPtr(tc.Function.Name),
67+
Input: parseToolInput(tc.Function.Arguments),
5968
})
69+
addedTools[tc.ID] = true
6070
}
6171
ccMsgs = append(ccMsgs, api.CCMessage{Role: m.Role, Content: contentParts})
6272
continue
@@ -218,24 +228,31 @@ func parseContent(content interface{}, toolNames map[string]string) []api.CCCont
218228
if text := contentPartToString(partMap); text != "" {
219229
parts = append(parts, api.CCContentPart{Type: "text", Text: strPtr(text)})
220230
}
221-
case "tool_use":
231+
case "tool_use", "tool-call":
222232
id, _ := partMap["id"].(string)
223-
name, _ := partMap["name"].(string)
224-
if id != "" && name != "" {
225-
toolNames[id] = name
233+
if id == "" {
234+
id, _ = partMap["toolCallId"].(string)
235+
}
236+
if id == "" {
237+
id, _ = partMap["tool_use_id"].(string)
226238
}
227-
parts = append(parts, api.CCContentPart{Type: "tool_use", ID: strPtr(id), Name: strPtr(name), Input: partMap["input"]})
228-
case "tool-call":
229-
id, _ := partMap["id"].(string)
230239
name, _ := partMap["name"].(string)
240+
if name == "" {
241+
name, _ = partMap["toolName"].(string)
242+
}
231243
if id != "" && name != "" {
232244
toolNames[id] = name
233245
}
234246
input := partMap["input"]
235247
if input == nil {
236248
input = partMap["arguments"]
237249
}
238-
parts = append(parts, api.CCContentPart{Type: "tool-call", ID: strPtr(id), Name: strPtr(name), Input: input})
250+
parts = append(parts, api.CCContentPart{
251+
Type: "tool-call",
252+
ToolCallID: strPtr(id),
253+
ToolName: strPtr(name),
254+
Input: input,
255+
})
239256
case "tool_result", "tool-result":
240257
toolID, _ := partMap["tool_use_id"].(string)
241258
if toolID == "" {

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/dev2k6/command-code-proxy-server/internal/update"
1010
)
1111

12-
const appVersion = "v1.0.7"
12+
const appVersion = "v1.0.8"
1313
const repositoryURL = "https://github.com/dev2k6/command-code-proxy-server"
1414
const debugLogging = false
1515

0 commit comments

Comments
 (0)