This commit is contained in:
nicole pardal 2025-09-29 20:10:38 -07:00
parent 3aa34ff0e6
commit f944382424
1 changed files with 6 additions and 7 deletions

View File

@ -1246,7 +1246,6 @@ func (s *Server) WebSearchHandler(c *gin.Context) {
req.MaxResults = 5
}
results, err := s.callWebSearchAPI(req.Query, req.MaxResults)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
@ -1269,14 +1268,14 @@ func (s *Server) callWebSearchAPI(query string, maxResults int) ([]api.SearchRes
Query: query,
MaxResults: maxResults,
}
client := api.NewClient(&url.URL{Scheme: "https", Host: "ollama.com"}, http.DefaultClient)
searchResp, err := client.WebSearch(context.Background(), &searchReq)
if err != nil {
return nil, err
}
return searchResp.Results, nil
}
@ -1317,16 +1316,16 @@ func (s *Server) callWebFetchAPI(targetURL string) (string, string, error) {
fetchReq := api.FetchRequest{
URL: targetURL,
}
// Create client to call ollama.com
client := api.NewClient(&url.URL{Scheme: "https", Host: "ollama.com"}, http.DefaultClient)
// Call the web fetch API
fetchResp, err := client.Fetch(context.Background(), &fetchReq)
if err != nil {
return "", "", err
}
return fetchResp.Content, fetchResp.Title, nil
}