Add yet more debugging information to LLM test.

The current failures are consistent with a timeout when generating
the first prompt, so increase a timeout that a past change forgot to
increase for the first test.

Otherwise, include server-side logs into error output to hopefully shed some
light on what is happening.

PiperOrigin-RevId: 599002718
This commit is contained in:
Etienne Perot
2024-01-16 17:09:52 -08:00
committed by gVisor bot
parent 7aee3ecbba
commit cce5bf7c64
2 changed files with 12 additions and 2 deletions
+11 -1
View File
@@ -356,7 +356,17 @@ type ConversationContext []int
func (llm *Ollama) Prompt(ctx context.Context, prompt *Prompt) (*Response, error) {
resp, err := jsonPost[PromptJSON, ResponseJSON](ctx, llm, "/api/generate", prompt.json())
if err != nil {
return nil, err
if ctx.Err() != nil {
return nil, fmt.Errorf("%w (+ context err: %v)", err, ctx.Err())
}
serverLogs, logsErr := llm.container.Logs(ctx)
if logsErr != nil {
return nil, fmt.Errorf("%w (could not get server logs: %v)", err, logsErr)
}
if serverLogs != "" {
return nil, fmt.Errorf("%w; ollama server logs:\n%v\n(end of ollama server logs)", err, serverLogs)
}
return nil, fmt.Errorf("%w (server logs are empty)", err)
}
return &Response{data: resp}, nil
}
+1 -1
View File
@@ -91,7 +91,7 @@ func TestLLM(t *testing.T) {
"Hello World".
`,
}
promptCtx, promptCancel := context.WithTimeout(ctx, time.Minute)
promptCtx, promptCancel := context.WithTimeout(ctx, 3*time.Minute)
response, err := llm.PromptUntil(promptCtx, &prompt, func(prompt *ollama.Prompt, response *ollama.Response) (*ollama.Prompt, error) {
defer prompt.Model.RaiseTemperature()
text := strings.TrimSpace(response.Text())