orch-code 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
package/cmd/version.go
CHANGED
|
@@ -140,7 +140,10 @@ func (c *Client) chatWithDoer(ctx context.Context, req providers.ChatRequest, do
|
|
|
140
140
|
|
|
141
141
|
payload := map[string]any{
|
|
142
142
|
"model": model,
|
|
143
|
-
"input":
|
|
143
|
+
"input": req.UserPrompt,
|
|
144
|
+
}
|
|
145
|
+
if strings.TrimSpace(req.SystemPrompt) != "" {
|
|
146
|
+
payload["instructions"] = req.SystemPrompt
|
|
144
147
|
}
|
|
145
148
|
if effort := strings.TrimSpace(req.ReasoningEffort); effort != "" {
|
|
146
149
|
payload["reasoning"] = map[string]any{"effort": effort}
|
|
@@ -238,25 +241,6 @@ func (c *Client) defaultModel(role providers.Role) string {
|
|
|
238
241
|
}
|
|
239
242
|
}
|
|
240
243
|
|
|
241
|
-
func buildInput(system, user string) []map[string]any {
|
|
242
|
-
parts := make([]map[string]any, 0, 2)
|
|
243
|
-
if strings.TrimSpace(system) != "" {
|
|
244
|
-
parts = append(parts, map[string]any{
|
|
245
|
-
"role": "system",
|
|
246
|
-
"content": []map[string]string{
|
|
247
|
-
{"type": "input_text", "text": system},
|
|
248
|
-
},
|
|
249
|
-
})
|
|
250
|
-
}
|
|
251
|
-
parts = append(parts, map[string]any{
|
|
252
|
-
"role": "user",
|
|
253
|
-
"content": []map[string]string{
|
|
254
|
-
{"type": "input_text", "text": user},
|
|
255
|
-
},
|
|
256
|
-
})
|
|
257
|
-
return parts
|
|
258
|
-
}
|
|
259
|
-
|
|
260
244
|
type responsesAPI struct {
|
|
261
245
|
Output []struct {
|
|
262
246
|
Content []struct {
|
|
@@ -3,6 +3,7 @@ package openai
|
|
|
3
3
|
import (
|
|
4
4
|
"context"
|
|
5
5
|
"encoding/base64"
|
|
6
|
+
"encoding/json"
|
|
6
7
|
"fmt"
|
|
7
8
|
"io"
|
|
8
9
|
"net/http"
|
|
@@ -114,7 +115,7 @@ func TestResolveAuthTokenAccountModeWithResolver(t *testing.T) {
|
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
func
|
|
118
|
+
func TestChatAccountModeUsesCodexEndpointAccountHeaderAndInstructions(t *testing.T) {
|
|
118
119
|
client := New(config.OpenAIProviderConfig{
|
|
119
120
|
AuthMode: "account",
|
|
120
121
|
BaseURL: "https://api.openai.com/v1",
|
|
@@ -137,10 +138,28 @@ func TestChatAccountModeUsesCodexEndpointAndAccountHeader(t *testing.T) {
|
|
|
137
138
|
if got := req.Header.Get("Authorization"); !strings.HasPrefix(got, "Bearer ") {
|
|
138
139
|
return nil, fmt.Errorf("missing auth header")
|
|
139
140
|
}
|
|
141
|
+
body, err := io.ReadAll(req.Body)
|
|
142
|
+
if err != nil {
|
|
143
|
+
return nil, fmt.Errorf("read request body: %w", err)
|
|
144
|
+
}
|
|
145
|
+
payload := map[string]any{}
|
|
146
|
+
if err := json.Unmarshal(body, &payload); err != nil {
|
|
147
|
+
return nil, fmt.Errorf("parse request body: %w", err)
|
|
148
|
+
}
|
|
149
|
+
if got := payload["instructions"]; got != "You are a constrained coding agent." {
|
|
150
|
+
return nil, fmt.Errorf("unexpected instructions: %#v", got)
|
|
151
|
+
}
|
|
152
|
+
if got := payload["input"]; got != "Return a diff." {
|
|
153
|
+
return nil, fmt.Errorf("unexpected input: %#v", got)
|
|
154
|
+
}
|
|
140
155
|
return response(http.StatusOK, `{"output_text":"done","status":"completed","usage":{"input_tokens":1,"output_tokens":1,"total_tokens":2}}`), nil
|
|
141
156
|
}}
|
|
142
157
|
|
|
143
|
-
out, err := client.chatWithDoer(context.Background(), providers.ChatRequest{
|
|
158
|
+
out, err := client.chatWithDoer(context.Background(), providers.ChatRequest{
|
|
159
|
+
Role: providers.RoleCoder,
|
|
160
|
+
SystemPrompt: "You are a constrained coding agent.",
|
|
161
|
+
UserPrompt: "Return a diff.",
|
|
162
|
+
}, doer)
|
|
144
163
|
if err != nil {
|
|
145
164
|
t.Fatalf("chat error: %v", err)
|
|
146
165
|
}
|