1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* For licensing terms, see /license.txt */ |
6
|
|
|
|
7
|
|
|
namespace Chamilo\CoreBundle\Entity; |
8
|
|
|
|
9
|
|
|
use Chamilo\CoreBundle\Repository\AiRequestsRepository; |
10
|
|
|
use DateTime; |
11
|
|
|
use DateTimeInterface; |
12
|
|
|
use Doctrine\ORM\Mapping as ORM; |
13
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
14
|
|
|
|
15
|
|
|
#[ORM\Table( |
16
|
|
|
name: 'ai_requests', |
17
|
|
|
indexes: [ |
18
|
|
|
new ORM\Index(columns: ['tool_name', 'tool_item_id'], name: 'idx_ai_requests_lookup'), |
19
|
|
|
] |
20
|
|
|
)] |
21
|
|
|
#[ORM\Entity(repositoryClass: AiRequestsRepository::class)] |
22
|
|
|
class AiRequests |
23
|
|
|
{ |
24
|
|
|
#[ORM\Id] |
25
|
|
|
#[ORM\GeneratedValue] |
26
|
|
|
#[ORM\Column(type: 'integer')] |
27
|
|
|
private ?int $id = null; |
28
|
|
|
|
29
|
|
|
#[Assert\NotBlank] |
30
|
|
|
#[ORM\Column(type: 'integer')] |
31
|
|
|
private int $userId; |
32
|
|
|
|
33
|
|
|
#[Assert\NotBlank] |
34
|
|
|
#[ORM\Column(type: 'string', length: 255)] |
35
|
|
|
private string $toolName; |
36
|
|
|
|
37
|
|
|
#[ORM\Column(type: 'bigint', nullable: true)] |
38
|
|
|
private ?int $toolItemId = null; |
39
|
|
|
|
40
|
|
|
#[Assert\NotBlank] |
41
|
|
|
#[ORM\Column(type: 'datetime')] |
42
|
|
|
private DateTimeInterface $requestedAt; |
43
|
|
|
|
44
|
|
|
#[Assert\NotBlank] |
45
|
|
|
#[ORM\Column(type: 'text')] |
46
|
|
|
private string $requestText; |
47
|
|
|
|
48
|
|
|
#[ORM\Column(type: 'integer', nullable: true)] |
49
|
|
|
private ?int $promptTokens = null; |
50
|
|
|
|
51
|
|
|
#[ORM\Column(type: 'integer', nullable: true)] |
52
|
|
|
private ?int $completionTokens = null; |
53
|
|
|
|
54
|
|
|
#[ORM\Column(type: 'integer', nullable: true)] |
55
|
|
|
private ?int $totalTokens = null; |
56
|
|
|
|
57
|
|
|
#[Assert\NotBlank] |
58
|
|
|
#[ORM\Column(type: 'string', length: 50)] |
59
|
|
|
private string $aiProvider; |
60
|
|
|
|
61
|
|
|
#[ORM\Column(type: 'string', length: 255, nullable: true)] |
62
|
|
|
private ?string $aiModel = null; |
63
|
|
|
|
64
|
|
|
#[ORM\Column(type: 'text', nullable: true)] |
65
|
|
|
private ?string $aiEndpoint = null; |
66
|
|
|
|
67
|
|
|
public function __construct() |
68
|
|
|
{ |
69
|
|
|
$this->requestedAt = new DateTime(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getId(): ?int |
73
|
|
|
{ |
74
|
|
|
return $this->id; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getUserId(): int |
78
|
|
|
{ |
79
|
|
|
return $this->userId; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function setUserId(int $userId): self |
83
|
|
|
{ |
84
|
|
|
$this->userId = $userId; |
85
|
|
|
|
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function getToolName(): string |
90
|
|
|
{ |
91
|
|
|
return $this->toolName; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function setToolName(string $toolName): self |
95
|
|
|
{ |
96
|
|
|
$this->toolName = $toolName; |
97
|
|
|
|
98
|
|
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public function getToolItemId(): ?int |
102
|
|
|
{ |
103
|
|
|
return $this->toolItemId; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function setToolItemId(?int $toolItemId): self |
107
|
|
|
{ |
108
|
|
|
$this->toolItemId = $toolItemId; |
109
|
|
|
|
110
|
|
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function getRequestedAt(): DateTimeInterface |
114
|
|
|
{ |
115
|
|
|
return $this->requestedAt; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function getRequestText(): string |
119
|
|
|
{ |
120
|
|
|
return $this->requestText; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function setRequestText(string $requestText): self |
124
|
|
|
{ |
125
|
|
|
$this->requestText = $requestText; |
126
|
|
|
|
127
|
|
|
return $this; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function getPromptTokens(): ?int |
131
|
|
|
{ |
132
|
|
|
return $this->promptTokens; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
public function setPromptTokens(?int $promptTokens): self |
136
|
|
|
{ |
137
|
|
|
$this->promptTokens = $promptTokens; |
138
|
|
|
|
139
|
|
|
return $this; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
public function getCompletionTokens(): ?int |
143
|
|
|
{ |
144
|
|
|
return $this->completionTokens; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
public function setCompletionTokens(?int $completionTokens): self |
148
|
|
|
{ |
149
|
|
|
$this->completionTokens = $completionTokens; |
150
|
|
|
|
151
|
|
|
return $this; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
public function getTotalTokens(): ?int |
155
|
|
|
{ |
156
|
|
|
return $this->totalTokens; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
public function setTotalTokens(?int $totalTokens): self |
160
|
|
|
{ |
161
|
|
|
$this->totalTokens = $totalTokens; |
162
|
|
|
|
163
|
|
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
public function getAiProvider(): string |
167
|
|
|
{ |
168
|
|
|
return $this->aiProvider; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
public function setAiProvider(string $aiProvider): self |
172
|
|
|
{ |
173
|
|
|
$this->aiProvider = $aiProvider; |
174
|
|
|
|
175
|
|
|
return $this; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
public function getAiModel(): ?string |
179
|
|
|
{ |
180
|
|
|
return $this->aiModel; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
public function setAiModel(?string $aiModel): self |
184
|
|
|
{ |
185
|
|
|
$this->aiModel = $aiModel; |
186
|
|
|
|
187
|
|
|
return $this; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
public function getAiEndpoint(): ?string |
191
|
|
|
{ |
192
|
|
|
return $this->aiEndpoint; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
public function setAiEndpoint(?string $aiEndpoint): self |
196
|
|
|
{ |
197
|
|
|
$this->aiEndpoint = $aiEndpoint; |
198
|
|
|
|
199
|
|
|
return $this; |
200
|
|
|
} |
201
|
|
|
} |
202
|
|
|
|