try and raise ollama timeout
This commit is contained in:
13
ai.go
13
ai.go
@@ -2,6 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/tmc/langchaingo/llms"
|
||||
"github.com/tmc/langchaingo/llms/ollama"
|
||||
@@ -32,9 +34,20 @@ func NewAIOllama(url, model string) AIOllama {
|
||||
}
|
||||
|
||||
func (ai AIOllama) Do(ctx context.Context, prompt string) (string, error) {
|
||||
c := &http.Client{
|
||||
Timeout: time.Hour,
|
||||
Transport: &http.Transport{
|
||||
//DisableKeepAlives: true,
|
||||
IdleConnTimeout: time.Hour,
|
||||
ResponseHeaderTimeout: time.Hour,
|
||||
ExpectContinueTimeout: time.Hour,
|
||||
},
|
||||
}
|
||||
defer c.CloseIdleConnections()
|
||||
llm, err := ollama.New(
|
||||
ollama.WithModel(ai.model),
|
||||
ollama.WithServerURL(ai.url),
|
||||
ollama.WithHTTPClient(c),
|
||||
)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
Reference in New Issue
Block a user