-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(AI Chat): Implement AI Chat item (#1741)
Co-authored-by: Jonathan Lim-Breitbart <[email protected]>
- Loading branch information
1 parent
65ebbea
commit 6348a59
Showing
88 changed files
with
1,578 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export function applyMixins(derivedCtor: any, constructors: any[]) { | ||
constructors.forEach((baseCtor) => { | ||
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => { | ||
Object.defineProperty( | ||
derivedCtor.prototype, | ||
name, | ||
Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || Object.create(null) | ||
); | ||
}); | ||
}); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/assets/wise5/common/chat-input/chat-input.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px"> | ||
<mat-form-field fxFlex class="form-field-no-label form-field-no-hint" appearance="fill"> | ||
<textarea | ||
matInput | ||
cdkTextareaAutosize | ||
placeholder="Add response..." | ||
i18n-placeholder | ||
[(ngModel)]="response" | ||
(keypress)="keyPressed($event)" | ||
></textarea> | ||
</mat-form-field> | ||
<button | ||
mat-flat-button | ||
color="primary" | ||
(click)="submit()" | ||
[disabled]="response.length === 0 || submitDisabled" | ||
i18n | ||
> | ||
Send | ||
</button> | ||
</div> |
Empty file.
21 changes: 21 additions & 0 deletions
21
src/assets/wise5/common/chat-input/chat-input.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { ChatInputComponent } from './chat-input.component'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
describe('ChatInputComponent', () => { | ||
let component: ChatInputComponent; | ||
let fixture: ComponentFixture<ChatInputComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [BrowserAnimationsModule, ChatInputComponent] | ||
}); | ||
fixture = TestBed.createComponent(ChatInputComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
33 changes: 33 additions & 0 deletions
33
src/assets/wise5/common/chat-input/chat-input.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { FlexLayoutModule } from '@angular/flex-layout'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatFormFieldModule } from '@angular/material/form-field'; | ||
import { MatInputModule } from '@angular/material/input'; | ||
|
||
@Component({ | ||
selector: 'chat-input', | ||
templateUrl: './chat-input.component.html', | ||
styleUrls: ['./chat-input.component.scss'], | ||
standalone: true, | ||
imports: [FormsModule, FlexLayoutModule, MatButtonModule, MatFormFieldModule, MatInputModule] | ||
}) | ||
export class ChatInputComponent { | ||
protected response: string = ''; | ||
@Input() submitDisabled: boolean = false; | ||
@Output() submitEvent: EventEmitter<string> = new EventEmitter<string>(); | ||
|
||
protected keyPressed(event: KeyboardEvent): void { | ||
if (event.key === 'Enter') { | ||
event.preventDefault(); | ||
if (this.response.length > 0 && !this.submitDisabled) { | ||
this.submit(); | ||
} | ||
} | ||
} | ||
|
||
protected submit(): void { | ||
this.submitEvent.emit(this.response); | ||
this.response = ''; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
src/assets/wise5/common/computer-avatar/computer-avatar-component-content.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { ComputerAvatarSettings } from './ComputerAvatarSettings'; | ||
|
||
export interface ComputerAvatarComponentContent { | ||
computerAvatarSettings: ComputerAvatarSettings; | ||
isComputerAvatarEnabled: boolean; | ||
} |
26 changes: 26 additions & 0 deletions
26
src/assets/wise5/common/computer-avatar/computer-avatar-component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ComputerAvatarComponentContent } from './computer-avatar-component-content'; | ||
|
||
export class ComputerAvatarComponent { | ||
content: ComputerAvatarComponentContent; | ||
|
||
isComputerAvatarEnabled(): boolean { | ||
return this.content.isComputerAvatarEnabled; | ||
} | ||
|
||
isComputerAvatarPromptAvailable(): boolean { | ||
const computerAvatarPrompt = this.content.computerAvatarSettings.prompt; | ||
return computerAvatarPrompt != null && computerAvatarPrompt !== ''; | ||
} | ||
|
||
isOnlyOneComputerAvatarAvailable(): boolean { | ||
return this.content.computerAvatarSettings.ids.length === 1; | ||
} | ||
|
||
isUseGlobalComputerAvatar(): boolean { | ||
return this.content.computerAvatarSettings.useGlobalComputerAvatar; | ||
} | ||
|
||
getComputerAvatarInitialResponse(): string { | ||
return this.content.computerAvatarSettings.initialResponse; | ||
} | ||
} |
Oops, something went wrong.