-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsilverback_ai.install
127 lines (121 loc) · 3.44 KB
/
silverback_ai.install
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* @file
* Install, update and uninstall functions for the Silverback AI module.
*/
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Language\LanguageInterface;
/**
* Implements hook_schema().
*/
function silverback_ai_schema() {
$db_schema = \Drupal::database()->schema();
if ($db_schema->tableExists('silverback_ai_usage')) {
$db_schema->dropTable('silverback_ai_usage');
}
$schema['silverback_ai_usage'] = [
'description' => 'Usage for the Silverback AI module.',
'fields' => [
'id' => [
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key.',
],
'uid' => [
'description' => 'Foreign key to {users}.uid; uniquely identifies a Drupal user executed the ai fetch action.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
],
'timestamp' => [
'description' => 'Date/time when the form submission failed, as Unix timestamp.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
],
'langcode' => [
'description' => 'The language of this request.',
'type' => 'varchar_ascii',
'length' => 12,
'not null' => TRUE,
'default' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
],
'target_entity_type_id' => [
'type' => 'varchar_ascii',
'length' => EntityTypeInterface::ID_MAX_LENGTH,
'not null' => FALSE,
'default' => '',
'description' => 'The ID of the associated entity type.',
],
'target_entity_id' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'description' => 'The ID of the associated entity.',
],
'target_entity_revision_id' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'description' => 'The revision ID of the associated entity.',
],
'tokens_in' => [
'description' => 'The total number of input tokens.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'big',
],
'tokens_out' => [
'description' => 'The total number of output tokens.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'big',
],
'total_count' => [
'description' => 'The total number of tokens used.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'big',
],
'provider' => [
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'The AI provider.',
],
'model' => [
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'The model used.',
],
'module' => [
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'The module used.',
],
'response' => [
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'description' => 'The response from the AI provider.',
],
],
'primary key' => ['id'],
'indexes' => [
'uid' => ['uid'],
'timestamp' => ['timestamp'],
],
];
return $schema;
}