forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom-input.component.ts
More file actions
68 lines (64 loc) · 1.55 KB
/
Copy pathcustom-input.component.ts
File metadata and controls
68 lines (64 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { Component, Input } from "@angular/core";
import { CommonModule } from "@angular/common";
import { FormsModule } from "@angular/forms";
import { ChatState } from "@copilotkit/angular";
@Component({
selector: "custom-input",
standalone: true,
imports: [CommonModule, FormsModule],
template: `
<div
[class]="inputClass"
style="
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
padding: 20px;
border-radius: 15px;
margin: 10px;
"
>
<input
type="text"
[(ngModel)]="inputValue"
placeholder="💬 Ask me anything..."
style="
width: 100%;
padding: 15px;
border: 2px solid white;
border-radius: 10px;
font-size: 16px;
background: rgba(255, 255, 255, 0.9);
color: #333;
outline: none;
"
(keyup.enter)="handleSend()"
/>
<button
style="
margin-top: 10px;
padding: 10px 20px;
background: white;
color: #f5576c;
border: none;
border-radius: 5px;
font-weight: bold;
cursor: pointer;
"
(click)="handleSend()"
>
Send Message ✨
</button>
</div>
`,
})
export class CustomInputComponent {
@Input() inputClass?: string;
inputValue = "";
constructor(private chat: ChatState) {}
handleSend() {
const value = this.inputValue.trim();
if (value) {
this.chat.submitInput(value);
this.inputValue = "";
}
}
}