feat: allow more input types to functions, fix tests (#377)
* feat: use json.rawMessage, test functions
* chore: lint
* fix: tests
the ChatCompletion mock server doesn't actually run otherwise. N=0
is the default request but the server will treat it as n=1
* fix: tests should default to n=1 completions
* chore: add back removed interfaces, custom marshal
* chore: lint
* chore: lint
* chore: add some tests
* chore: appease lint
* clean up JSON schema + tests
* chore: lint
* feat: remove backwards compatible functions
for illustrative purposes
* fix: revert params change
* chore: use interface{}
* chore: add test
* chore: add back FunctionDefine
* chore: /s/interface{}/any
* chore: add back jsonschemadefinition
* chore: testcov
* chore: lint
* chore: remove pointers
* chore: update comment
* chore: address CR
added test for compatibility as well
---------
Co-authored-by: James <jmacwhyte@MacBooger-II.local>
This commit is contained in:
@@ -83,7 +83,11 @@ func handleCompletionEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||
Model: completionReq.Model,
|
||||
}
|
||||
// create completions
|
||||
for i := 0; i < completionReq.N; i++ {
|
||||
n := completionReq.N
|
||||
if n == 0 {
|
||||
n = 1
|
||||
}
|
||||
for i := 0; i < n; i++ {
|
||||
// generate a random string of length completionReq.Length
|
||||
completionStr := strings.Repeat("a", completionReq.MaxTokens)
|
||||
if completionReq.Echo {
|
||||
@@ -94,8 +98,8 @@ func handleCompletionEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||
Index: i,
|
||||
})
|
||||
}
|
||||
inputTokens := numTokens(completionReq.Prompt.(string)) * completionReq.N
|
||||
completionTokens := completionReq.MaxTokens * completionReq.N
|
||||
inputTokens := numTokens(completionReq.Prompt.(string)) * n
|
||||
completionTokens := completionReq.MaxTokens * n
|
||||
res.Usage = Usage{
|
||||
PromptTokens: inputTokens,
|
||||
CompletionTokens: completionTokens,
|
||||
|
||||
Reference in New Issue
Block a user