fix: build problems

This commit is contained in:
Eugen Eisler
2025-02-25 23:12:10 +01:00
parent 952f584158
commit 1e345af0bc
3 changed files with 169 additions and 70 deletions

View File

@@ -5,32 +5,18 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/danielmiessler/fabric/core"
"github.com/gin-gonic/gin"
"io"
"log"
"net/http"
"strings"
"time"
"github.com/danielmiessler/fabric/core"
"github.com/gin-gonic/gin"
)
type OllamaModel struct {
Models []Model `json:"models"`
}
func isValidOllamaRequestBody(body OllamaRequestBody) bool {
if body.Model == "" || len(body.Messages) == 0 {
return false
}
for _, msg := range body.Messages {
if msg.Content == "" || msg.Role == "" {
return false
}
}
return true
}
type Model struct {
Details ModelDetails `json:"details"`
Digest string `json:"digest"`
@@ -156,16 +142,12 @@ func (f APIConvert) ollamaTags(c *gin.Context) {
})
}
if !isValidOllamaRequestBody(prompt) {
log.Printf("Invalid request body: %v", prompt)
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid request body"})
return
}
if !isValidOllamaRequestBody(prompt) {
log.Printf("Invalid request body: %v", prompt)
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid request body"})
return
}
c.JSON(200, response)
}
func (f APIConvert) ollamaChat(c *gin.Context) {
body, err := io.ReadAll(c.Request.Body)
if err != nil {
log.Printf("Error reading body: %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "testing endpoint"})