Skip to content

Commit

Permalink
Wrote a whole bunch of code to do joins. Unittests are passing; but t…
Browse files Browse the repository at this point in the history
…here aren't many of these.
  • Loading branch information
jlewi committed Apr 16, 2024
1 parent 8f7bd61 commit 08e6ad0
Show file tree
Hide file tree
Showing 8 changed files with 777 additions and 33 deletions.
9 changes: 9 additions & 0 deletions app/pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,17 @@ func (a *Agent) Generate(ctx context.Context, req *v1alpha1.GenerateRequest) (*v
log = log.WithValues("traceId", span.SpanContext().TraceID())
ctx = logr.NewContext(ctx, log)

log.Info("Agent:generate", "request", req)
blocks, err := a.completeWithRetries(ctx, req)
if err != nil {
// TODO(jeremy): Should we set a status code?
return nil, err
}

// Attach block ids to any blocks generated.
// N.B. This is kind of a last resort to make sure all blocks have an ID set. In general, we want to set blockIds
// earlier in the processing pipeline so that any log messages involving blocks has block ids set. BlockIDs
// should get set in parseResponse. When block Ids are first set.
blockIds, err := docs.SetBlockIds(blocks)
if err != nil {
log.Error(err, "Agent.Generate, failed to set block ids", "blocks", blocks, "blockIds", blockIds)
Expand Down Expand Up @@ -157,6 +161,11 @@ func (a *Agent) parseResponse(ctx context.Context, resp *openai.ChatCompletionRe
continue
}

// Set block ids
if _, err := docs.SetBlockIds(blocks); err != nil {
return nil, errors.Wrapf(err, "Failed to set block ids")
}

allBlocks = append(allBlocks, blocks...)
}
return allBlocks, nil
Expand Down
Loading

0 comments on commit 08e6ad0

Please sign in to comment.