Skip to content

Commit 43e0956

Browse files
Rename chatID to completionID
1 parent 231b4f0 commit 43e0956

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

pkg/monitor/display.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,23 @@ func (d *display) Event(event runner.Event) {
131131
d.livePrinter.end()
132132
if event.ChatRequest == nil {
133133
log = log.Fields(
134-
"chatID", event.ChatTransactionID,
134+
"completionID", event.ChatCompletionID,
135135
"response", toJSON(event.ChatResponse),
136136
"cached", event.ChatResponseCached,
137137
)
138138
} else {
139139
log.Infof("openai request sent [%s]", callName)
140140
log = log.Fields(
141-
"chatID", event.ChatTransactionID,
141+
"completionID", event.ChatCompletionID,
142142
"request", toJSON(event.ChatRequest),
143143
)
144144
}
145145
log.Debugf("messages")
146146
currentCall.Messages = append(currentCall.Messages, message{
147-
ChatID: event.ChatTransactionID,
148-
Request: event.ChatRequest,
149-
Response: event.ChatResponse,
150-
Cached: event.ChatResponseCached,
147+
CompletionID: event.ChatCompletionID,
148+
Request: event.ChatRequest,
149+
Response: event.ChatResponse,
150+
Cached: event.ChatResponseCached,
151151
})
152152
case runner.EventTypeCallFinish:
153153
d.livePrinter.end()
@@ -263,10 +263,10 @@ type dump struct {
263263
}
264264

265265
type message struct {
266-
ChatID string `json:"chatID,omitempty"`
267-
Request any `json:"request,omitempty"`
268-
Response any `json:"response,omitempty"`
269-
Cached bool `json:"cached,omitempty"`
266+
CompletionID string `json:"completionID,omitempty"`
267+
Request any `json:"request,omitempty"`
268+
Response any `json:"response,omitempty"`
269+
Cached bool `json:"cached,omitempty"`
270270
}
271271

272272
type call struct {

pkg/openai/client.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ const (
2828
)
2929

3030
var (
31-
key = os.Getenv("OPENAI_API_KEY")
32-
url = os.Getenv("OPENAI_URL")
33-
transactionID int64
31+
key = os.Getenv("OPENAI_API_KEY")
32+
url = os.Getenv("OPENAI_URL")
33+
completionID int64
3434
)
3535

3636
type Client struct {
@@ -239,12 +239,12 @@ func toMessages(ctx context.Context, cache *cache.Client, request types.Completi
239239
}
240240

241241
type Status struct {
242-
OpenAITransactionID string
243-
Request any
244-
Response any
245-
Cached bool
246-
Chunks any
247-
PartialResponse *types.CompletionMessage
242+
CompletionID string
243+
Request any
244+
Response any
245+
Cached bool
246+
Chunks any
247+
PartialResponse *types.CompletionMessage
248248
}
249249

250250
func (c *Client) Call(ctx context.Context, messageRequest types.CompletionRequest, status chan<- Status) (*types.CompletionMessage, error) {
@@ -290,10 +290,10 @@ func (c *Client) Call(ctx context.Context, messageRequest types.CompletionReques
290290
}
291291
}
292292

293-
id := fmt.Sprint(atomic.AddInt64(&transactionID, 1))
293+
id := fmt.Sprint(atomic.AddInt64(&completionID, 1))
294294
status <- Status{
295-
OpenAITransactionID: id,
296-
Request: request,
295+
CompletionID: id,
296+
Request: request,
297297
}
298298

299299
var cacheResponse bool
@@ -316,10 +316,10 @@ func (c *Client) Call(ctx context.Context, messageRequest types.CompletionReques
316316
}
317317

318318
status <- Status{
319-
OpenAITransactionID: id,
320-
Chunks: response,
321-
Response: result,
322-
Cached: cacheResponse,
319+
CompletionID: id,
320+
Chunks: response,
321+
Response: result,
322+
Cached: cacheResponse,
323323
}
324324

325325
return &result, nil
@@ -416,7 +416,7 @@ func (c *Client) call(ctx context.Context, request openai.ChatCompletionRequest,
416416
}
417417

418418
partial <- Status{
419-
OpenAITransactionID: transactionID,
419+
CompletionID: transactionID,
420420
PartialResponse: &types.CompletionMessage{
421421
Role: types.CompletionMessageRoleTypeAssistant,
422422
Content: types.Text(msg + "Waiting for model response...\n"),
@@ -442,8 +442,8 @@ func (c *Client) call(ctx context.Context, request openai.ChatCompletionRequest,
442442
if partial != nil {
443443
partialMessage = appendMessage(partialMessage, response)
444444
partial <- Status{
445-
OpenAITransactionID: transactionID,
446-
PartialResponse: &partialMessage,
445+
CompletionID: transactionID,
446+
PartialResponse: &partialMessage,
447447
}
448448
}
449449
responses = append(responses, response)

pkg/runner/runner.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ type Event struct {
8787
CallContext *engine.Context
8888
ToolResults int
8989
Type EventType
90-
ChatTransactionID string
90+
ChatCompletionID string
9191
ChatRequest any
9292
ChatResponse any
9393
ChatResponseCached bool
@@ -167,18 +167,18 @@ func streamProgress(callCtx *engine.Context, monitor Monitor) (chan openai.Statu
167167
for status := range progress {
168168
if message := status.PartialResponse; message != nil {
169169
monitor.Event(Event{
170-
Time: time.Now(),
171-
CallContext: callCtx,
172-
Type: EventTypeCallProgress,
173-
ChatTransactionID: status.OpenAITransactionID,
174-
Content: message.String(),
170+
Time: time.Now(),
171+
CallContext: callCtx,
172+
Type: EventTypeCallProgress,
173+
ChatCompletionID: status.CompletionID,
174+
Content: message.String(),
175175
})
176176
} else {
177177
monitor.Event(Event{
178178
Time: time.Now(),
179179
CallContext: callCtx,
180180
Type: EventTypeChat,
181-
ChatTransactionID: status.OpenAITransactionID,
181+
ChatCompletionID: status.CompletionID,
182182
ChatRequest: status.Request,
183183
ChatResponse: status.Response,
184184
ChatResponseCached: status.Cached,

0 commit comments

Comments
 (0)