mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-17 00:23:56 +00:00
feat: support ollama now (close #870)
This commit is contained in:
@@ -69,6 +69,7 @@ const (
|
||||
ChannelTypeMinimax
|
||||
ChannelTypeMistral
|
||||
ChannelTypeGroq
|
||||
ChannelTypeOllama
|
||||
|
||||
ChannelTypeDummy
|
||||
)
|
||||
@@ -104,6 +105,7 @@ var ChannelBaseURLs = []string{
|
||||
"https://api.minimax.chat", // 27
|
||||
"https://api.mistral.ai", // 28
|
||||
"https://api.groq.com/openai", // 29
|
||||
"http://localhost:11434", // 30
|
||||
}
|
||||
|
||||
const (
|
||||
|
@@ -185,6 +185,10 @@ func GetTimeString() string {
|
||||
return fmt.Sprintf("%s%d", now.Format("20060102150405"), now.UnixNano()%1e9)
|
||||
}
|
||||
|
||||
func GenRequestID() string {
|
||||
return GetTimeString() + GetRandomNumberString(8)
|
||||
}
|
||||
|
||||
func Max(a int, b int) int {
|
||||
if a >= b {
|
||||
return a
|
||||
|
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/songquanpeng/one-api/common/config"
|
||||
"github.com/songquanpeng/one-api/common/helper"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
@@ -94,6 +95,9 @@ func logHelper(ctx context.Context, level string, msg string) {
|
||||
writer = gin.DefaultWriter
|
||||
}
|
||||
id := ctx.Value(RequestIdKey)
|
||||
if id == nil {
|
||||
id = helper.GenRequestID()
|
||||
}
|
||||
now := time.Now()
|
||||
_, _ = fmt.Fprintf(writer, "[%s] %v | %s | %s \n", level, now.Format("2006/01/02 - 15:04:05"), id, msg)
|
||||
if !setupLogWorking {
|
||||
|
Reference in New Issue
Block a user