Merge pull request #894 from trheyi/main
Add type filtering for assistants in API and data loading
This commit is contained in:
commit
ae3fba4a0b
4 changed files with 13 additions and 17 deletions
|
|
@ -962,6 +962,7 @@ func (neo *DSL) handleGenerateCustom(c *gin.Context) {
|
||||||
func (neo *DSL) handleAssistantList(c *gin.Context) {
|
func (neo *DSL) handleAssistantList(c *gin.Context) {
|
||||||
// Parse filter parameters
|
// Parse filter parameters
|
||||||
filter := store.AssistantFilter{
|
filter := store.AssistantFilter{
|
||||||
|
Type: "assistant",
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
|
|
@ -1106,6 +1107,7 @@ func (neo *DSL) handleAssistantDetail(c *gin.Context) {
|
||||||
|
|
||||||
filter := store.AssistantFilter{
|
filter := store.AssistantFilter{
|
||||||
AssistantID: assistantID,
|
AssistantID: assistantID,
|
||||||
|
Type: "assistant",
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 1,
|
PageSize: 1,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,21 +78,7 @@ func LoadBuiltIn() error {
|
||||||
assistant.Sort = sort
|
assistant.Sort = sort
|
||||||
}
|
}
|
||||||
if assistant.Tags == nil {
|
if assistant.Tags == nil {
|
||||||
assistant.Tags = []string{"Built-in"}
|
assistant.Tags = []string{}
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the assistant has Built-in tag
|
|
||||||
hasBuiltIn := false
|
|
||||||
for _, tag := range assistant.Tags {
|
|
||||||
if tag == "Built-in" {
|
|
||||||
hasBuiltIn = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// add Built-in tag if not exists
|
|
||||||
if !hasBuiltIn {
|
|
||||||
assistant.Tags = append(assistant.Tags, "Built-in")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the assistant
|
// Save the assistant
|
||||||
|
|
@ -254,8 +240,10 @@ func LoadPath(path string) (*Assistant, error) {
|
||||||
// assistant_id
|
// assistant_id
|
||||||
id := strings.ReplaceAll(strings.TrimPrefix(path, "/assistants/"), "/", ".")
|
id := strings.ReplaceAll(strings.TrimPrefix(path, "/assistants/"), "/", ".")
|
||||||
data["assistant_id"] = id
|
data["assistant_id"] = id
|
||||||
data["type"] = "assistant"
|
|
||||||
data["path"] = path
|
data["path"] = path
|
||||||
|
if _, has := data["type"]; !has {
|
||||||
|
data["type"] = "assistant"
|
||||||
|
}
|
||||||
|
|
||||||
updatedAt := int64(0)
|
updatedAt := int64(0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ type ChatGroupResponse struct {
|
||||||
// Used for filtering and pagination when retrieving assistant lists
|
// Used for filtering and pagination when retrieving assistant lists
|
||||||
type AssistantFilter struct {
|
type AssistantFilter struct {
|
||||||
Tags []string `json:"tags,omitempty"` // Filter by tags
|
Tags []string `json:"tags,omitempty"` // Filter by tags
|
||||||
|
Type string `json:"type,omitempty"` // Filter by type
|
||||||
Keywords string `json:"keywords,omitempty"` // Search in name and description
|
Keywords string `json:"keywords,omitempty"` // Search in name and description
|
||||||
Connector string `json:"connector,omitempty"` // Filter by connector
|
Connector string `json:"connector,omitempty"` // Filter by connector
|
||||||
AssistantID string `json:"assistant_id,omitempty"` // Filter by assistant ID
|
AssistantID string `json:"assistant_id,omitempty"` // Filter by assistant ID
|
||||||
|
|
|
||||||
|
|
@ -1058,6 +1058,11 @@ func (conv *Xun) GetAssistants(filter AssistantFilter) (*AssistantResponse, erro
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply type filter if provided
|
||||||
|
if filter.Type != "" {
|
||||||
|
qb.Where("type", filter.Type)
|
||||||
|
}
|
||||||
|
|
||||||
// Apply connector filter if provided
|
// Apply connector filter if provided
|
||||||
if filter.Connector != "" {
|
if filter.Connector != "" {
|
||||||
qb.Where("connector", filter.Connector)
|
qb.Where("connector", filter.Connector)
|
||||||
|
|
@ -1259,7 +1264,7 @@ func (conv *Xun) DeleteAssistants(filter AssistantFilter) (int64, error) {
|
||||||
// GetAssistantTags retrieves all unique tags from assistants
|
// GetAssistantTags retrieves all unique tags from assistants
|
||||||
func (conv *Xun) GetAssistantTags() ([]string, error) {
|
func (conv *Xun) GetAssistantTags() ([]string, error) {
|
||||||
q := conv.newQuery().Table(conv.getAssistantTable())
|
q := conv.newQuery().Table(conv.getAssistantTable())
|
||||||
rows, err := q.Select("tags").GroupBy("tags").Get()
|
rows, err := q.Select("tags").Where("type", "assistant").GroupBy("tags").Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue