@@ -165,40 +165,47 @@ func createLLM() (llms.Model, error) {
165
165
}
166
166
167
167
func getAllTags (ctx context.Context , baseURL , apiToken string ) (map [string ]int , error ) {
168
+ tagIDMapping := make (map [string ]int )
168
169
url := fmt .Sprintf ("%s/api/tags/" , baseURL )
169
- req , err := http .NewRequestWithContext (ctx , "GET" , url , nil )
170
- if err != nil {
171
- return nil , err
172
- }
173
- req .Header .Set ("Authorization" , fmt .Sprintf ("Token %s" , apiToken ))
174
170
175
171
client := & http.Client {}
176
- resp , err := client .Do (req )
177
- if err != nil {
178
- return nil , err
179
- }
180
- defer resp .Body .Close ()
181
172
182
- if resp .StatusCode != http .StatusOK {
183
- bodyBytes , _ := io .ReadAll (resp .Body )
184
- return nil , fmt .Errorf ("Error fetching tags: %d, %s" , resp .StatusCode , string (bodyBytes ))
185
- }
173
+ for url != "" {
174
+ req , err := http .NewRequestWithContext (ctx , "GET" , url , nil )
175
+ if err != nil {
176
+ return nil , err
177
+ }
178
+ req .Header .Set ("Authorization" , fmt .Sprintf ("Token %s" , apiToken ))
186
179
187
- var tagsResponse struct {
188
- Results []struct {
189
- ID int `json:"id"`
190
- Name string `json:"name"`
191
- } `json:"results"`
192
- }
180
+ resp , err := client .Do (req )
181
+ if err != nil {
182
+ return nil , err
183
+ }
184
+ defer resp .Body .Close ()
193
185
194
- err = json . NewDecoder ( resp . Body ). Decode ( & tagsResponse )
195
- if err != nil {
196
- return nil , err
197
- }
186
+ if resp . StatusCode != http . StatusOK {
187
+ bodyBytes , _ := io . ReadAll ( resp . Body )
188
+ return nil , fmt . Errorf ( "Error fetching tags: %d, %s" , resp . StatusCode , string ( bodyBytes ))
189
+ }
198
190
199
- tagIDMapping := make (map [string ]int )
200
- for _ , tag := range tagsResponse .Results {
201
- tagIDMapping [tag .Name ] = tag .ID
191
+ var tagsResponse struct {
192
+ Results []struct {
193
+ ID int `json:"id"`
194
+ Name string `json:"name"`
195
+ } `json:"results"`
196
+ Next string `json:"next"`
197
+ }
198
+
199
+ err = json .NewDecoder (resp .Body ).Decode (& tagsResponse )
200
+ if err != nil {
201
+ return nil , err
202
+ }
203
+
204
+ for _ , tag := range tagsResponse .Results {
205
+ tagIDMapping [tag .Name ] = tag .ID
206
+ }
207
+
208
+ url = tagsResponse .Next
202
209
}
203
210
204
211
return tagIDMapping , nil
0 commit comments