mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat: introducing streams management pages #166
This commit is contained in:
parent
9c16b55dde
commit
2649b710bb
32 changed files with 3170 additions and 606 deletions
|
@ -1,35 +1,35 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sashabaranov/go-openai"
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sashabaranov/go-openai"
|
||||
)
|
||||
|
||||
type JSON []openai.ChatCompletionMessage
|
||||
type ChatGPTCompletionMessages []openai.ChatCompletionMessage
|
||||
|
||||
// Scan scan value into Jsonb, implements sql.Scanner interface
|
||||
func (j *JSON) Scan(value interface{}) error {
|
||||
bytes, ok := value.([]byte)
|
||||
if !ok {
|
||||
return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", value))
|
||||
}
|
||||
// Scan value into Jsonb, implements sql.Scanner interface
|
||||
func (j *ChatGPTCompletionMessages) Scan(value interface{}) error {
|
||||
bytes, ok := value.([]byte)
|
||||
if !ok {
|
||||
return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", value))
|
||||
}
|
||||
|
||||
result := make([]openai.ChatCompletionMessage, 0)
|
||||
err := json.Unmarshal(bytes, &result)
|
||||
*j = result
|
||||
result := make([]openai.ChatCompletionMessage, 0)
|
||||
err := json.Unmarshal(bytes, &result)
|
||||
*j = result
|
||||
|
||||
return err
|
||||
return err
|
||||
}
|
||||
|
||||
// Value return json value, implement driver.Valuer interface
|
||||
func (j *JSON) Value() (driver.Value, error) {
|
||||
return json.Marshal(*j)
|
||||
func (j *ChatGPTCompletionMessages) Value() (driver.Value, error) {
|
||||
return json.Marshal(*j)
|
||||
}
|
||||
|
||||
type ChatGPTLog struct {
|
||||
Name string `json:"name"`
|
||||
Content JSON `json:"content" gorm:"serializer:json"`
|
||||
Name string `json:"name"`
|
||||
Content ChatGPTCompletionMessages `json:"content" gorm:"serializer:json"`
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ func GenerateAllModel() []any {
|
|||
Cert{},
|
||||
ChatGPTLog{},
|
||||
Site{},
|
||||
Stream{},
|
||||
DnsCredential{},
|
||||
Environment{},
|
||||
Notification{},
|
||||
|
|
8
model/stream.go
Normal file
8
model/stream.go
Normal file
|
@ -0,0 +1,8 @@
|
|||
package model
|
||||
|
||||
type Stream struct {
|
||||
Model
|
||||
Path string `json:"path"`
|
||||
Advanced bool `json:"advanced"`
|
||||
ChatGPTMessages ChatGPTCompletionMessages `json:"chatgpt_messages" gorm:"serializer:json"`
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue