Skip to content

Commit

Permalink
CWC
Browse files Browse the repository at this point in the history
Streaming fix
  • Loading branch information
ppiliaev committed Nov 17, 2023
1 parent 71de949 commit 110afe6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/codewhispererChat/clients/chat/v0/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export class ChatSession {
this.tokenSource = new vscode.CancellationTokenSource()
}

public setSessionID(id?: string){
this.sessionId = id
}

async chat(chatRequest: GenerateAssistantResponseRequest): Promise<GenerateAssistantResponseCommandOutput> {
this.client = await new CodeWhispererStreamingClient().createSdkClient()

Expand All @@ -43,15 +47,6 @@ export class ChatSession {
)
}

// read the first event to get conversation id.
// this assumes that the metadataEvent is the first event in the response stream.
for await (const event of response.generateAssistantResponseResponse) {
if (event.messageMetadataEvent !== undefined) {
this.sessionId = event.messageMetadataEvent!.conversationId
}
break
}

return response
}
}
4 changes: 4 additions & 0 deletions src/codewhispererChat/controllers/chat/messenger/messenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export class Messenger {
}
}

if (chatEvent.messageMetadataEvent !== undefined) {
session.setSessionID(chatEvent.messageMetadataEvent!.conversationId)
}

if (session.tokenSource.token.isCancellationRequested) {
return true
}
Expand Down

0 comments on commit 110afe6

Please sign in to comment.