-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix failures to compute embeddings too much context.
* Prior to this document we were computing the embeddings using the entire notebook. This would lead to context exceeded errors on longer documents. * This had two negative impacts 1. We stop learning from long documents because we no longer compute embeddings for the document 1. When making suggestions we don't embed up retrieving any documents from RAG because we can't compute the embeddings for the current document * This PR also refactors the code to share code for computing embeddings between the learner and the Agent to minimize risk of training and serving skew. * Fix #260
- Loading branch information
Showing
10 changed files
with
124 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package oai | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/pkg/errors" | ||
"github.com/sashabaranov/go-openai" | ||
) | ||
|
||
func Test_HTTPStatusCode(t *testing.T) { | ||
type testCase struct { | ||
name string | ||
err error | ||
expected int | ||
} | ||
|
||
cases := []testCase{ | ||
{ | ||
name: "basic", | ||
err: &openai.APIError{ | ||
HTTPStatusCode: 404, | ||
}, | ||
expected: 404, | ||
}, | ||
{ | ||
name: "wrapped", | ||
err: errors.Wrapf(&openai.APIError{ | ||
HTTPStatusCode: 509, | ||
}, "wrapped"), | ||
expected: 509, | ||
}, | ||
{ | ||
name: "not api error", | ||
err: errors.New("not an api error"), | ||
expected: -1, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
actual := HTTPStatusCode(tc.err) | ||
if actual != tc.expected { | ||
t.Errorf("expected %v, got %v", tc.expected, actual) | ||
} | ||
}) | ||
} | ||
} |