mirror of
https://github.com/coalaura/whiskr.git
synced 2025-09-09 01:09:54 +00:00
debug and sc update
This commit is contained in:
BIN
.github/chat.png
vendored
BIN
.github/chat.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 125 KiB |
7
chat.go
7
chat.go
@@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/revrost/go-openrouter"
|
"github.com/revrost/go-openrouter"
|
||||||
)
|
)
|
||||||
@@ -122,8 +121,7 @@ func HandleChat(w http.ResponseWriter, r *http.Request) {
|
|||||||
request.Stream = true
|
request.Stream = true
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
b, _ := json.MarshalIndent(request, "", "\t")
|
dump(request)
|
||||||
os.WriteFile("debug.json", b, 0755)
|
|
||||||
|
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
|
|
||||||
@@ -165,6 +163,9 @@ func HandleChat(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
choice := chunk.Choices[0]
|
choice := chunk.Choices[0]
|
||||||
|
|
||||||
|
// DEBUG
|
||||||
|
debug(choice)
|
||||||
|
|
||||||
if choice.FinishReason == openrouter.FinishReasonContentFilter {
|
if choice.FinishReason == openrouter.FinishReasonContentFilter {
|
||||||
response.Send(ErrorChunk(errors.New("stopped due to content_filter")))
|
response.Send(ErrorChunk(errors.New("stopped due to content_filter")))
|
||||||
|
|
||||||
|
23
debug.go
Normal file
23
debug.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dump(v any) {
|
||||||
|
if !Debug {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
b, _ := json.MarshalIndent(v, "", "\t")
|
||||||
|
os.WriteFile("debug.json", b, 0644)
|
||||||
|
}
|
||||||
|
|
||||||
|
func debug(v any) {
|
||||||
|
if !Debug {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("%#v\n", v)
|
||||||
|
}
|
11
env.go
11
env.go
@@ -7,12 +7,21 @@ import (
|
|||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
)
|
)
|
||||||
|
|
||||||
var OpenRouterToken string
|
var (
|
||||||
|
Debug bool
|
||||||
|
OpenRouterToken string
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
log.MustPanic(godotenv.Load())
|
log.MustPanic(godotenv.Load())
|
||||||
|
|
||||||
|
Debug = os.Getenv("DEBUG") == "true"
|
||||||
|
|
||||||
if OpenRouterToken = os.Getenv("OPENROUTER_TOKEN"); OpenRouterToken == "" {
|
if OpenRouterToken = os.Getenv("OPENROUTER_TOKEN"); OpenRouterToken == "" {
|
||||||
log.Panic(errors.New("missing openrouter token"))
|
log.Panic(errors.New("missing openrouter token"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if Debug {
|
||||||
|
log.Debug("Debug mode enabled")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -119,7 +119,7 @@ body {
|
|||||||
.message {
|
.message {
|
||||||
position: relative;
|
position: relative;
|
||||||
max-width: 700px;
|
max-width: 700px;
|
||||||
min-width: 200px;
|
min-width: 280px;
|
||||||
width: max-content;
|
width: max-content;
|
||||||
padding-top: 28px;
|
padding-top: 28px;
|
||||||
background: #363a4f;
|
background: #363a4f;
|
||||||
|
Reference in New Issue
Block a user