@@ -56,19 +56,21 @@ type ChatServer struct {
56
56
cli runtimeclient.Client
57
57
storage storage.Storage
58
58
once sync.Once
59
+ isGpts bool
59
60
}
60
61
61
- func NewChatServer (cli runtimeclient.Client ) * ChatServer {
62
+ func NewChatServer (cli runtimeclient.Client , isGpts bool ) * ChatServer {
62
63
return & ChatServer {
63
- cli : cli ,
64
+ cli : cli ,
65
+ isGpts : isGpts ,
64
66
}
65
67
}
66
68
67
69
func (cs * ChatServer ) Storage () storage.Storage {
68
70
if cs .storage == nil {
69
71
cs .once .Do (func () {
70
72
ctx := context .TODO ()
71
- ds , err := pkgconfig .GetRelationalDatasource (ctx , cs . cli )
73
+ ds , err := pkgconfig .GetRelationalDatasource (ctx )
72
74
if err != nil || ds == nil {
73
75
if err != nil {
74
76
klog .Infof ("get relational datasource failed: %s, use memory storage for chat" , err .Error ())
@@ -183,7 +185,7 @@ func (cs *ChatServer) AppRun(ctx context.Context, req ChatReqBody, respStream ch
183
185
184
186
func (cs * ChatServer ) ListConversations (ctx context.Context , req APPMetadata ) ([]storage.Conversation , error ) {
185
187
currentUser , _ := ctx .Value (auth .UserNameContextKey ).(string )
186
- return cs .Storage ().ListConversations (storage .WithAppNamespace (req .AppNamespace ), storage .WithAppName (req .APPName ), storage .WithUser (currentUser ), storage . WithUser ( currentUser ) )
188
+ return cs .Storage ().ListConversations (storage .WithAppNamespace (req .AppNamespace ), storage .WithAppName (req .APPName ), storage .WithUser (currentUser ))
187
189
}
188
190
189
191
func (cs * ChatServer ) DeleteConversation (ctx context.Context , conversationID string ) error {
@@ -390,7 +392,13 @@ The question you asked is:`
390
392
391
393
func (cs * ChatServer ) GetApp (ctx context.Context , appName , appNamespace string ) (* v1alpha1.Application , runtimeclient.Client , error ) {
392
394
token := auth .ForOIDCToken (ctx )
393
- c , err := client .GetClient (token )
395
+ var c runtimeclient.Client
396
+ var err error
397
+ if ! cs .isGpts {
398
+ c , err = client .GetClient (token )
399
+ } else {
400
+ c = cs .cli
401
+ }
394
402
if err != nil {
395
403
return nil , nil , fmt .Errorf ("failed to get a client: %w" , err )
396
404
}
0 commit comments