Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: get username in chat #991

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions apiserver/service/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ func (cs *ChatService) ListConversationHandler() gin.HandlerFunc {
req := chat.APPMetadata{}
_ = c.ShouldBindJSON(&req)
req.AppNamespace = NamespaceInHeader(c)
resp, err := cs.server.ListConversations(c, req)
resp, err := cs.server.ListConversations(c.Request.Context(), req)
if err != nil {
klog.FromContext(c.Request.Context()).Error(err, "error list conversation")
c.JSON(http.StatusInternalServerError, chat.ErrorResp{Err: err.Error()})
return
}
if err := cs.server.FillAppIconToConversations(c, &resp); err != nil {
if err := cs.server.FillAppIconToConversations(c.Request.Context(), &resp); err != nil {
// note: fill app icon is try our best, don't need to return error
klog.FromContext(c.Request.Context()).Error(err, "error fill app icon to conversations")
}
Expand Down Expand Up @@ -309,7 +309,7 @@ func (cs *ChatService) DeleteConversationHandler() gin.HandlerFunc {
c.JSON(http.StatusBadRequest, chat.ErrorResp{Err: err.Error()})
return
}
err := cs.server.DeleteConversation(c, conversationID)
err := cs.server.DeleteConversation(c.Request.Context(), conversationID)
if err != nil {
klog.FromContext(c.Request.Context()).Error(err, "error delete conversation")
c.JSON(http.StatusInternalServerError, chat.ErrorResp{Err: err.Error()})
Expand Down Expand Up @@ -341,7 +341,7 @@ func (cs *ChatService) HistoryHandler() gin.HandlerFunc {
return
}
req.AppNamespace = NamespaceInHeader(c)
resp, err := cs.server.ListMessages(c, req)
resp, err := cs.server.ListMessages(c.Request.Context(), req)
if err != nil {
klog.FromContext(c.Request.Context()).Error(err, "error list messages")
c.JSON(http.StatusInternalServerError, chat.ErrorResp{Err: err.Error()})
Expand Down Expand Up @@ -383,7 +383,7 @@ func (cs *ChatService) ReferenceHandler() gin.HandlerFunc {
c.JSON(http.StatusBadRequest, chat.ErrorResp{Err: err.Error()})
return
}
resp, err := cs.server.GetMessageReferences(c, req)
resp, err := cs.server.GetMessageReferences(c.Request.Context(), req)
if err != nil {
klog.FromContext(c.Request.Context()).Error(err, "error get message references")
c.JSON(http.StatusInternalServerError, chat.ErrorResp{Err: err.Error()})
Expand Down
6 changes: 3 additions & 3 deletions apiserver/service/minio_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ func (m *minioAPI) CreateWebCrawlerFile(ctx *gin.Context) {
namespace := NamespaceInHeader(ctx)

// read versioneddataset
vds, err := versioneddataset.GetVersionedDataset(ctx, m.client, body.VersionedDataset, namespace)
vds, err := versioneddataset.GetVersionedDataset(ctx.Request.Context(), m.client, body.VersionedDataset, namespace)
if err != nil {
klog.Errorf("failed to get versioneddataset error %s", err)
ctx.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{
Expand All @@ -843,7 +843,7 @@ func (m *minioAPI) CreateWebCrawlerFile(ctx *gin.Context) {
return
}
// read datasource
ds, err := apiserverds.ReadDatasource(ctx, m.client, body.Datasource, namespace)
ds, err := apiserverds.ReadDatasource(ctx.Request.Context(), m.client, body.Datasource, namespace)
if err != nil {
klog.Errorf("failed to get datasource error %s", err)
ctx.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{
Expand Down Expand Up @@ -882,7 +882,7 @@ func (m *minioAPI) CreateWebCrawlerFile(ctx *gin.Context) {
}

object := fmt.Sprintf("dataset/%s/%s/%s-%s.web", vds.Dataset.Name, vds.Version, ds.Namespace, ds.Name)
_, err = source.Client.PutObject(ctx, namespace, object, bytes.NewReader(content), int64(len(content)), minio.PutObjectOptions{})
_, err = source.Client.PutObject(ctx.Request.Context(), namespace, object, bytes.NewReader(content), int64(len(content)), minio.PutObjectOptions{})
if err != nil {
klog.Errorf("failed to put webcrawler file error %s", err)
ctx.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{
Expand Down
6 changes: 3 additions & 3 deletions apiserver/service/rag_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (r *RagAPI) Summary(ctx *gin.Context) {
namespace := NamespaceInHeader(ctx)

rr := v1alpha1.RAG{}
if err := r.c.Get(ctx, types.NamespacedName{
if err := r.c.Get(ctx.Request.Context(), types.NamespacedName{
Namespace: namespace, Name: ragName,
}, &rr); err != nil {
klog.Error(fmt.Sprintf("can't get rag by name %s", ragName))
Expand Down Expand Up @@ -109,7 +109,7 @@ func (r *RagAPI) ReportDetail(ctx *gin.Context) {
namespace := NamespaceInHeader(ctx)

rr := v1alpha1.RAG{}
if err := r.c.Get(ctx, types.NamespacedName{
if err := r.c.Get(ctx.Request.Context(), types.NamespacedName{
Namespace: namespace, Name: ragName,
}, &rr); err != nil {
klog.Error(fmt.Sprintf("can't get rag by name %s", ragName))
Expand Down Expand Up @@ -145,7 +145,7 @@ func (r *RagAPI) ReportScatter(ctx *gin.Context) {
namespace := NamespaceInHeader(ctx)

rr := v1alpha1.RAG{}
if err := r.c.Get(ctx, types.NamespacedName{
if err := r.c.Get(ctx.Request.Context(), types.NamespacedName{
Namespace: namespace, Name: ragName,
}, &rr); err != nil {
klog.Error(fmt.Sprintf("can't get rag by name %s", ragName))
Expand Down
Loading