try and raise ollama timeout
parent
e5e98e2890
commit
20256bd6b4
13
ai.go
13
ai.go
|
|
@ -2,6 +2,8 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/tmc/langchaingo/llms"
|
"github.com/tmc/langchaingo/llms"
|
||||||
"github.com/tmc/langchaingo/llms/ollama"
|
"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) {
|
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(
|
llm, err := ollama.New(
|
||||||
ollama.WithModel(ai.model),
|
ollama.WithModel(ai.model),
|
||||||
ollama.WithServerURL(ai.url),
|
ollama.WithServerURL(ai.url),
|
||||||
|
ollama.WithHTTPClient(c),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue