feat: revert default to wanyamaelis Qwen3.8-27B and expand verified non-ZeroGPU endpoints
This commit is contained in:
@@ -32,10 +32,10 @@ var (
|
||||
ConfiguredModel string
|
||||
EnableThinkingDefault = true
|
||||
DefaultEndpoints = []string{
|
||||
"https://halvo78-qwen3-8-flash-next-playground.hf.space",
|
||||
"https://wanyamaelis-qwen3-8-27b.hf.space",
|
||||
"https://apathy-exe-qwen3-8-27b.hf.space",
|
||||
"https://apathy-exe-qwen3-8-flash-next.hf.space",
|
||||
"https://mikelalda-qwen3-8-euskera-gguf-q4.hf.space",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -517,7 +517,7 @@ func EffectiveModelID(reqModel string, defaultModel string) string {
|
||||
if defaultModel != "" {
|
||||
return defaultModel
|
||||
}
|
||||
return "Qwen/Qwen3.8-Flash-Next"
|
||||
return "Qwen/Qwen3.8-27B"
|
||||
default:
|
||||
return clean
|
||||
}
|
||||
@@ -1154,6 +1154,27 @@ func (f *StreamToolCallFilter) HasEmittedCalls() bool {
|
||||
// Qwen3.8-Flash Service & Gradio Stream Parsing
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
func extractMessageContent(msgMap map[string]interface{}) string {
|
||||
contentVal := msgMap["content"]
|
||||
if contentStr, ok := contentVal.(string); ok {
|
||||
return contentStr
|
||||
}
|
||||
if contentSlice, ok := contentVal.([]interface{}); ok {
|
||||
var sb strings.Builder
|
||||
for _, item := range contentSlice {
|
||||
if s, ok := item.(string); ok {
|
||||
sb.WriteString(s)
|
||||
} else if m, ok := item.(map[string]interface{}); ok {
|
||||
if textVal, ok := m["text"].(string); ok {
|
||||
sb.WriteString(textVal)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.String()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// parseAssistantText extracts the latest assistant message text from the Gradio output array.
|
||||
func parseAssistantText(dataJSON string) (string, bool) {
|
||||
var raw []interface{}
|
||||
@@ -1172,9 +1193,12 @@ func parseAssistantText(dataJSON string) (string, bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
// Find the last assistant message
|
||||
for i := len(msgList) - 1; i >= 0; i-- {
|
||||
msgMap, ok := msgList[i].(map[string]interface{})
|
||||
var reasoningText string
|
||||
var answerText string
|
||||
var foundAssistant bool
|
||||
|
||||
for _, item := range msgList {
|
||||
msgMap, ok := item.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
@@ -1182,27 +1206,35 @@ func parseAssistantText(dataJSON string) (string, bool) {
|
||||
if role != "assistant" {
|
||||
continue
|
||||
}
|
||||
foundAssistant = true
|
||||
text := extractMessageContent(msgMap)
|
||||
|
||||
contentVal := msgMap["content"]
|
||||
if contentStr, ok := contentVal.(string); ok {
|
||||
return contentStr, true
|
||||
}
|
||||
if contentSlice, ok := contentVal.([]interface{}); ok {
|
||||
var sb strings.Builder
|
||||
for _, item := range contentSlice {
|
||||
if s, ok := item.(string); ok {
|
||||
sb.WriteString(s)
|
||||
} else if m, ok := item.(map[string]interface{}); ok {
|
||||
if textVal, ok := m["text"].(string); ok {
|
||||
sb.WriteString(textVal)
|
||||
}
|
||||
}
|
||||
isReasoning := false
|
||||
if meta, ok := msgMap["metadata"].(map[string]interface{}); ok {
|
||||
if title, ok := meta["title"].(string); ok && strings.EqualFold(title, "reasoning") {
|
||||
isReasoning = true
|
||||
}
|
||||
return sb.String(), true
|
||||
}
|
||||
|
||||
if isReasoning {
|
||||
reasoningText = text
|
||||
} else {
|
||||
answerText = text
|
||||
}
|
||||
}
|
||||
|
||||
return "", false
|
||||
if !foundAssistant {
|
||||
return "", false
|
||||
}
|
||||
|
||||
if reasoningText != "" {
|
||||
if answerText != "" {
|
||||
return fmt.Sprintf("<think>\n%s\n</think>\n\n%s", reasoningText, answerText), true
|
||||
}
|
||||
return fmt.Sprintf("<think>\n%s\n</think>", reasoningText), true
|
||||
}
|
||||
|
||||
return answerText, true
|
||||
}
|
||||
|
||||
type EndpointNode struct {
|
||||
@@ -1252,7 +1284,7 @@ func parseEndpointList(rawList []string) []*EndpointNode {
|
||||
|
||||
func NewQwenService(endpoints []string, modelName, mode, token, apiKey, baseURL, socksProxy string, enableThinking, autoFailover bool) *QwenService {
|
||||
if modelName == "" {
|
||||
modelName = "Qwen/Qwen3.8-Flash-Next"
|
||||
modelName = "Qwen/Qwen3.8-27B"
|
||||
}
|
||||
if mode == "" {
|
||||
mode = "auto"
|
||||
@@ -1289,18 +1321,18 @@ func (s *QwenService) ListModels() []ModelItem {
|
||||
now := time.Now().Unix()
|
||||
primaryID := s.modelName
|
||||
if primaryID == "" {
|
||||
primaryID = "Qwen/Qwen3.8-Flash-Next"
|
||||
primaryID = "Qwen/Qwen3.8-27B"
|
||||
}
|
||||
|
||||
candidates := []string{
|
||||
primaryID,
|
||||
"Qwen/Qwen3.8-Flash-Next",
|
||||
"Qwen/Qwen3.8-27B",
|
||||
"Qwen/Qwen3.8-Flash-Next",
|
||||
"Qwen/Qwen3.8-27B-Uncensored",
|
||||
"qwen3.8-27b",
|
||||
"qwen3.8-flash-next",
|
||||
"qwen-flash-next",
|
||||
"qwen-flash",
|
||||
"qwen3.8-27b",
|
||||
"qwen3.8-27b-uncensored",
|
||||
"qwen",
|
||||
}
|
||||
@@ -1314,7 +1346,7 @@ func (s *QwenService) ListModels() []ModelItem {
|
||||
ID: id,
|
||||
Object: "model",
|
||||
Created: now,
|
||||
OwnedBy: "qwen",
|
||||
OwnedBy: "qwen-community",
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1328,13 +1360,13 @@ func (s *QwenService) detectEndpointModeFor(epURL, defaultMode string) string {
|
||||
}
|
||||
|
||||
ep := strings.ToLower(epURL)
|
||||
if strings.Contains(ep, "microhero") || strings.HasSuffix(ep, "/respond") {
|
||||
if strings.Contains(ep, "microhero") || strings.Contains(ep, "jickman") || strings.HasSuffix(ep, "/respond") {
|
||||
return "respond"
|
||||
}
|
||||
if strings.Contains(ep, "halvo78") || strings.HasSuffix(ep, "/chat_response") {
|
||||
return "chat_response"
|
||||
}
|
||||
if strings.Contains(ep, "wanyamaelis") || strings.Contains(ep, "apathy-exe") || strings.HasSuffix(ep, "/v1") {
|
||||
if strings.Contains(ep, "wanyamaelis") || strings.Contains(ep, "apathy-exe") || strings.Contains(ep, "mikelalda") || strings.HasSuffix(ep, "/v1") {
|
||||
return "openai"
|
||||
}
|
||||
|
||||
@@ -1587,13 +1619,13 @@ func (s *QwenService) chatDirectOpenAI(endpointURL string, w http.ResponseWriter
|
||||
|
||||
func (s *QwenService) chatGradioRespond(endpointURL string, w http.ResponseWriter, r *http.Request, req ChatCompletionRequest, resolvedModel string, maxTokens int) error {
|
||||
var promptText string
|
||||
var sysPrompt string
|
||||
toolsPrompt := FormatToolsPrompt(req.Tools)
|
||||
|
||||
if len(req.Messages) == 1 && req.Messages[0].Role == "user" && len(req.Tools) == 0 {
|
||||
promptText = req.Messages[0].GetContentString()
|
||||
} else {
|
||||
var sb strings.Builder
|
||||
var sysPrompt string
|
||||
for _, m := range req.Messages {
|
||||
if m.Role == "system" {
|
||||
if sysPrompt != "" {
|
||||
@@ -1679,14 +1711,34 @@ func (s *QwenService) chatGradioRespond(endpointURL string, w http.ResponseWrite
|
||||
effHFToken = s.token
|
||||
}
|
||||
|
||||
gradioData := []interface{}{
|
||||
map[string]interface{}{
|
||||
"text": promptText,
|
||||
"files": []interface{}{},
|
||||
},
|
||||
clampedTokens,
|
||||
tempVal,
|
||||
topPVal,
|
||||
var gradioData []interface{}
|
||||
if strings.Contains(strings.ToLower(endpointURL), "jickman") {
|
||||
jickmanSys := sysPrompt
|
||||
if jickmanSys == "" {
|
||||
jickmanSys = "You are a helpful assistant."
|
||||
}
|
||||
gradioData = []interface{}{
|
||||
map[string]interface{}{
|
||||
"text": promptText,
|
||||
"files": []interface{}{},
|
||||
},
|
||||
"low",
|
||||
tempVal,
|
||||
topPVal,
|
||||
40,
|
||||
clampedTokens,
|
||||
jickmanSys,
|
||||
}
|
||||
} else {
|
||||
gradioData = []interface{}{
|
||||
map[string]interface{}{
|
||||
"text": promptText,
|
||||
"files": []interface{}{},
|
||||
},
|
||||
clampedTokens,
|
||||
tempVal,
|
||||
topPVal,
|
||||
}
|
||||
}
|
||||
|
||||
gradioPayload := map[string]interface{}{"data": gradioData}
|
||||
@@ -2232,7 +2284,7 @@ func main() {
|
||||
autoFailover := flag.Bool("failover", true, "Enable automatic failover across endpoints on error or quota limit")
|
||||
flag.BoolVar(autoFailover, "auto-failover", true, "Alias for -failover")
|
||||
|
||||
defaultModelVal := "Qwen/Qwen3.8-Flash-Next"
|
||||
defaultModelVal := "Qwen/Qwen3.8-27B"
|
||||
if envModel := os.Getenv("QFLASH_MODEL"); envModel != "" {
|
||||
defaultModelVal = envModel
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user