Implement temporary mock SID for chat handling and comment out userID retrieval in chat queries
- Added a temporary mock SID value in the handleChat, handleChatList, and handleChatLatest functions to facilitate testing. - Commented out userID retrieval in GetChat, GetChatWithFilter, and getChatsWithFilter methods to simplify query logic during development. - Updated GetHistory method to comment out userID usage, maintaining consistency across chat-related functionalities.
This commit is contained in:
parent
b98dc53acb
commit
d973686760
3 changed files with 26 additions and 23 deletions
|
|
@ -218,6 +218,7 @@ func (agent *API) handleChat(c *gin.Context) {
|
|||
// handleChatList handles the chat list request
|
||||
func (agent *API) handleChatList(c *gin.Context) {
|
||||
sid := c.GetString("__sid")
|
||||
sid = "temporary-mock-sid-123"
|
||||
if sid == "" {
|
||||
c.JSON(400, gin.H{"message": "sid is required", "code": 400})
|
||||
c.Done()
|
||||
|
|
@ -262,6 +263,7 @@ func (agent *API) handleChatList(c *gin.Context) {
|
|||
// handleChatHistory handles the chat history request
|
||||
func (agent *API) handleChatHistory(c *gin.Context) {
|
||||
sid := c.GetString("__sid")
|
||||
sid = "temporary-mock-sid-123"
|
||||
if sid == "" {
|
||||
c.JSON(400, gin.H{"message": "sid is required", "code": 400})
|
||||
c.Done()
|
||||
|
|
@ -372,6 +374,7 @@ func (agent *API) getSessionID(c *gin.Context) string {
|
|||
// handleChatLatest handles getting the latest chat
|
||||
func (agent *API) handleChatLatest(c *gin.Context) {
|
||||
sid := c.GetString("__sid")
|
||||
sid = "temporary-mock-sid-123"
|
||||
if sid == "" {
|
||||
c.JSON(400, gin.H{"message": "sid is required", "code": 400})
|
||||
c.Done()
|
||||
|
|
|
|||
|
|
@ -29,15 +29,15 @@ func (conv *Xun) UpdateChatTitle(sid string, cid string, title string) error {
|
|||
|
||||
// GetChat get the chat info and its history
|
||||
func (conv *Xun) GetChat(sid string, cid string, locale ...string) (*types.ChatInfo, error) {
|
||||
userID, err := conv.getUserID(sid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// userID, err := conv.getUserID(sid)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// Get chat info
|
||||
qb := conv.newQueryChat().
|
||||
Select("chat_id", "title", "assistant_id").
|
||||
Where("sid", userID).
|
||||
// Where("sid", userID).
|
||||
Where("chat_id", cid)
|
||||
|
||||
row, err := qb.First()
|
||||
|
|
@ -93,15 +93,15 @@ func (conv *Xun) GetChat(sid string, cid string, locale ...string) (*types.ChatI
|
|||
|
||||
// GetChatWithFilter get the chat info and its history with filter options
|
||||
func (conv *Xun) GetChatWithFilter(sid string, cid string, filter types.ChatFilter, locale ...string) (*types.ChatInfo, error) {
|
||||
userID, err := conv.getUserID(sid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// userID, err := conv.getUserID(sid)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// Get chat info
|
||||
qb := conv.newQueryChat().
|
||||
Select("chat_id", "title", "assistant_id").
|
||||
Where("sid", userID).
|
||||
// Where("sid", userID).
|
||||
Where("chat_id", cid)
|
||||
|
||||
row, err := qb.First()
|
||||
|
|
@ -209,10 +209,10 @@ func (conv *Xun) GetChats(sid string, filter types.ChatFilter, locale ...string)
|
|||
|
||||
// getChatsWithFilter get the chats with filter options
|
||||
func (conv *Xun) getChatsWithFilter(sid string, filter types.ChatFilter, locale ...string) (*types.ChatGroupResponse, error) {
|
||||
userID, err := conv.getUserID(sid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// userID, err := conv.getUserID(sid)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// Set default values
|
||||
if filter.Page <= 0 {
|
||||
|
|
@ -226,8 +226,8 @@ func (conv *Xun) getChatsWithFilter(sid string, filter types.ChatFilter, locale
|
|||
}
|
||||
|
||||
// Get total count
|
||||
qbCount := conv.newQueryChat().
|
||||
Where("sid", userID)
|
||||
qbCount := conv.newQueryChat()
|
||||
// Where("sid", userID)
|
||||
|
||||
// Apply silent filter if provided
|
||||
if filter.Silent != nil {
|
||||
|
|
@ -257,8 +257,8 @@ func (conv *Xun) getChatsWithFilter(sid string, filter types.ChatFilter, locale
|
|||
|
||||
// Get chats with pagination
|
||||
qb := conv.newQueryChat().
|
||||
Select("chat_id", "title", "assistant_id", "silent", "created_at", "updated_at").
|
||||
Where("sid", userID)
|
||||
Select("chat_id", "title", "assistant_id", "silent", "created_at", "updated_at")
|
||||
// Where("sid", userID)
|
||||
|
||||
// Apply silent filter if provided
|
||||
if filter.Silent != nil {
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ import (
|
|||
|
||||
// GetHistory get the history
|
||||
func (conv *Xun) GetHistory(sid string, cid string, locale ...string) ([]map[string]interface{}, error) {
|
||||
userID, err := conv.getUserID(sid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// userID, err := conv.getUserID(sid)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
qb := conv.newQuery().
|
||||
Select("role", "name", "content", "context", "assistant_id", "assistant_name", "assistant_avatar", "mentions", "uid", "silent", "created_at", "updated_at").
|
||||
Where("sid", userID).
|
||||
// Where("sid", userID).
|
||||
Where("cid", cid).
|
||||
OrderBy("id", "desc")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue