datamule 0.380__py3-none-any.whl → 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- datamule/__init__.py +46 -86
- datamule/book.py +16 -0
- datamule/config.py +29 -0
- datamule/data/company_former_names.csv +8148 -8148
- datamule/data/company_metadata.csv +10049 -10049
- datamule/data/company_tickers.csv +9999 -10168
- datamule/data/sec-glossary.csv +728 -728
- datamule/data/xbrl_descriptions.csv +10024 -10024
- datamule/document.py +278 -0
- datamule/downloader/downloader.py +374 -0
- datamule/downloader/premiumdownloader.py +335 -0
- datamule/helper.py +123 -136
- datamule/mapping_dicts/txt_mapping_dicts.py +232 -0
- datamule/mapping_dicts/xml_mapping_dicts.py +19 -0
- datamule/monitor.py +238 -0
- datamule/mulebot/__init__.py +1 -1
- datamule/mulebot/helper.py +34 -34
- datamule/mulebot/mulebot.py +129 -129
- datamule/mulebot/mulebot_server/server.py +86 -86
- datamule/mulebot/mulebot_server/static/css/minimalist.css +173 -173
- datamule/mulebot/mulebot_server/static/scripts/artifacts.js +67 -67
- datamule/mulebot/mulebot_server/static/scripts/chat.js +91 -91
- datamule/mulebot/mulebot_server/static/scripts/filingArtifacts.js +55 -55
- datamule/mulebot/mulebot_server/static/scripts/listArtifacts.js +14 -14
- datamule/mulebot/mulebot_server/static/scripts/main.js +56 -56
- datamule/mulebot/mulebot_server/static/scripts/prefilledPrompt.js +26 -26
- datamule/mulebot/mulebot_server/static/scripts/suggestions.js +46 -46
- datamule/mulebot/mulebot_server/static/scripts/tableArtifacts.js +128 -128
- datamule/mulebot/mulebot_server/static/scripts/utils.js +27 -27
- datamule/mulebot/mulebot_server/templates/chat-minimalist.html +90 -90
- datamule/mulebot/search.py +51 -51
- datamule/mulebot/tools.py +82 -82
- datamule/packageupdater.py +207 -0
- datamule/portfolio.py +106 -0
- datamule/submission.py +76 -0
- datamule-1.0.0.dist-info/METADATA +27 -0
- datamule-1.0.0.dist-info/RECORD +40 -0
- {datamule-0.380.dist-info → datamule-1.0.0.dist-info}/WHEEL +1 -1
- datamule/data/filing_types.csv +0 -485
- datamule/data/ftd_locations.csv +0 -388
- datamule/datamule_api.py +0 -21
- datamule/dataset_builder/_init.py +0 -1
- datamule/dataset_builder/dataset_builder.py +0 -260
- datamule/downloader/__init__.py +0 -0
- datamule/downloader/dropbox_downloader.py +0 -225
- datamule/downloader/ftd.py +0 -216
- datamule/downloader/information_table_13f.py +0 -231
- datamule/downloader/sec_downloader.py +0 -635
- datamule/filing_viewer/__init__.py +0 -1
- datamule/filing_viewer/filing_viewer.py +0 -256
- datamule/global_vars.py +0 -202
- datamule/parser/__init__.py +0 -1
- datamule/parser/basic_10k_parser.py +0 -82
- datamule/parser/basic_10q_parser.py +0 -73
- datamule/parser/basic_13d_parser.py +0 -58
- datamule/parser/basic_13g_parser.py +0 -61
- datamule/parser/basic_8k_parser.py +0 -84
- datamule/parser/company_concepts_parser.py +0 -0
- datamule/parser/form_d_parser.py +0 -70
- datamule/parser/generalized_item_parser.py +0 -78
- datamule/parser/generalized_xml_parser.py +0 -0
- datamule/parser/helper.py +0 -75
- datamule/parser/information_table_parser_13fhr.py +0 -41
- datamule/parser/insider_trading_parser.py +0 -158
- datamule/parser/mappings.py +0 -95
- datamule/parser/n_port_p_parser.py +0 -70
- datamule/parser/sec_parser.py +0 -79
- datamule/parser/sgml_parser.py +0 -180
- datamule/sec_filing.py +0 -126
- datamule/sec_search.py +0 -20
- datamule-0.380.dist-info/METADATA +0 -110
- datamule-0.380.dist-info/RECORD +0 -61
- {datamule-0.380.dist-info → datamule-1.0.0.dist-info}/top_level.txt +0 -0
@@ -1,174 +1,174 @@
|
|
1
|
-
/* Global Styles */
|
2
|
-
body {
|
3
|
-
background-color: #f8f9fa;
|
4
|
-
color: #343a40;
|
5
|
-
}
|
6
|
-
|
7
|
-
/* Cards */
|
8
|
-
.card {
|
9
|
-
border: none;
|
10
|
-
box-shadow: 0 4px 6px rgba(0, 0, 0, .1);
|
11
|
-
}
|
12
|
-
|
13
|
-
/* Buttons */
|
14
|
-
.btn-primary {
|
15
|
-
background-color: #6c757d;
|
16
|
-
border-color: #6c757d;
|
17
|
-
}
|
18
|
-
|
19
|
-
.btn-primary:hover {
|
20
|
-
background-color: #5a6268;
|
21
|
-
border-color: #545b62;
|
22
|
-
}
|
23
|
-
|
24
|
-
.btn-primary:disabled {
|
25
|
-
background-color: #6c757d;
|
26
|
-
border-color: #6c757d;
|
27
|
-
opacity: 0.65;
|
28
|
-
}
|
29
|
-
|
30
|
-
/* Social Buttons */
|
31
|
-
.social-btn {
|
32
|
-
display: inline-flex;
|
33
|
-
align-items: center;
|
34
|
-
justify-content: center;
|
35
|
-
width: auto;
|
36
|
-
height: 36px;
|
37
|
-
border-radius: 6px;
|
38
|
-
margin: 0 5px;
|
39
|
-
padding: 0 12px;
|
40
|
-
background-color: #f8f9fa;
|
41
|
-
border: 1px solid #6c757d;
|
42
|
-
color: #6c757d;
|
43
|
-
font-size: 14px;
|
44
|
-
text-decoration: none;
|
45
|
-
transition: all 0.3s ease;
|
46
|
-
}
|
47
|
-
|
48
|
-
.social-btn:hover {
|
49
|
-
background-color: #6c757d;
|
50
|
-
color: #ffffff;
|
51
|
-
transform: translateY(-2px);
|
52
|
-
}
|
53
|
-
|
54
|
-
.social-btn:hover svg {
|
55
|
-
fill: #ffffff;
|
56
|
-
}
|
57
|
-
|
58
|
-
.social-btn svg {
|
59
|
-
width: 18px;
|
60
|
-
height: 18px;
|
61
|
-
fill: #6c757d;
|
62
|
-
margin-right: 6px;
|
63
|
-
transition: fill 0.3s ease;
|
64
|
-
}
|
65
|
-
|
66
|
-
/* Chat container */
|
67
|
-
#chat-outer-container {
|
68
|
-
position: relative;
|
69
|
-
height: 400px;
|
70
|
-
overflow: hidden;
|
71
|
-
}
|
72
|
-
|
73
|
-
#chat-container {
|
74
|
-
height: 100%;
|
75
|
-
overflow-y: auto;
|
76
|
-
padding-bottom: 40px;
|
77
|
-
/* Make room for the thinking indicator */
|
78
|
-
}
|
79
|
-
|
80
|
-
/* Artifact container */
|
81
|
-
#artifact-container {
|
82
|
-
max-height: 400px;
|
83
|
-
overflow-y: auto;
|
84
|
-
}
|
85
|
-
|
86
|
-
/* Suggestion Box */
|
87
|
-
.suggestion-box {
|
88
|
-
background-color: #f8f9fa;
|
89
|
-
border-radius: 10px;
|
90
|
-
padding: 15px;
|
91
|
-
margin-top: 20px;
|
92
|
-
}
|
93
|
-
|
94
|
-
.suggestion-item {
|
95
|
-
background-color: white;
|
96
|
-
border-radius: 8px;
|
97
|
-
padding: 8px 12px;
|
98
|
-
margin-bottom: 10px;
|
99
|
-
cursor: pointer;
|
100
|
-
transition: background-color 0.3s;
|
101
|
-
}
|
102
|
-
|
103
|
-
.suggestion-item:hover {
|
104
|
-
background-color: #f0f0f0;
|
105
|
-
}
|
106
|
-
|
107
|
-
/* Autocomplete */
|
108
|
-
.select-wrapper {
|
109
|
-
position: relative;
|
110
|
-
}
|
111
|
-
|
112
|
-
.autocomplete-items {
|
113
|
-
position: absolute;
|
114
|
-
border: 1px solid #d4d4d4;
|
115
|
-
border-top: none;
|
116
|
-
z-index: 99;
|
117
|
-
top: 100%;
|
118
|
-
left: 0;
|
119
|
-
right: 0;
|
120
|
-
max-height: 200px;
|
121
|
-
overflow-y: auto;
|
122
|
-
background-color: #fff;
|
123
|
-
}
|
124
|
-
|
125
|
-
.autocomplete-items div {
|
126
|
-
padding: 10px;
|
127
|
-
cursor: pointer;
|
128
|
-
background-color: #fff;
|
129
|
-
border-bottom: 1px solid #d4d4d4;
|
130
|
-
}
|
131
|
-
|
132
|
-
.autocomplete-items div:hover {
|
133
|
-
background-color: #e9e9e9;
|
134
|
-
}
|
135
|
-
|
136
|
-
.autocomplete-active {
|
137
|
-
background-color: DodgerBlue !important;
|
138
|
-
color: #ffffff;
|
139
|
-
}
|
140
|
-
|
141
|
-
/* Thinking Indicator */
|
142
|
-
.thinking-indicator {
|
143
|
-
position: absolute;
|
144
|
-
bottom: 0;
|
145
|
-
left: 0;
|
146
|
-
right: 0;
|
147
|
-
padding: 10px;
|
148
|
-
background-color: #f0f0f0;
|
149
|
-
border-radius: 5px 5px 0 0;
|
150
|
-
display: none;
|
151
|
-
z-index: 1000;
|
152
|
-
box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
|
153
|
-
}
|
154
|
-
|
155
|
-
.dot-animation {
|
156
|
-
display: inline-block;
|
157
|
-
width: 20px;
|
158
|
-
text-align: left;
|
159
|
-
animation: dotAnimation 1.5s infinite;
|
160
|
-
}
|
161
|
-
|
162
|
-
@keyframes dotAnimation {
|
163
|
-
0% {
|
164
|
-
content: '.';
|
165
|
-
}
|
166
|
-
|
167
|
-
33% {
|
168
|
-
content: '..';
|
169
|
-
}
|
170
|
-
|
171
|
-
66% {
|
172
|
-
content: '...';
|
173
|
-
}
|
1
|
+
/* Global Styles */
|
2
|
+
body {
|
3
|
+
background-color: #f8f9fa;
|
4
|
+
color: #343a40;
|
5
|
+
}
|
6
|
+
|
7
|
+
/* Cards */
|
8
|
+
.card {
|
9
|
+
border: none;
|
10
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, .1);
|
11
|
+
}
|
12
|
+
|
13
|
+
/* Buttons */
|
14
|
+
.btn-primary {
|
15
|
+
background-color: #6c757d;
|
16
|
+
border-color: #6c757d;
|
17
|
+
}
|
18
|
+
|
19
|
+
.btn-primary:hover {
|
20
|
+
background-color: #5a6268;
|
21
|
+
border-color: #545b62;
|
22
|
+
}
|
23
|
+
|
24
|
+
.btn-primary:disabled {
|
25
|
+
background-color: #6c757d;
|
26
|
+
border-color: #6c757d;
|
27
|
+
opacity: 0.65;
|
28
|
+
}
|
29
|
+
|
30
|
+
/* Social Buttons */
|
31
|
+
.social-btn {
|
32
|
+
display: inline-flex;
|
33
|
+
align-items: center;
|
34
|
+
justify-content: center;
|
35
|
+
width: auto;
|
36
|
+
height: 36px;
|
37
|
+
border-radius: 6px;
|
38
|
+
margin: 0 5px;
|
39
|
+
padding: 0 12px;
|
40
|
+
background-color: #f8f9fa;
|
41
|
+
border: 1px solid #6c757d;
|
42
|
+
color: #6c757d;
|
43
|
+
font-size: 14px;
|
44
|
+
text-decoration: none;
|
45
|
+
transition: all 0.3s ease;
|
46
|
+
}
|
47
|
+
|
48
|
+
.social-btn:hover {
|
49
|
+
background-color: #6c757d;
|
50
|
+
color: #ffffff;
|
51
|
+
transform: translateY(-2px);
|
52
|
+
}
|
53
|
+
|
54
|
+
.social-btn:hover svg {
|
55
|
+
fill: #ffffff;
|
56
|
+
}
|
57
|
+
|
58
|
+
.social-btn svg {
|
59
|
+
width: 18px;
|
60
|
+
height: 18px;
|
61
|
+
fill: #6c757d;
|
62
|
+
margin-right: 6px;
|
63
|
+
transition: fill 0.3s ease;
|
64
|
+
}
|
65
|
+
|
66
|
+
/* Chat container */
|
67
|
+
#chat-outer-container {
|
68
|
+
position: relative;
|
69
|
+
height: 400px;
|
70
|
+
overflow: hidden;
|
71
|
+
}
|
72
|
+
|
73
|
+
#chat-container {
|
74
|
+
height: 100%;
|
75
|
+
overflow-y: auto;
|
76
|
+
padding-bottom: 40px;
|
77
|
+
/* Make room for the thinking indicator */
|
78
|
+
}
|
79
|
+
|
80
|
+
/* Artifact container */
|
81
|
+
#artifact-container {
|
82
|
+
max-height: 400px;
|
83
|
+
overflow-y: auto;
|
84
|
+
}
|
85
|
+
|
86
|
+
/* Suggestion Box */
|
87
|
+
.suggestion-box {
|
88
|
+
background-color: #f8f9fa;
|
89
|
+
border-radius: 10px;
|
90
|
+
padding: 15px;
|
91
|
+
margin-top: 20px;
|
92
|
+
}
|
93
|
+
|
94
|
+
.suggestion-item {
|
95
|
+
background-color: white;
|
96
|
+
border-radius: 8px;
|
97
|
+
padding: 8px 12px;
|
98
|
+
margin-bottom: 10px;
|
99
|
+
cursor: pointer;
|
100
|
+
transition: background-color 0.3s;
|
101
|
+
}
|
102
|
+
|
103
|
+
.suggestion-item:hover {
|
104
|
+
background-color: #f0f0f0;
|
105
|
+
}
|
106
|
+
|
107
|
+
/* Autocomplete */
|
108
|
+
.select-wrapper {
|
109
|
+
position: relative;
|
110
|
+
}
|
111
|
+
|
112
|
+
.autocomplete-items {
|
113
|
+
position: absolute;
|
114
|
+
border: 1px solid #d4d4d4;
|
115
|
+
border-top: none;
|
116
|
+
z-index: 99;
|
117
|
+
top: 100%;
|
118
|
+
left: 0;
|
119
|
+
right: 0;
|
120
|
+
max-height: 200px;
|
121
|
+
overflow-y: auto;
|
122
|
+
background-color: #fff;
|
123
|
+
}
|
124
|
+
|
125
|
+
.autocomplete-items div {
|
126
|
+
padding: 10px;
|
127
|
+
cursor: pointer;
|
128
|
+
background-color: #fff;
|
129
|
+
border-bottom: 1px solid #d4d4d4;
|
130
|
+
}
|
131
|
+
|
132
|
+
.autocomplete-items div:hover {
|
133
|
+
background-color: #e9e9e9;
|
134
|
+
}
|
135
|
+
|
136
|
+
.autocomplete-active {
|
137
|
+
background-color: DodgerBlue !important;
|
138
|
+
color: #ffffff;
|
139
|
+
}
|
140
|
+
|
141
|
+
/* Thinking Indicator */
|
142
|
+
.thinking-indicator {
|
143
|
+
position: absolute;
|
144
|
+
bottom: 0;
|
145
|
+
left: 0;
|
146
|
+
right: 0;
|
147
|
+
padding: 10px;
|
148
|
+
background-color: #f0f0f0;
|
149
|
+
border-radius: 5px 5px 0 0;
|
150
|
+
display: none;
|
151
|
+
z-index: 1000;
|
152
|
+
box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
|
153
|
+
}
|
154
|
+
|
155
|
+
.dot-animation {
|
156
|
+
display: inline-block;
|
157
|
+
width: 20px;
|
158
|
+
text-align: left;
|
159
|
+
animation: dotAnimation 1.5s infinite;
|
160
|
+
}
|
161
|
+
|
162
|
+
@keyframes dotAnimation {
|
163
|
+
0% {
|
164
|
+
content: '.';
|
165
|
+
}
|
166
|
+
|
167
|
+
33% {
|
168
|
+
content: '..';
|
169
|
+
}
|
170
|
+
|
171
|
+
66% {
|
172
|
+
content: '...';
|
173
|
+
}
|
174
174
|
}
|
@@ -1,68 +1,68 @@
|
|
1
|
-
// artifacts.js
|
2
|
-
import { renderTableArtifact } from './tableArtifacts.js';
|
3
|
-
import { renderListArtifact } from './listArtifacts.js';
|
4
|
-
import { renderFilingArtifact } from './filingArtifacts.js';
|
5
|
-
|
6
|
-
export let artifactContent = null;
|
7
|
-
export let artifactContainer = null;
|
8
|
-
export let suggestionContainer = null;
|
9
|
-
export let toggleArtifactsBtn = null;
|
10
|
-
export let allArtifacts = [];
|
11
|
-
|
12
|
-
export function initializeArtifacts() {
|
13
|
-
artifactContent = document.getElementById('artifact-content');
|
14
|
-
artifactContainer = document.getElementById('artifact-container');
|
15
|
-
suggestionContainer = document.querySelector('.suggestion-box');
|
16
|
-
toggleArtifactsBtn = document.getElementById('toggle-artifacts');
|
17
|
-
|
18
|
-
if (toggleArtifactsBtn) {
|
19
|
-
toggleArtifactsBtn.addEventListener('click', toggleArtifacts);
|
20
|
-
}
|
21
|
-
|
22
|
-
// Initially hide artifacts
|
23
|
-
hideArtifacts();
|
24
|
-
}
|
25
|
-
|
26
|
-
export function renderArtifact(artifactData, artifactType) {
|
27
|
-
if (artifactType === 'artifact-table') {
|
28
|
-
const newArtifacts = Array.isArray(artifactData) ? artifactData : [artifactData];
|
29
|
-
newArtifacts.forEach(artifact => {
|
30
|
-
artifact.type = artifactType;
|
31
|
-
});
|
32
|
-
allArtifacts = [...allArtifacts, ...newArtifacts];
|
33
|
-
renderTableArtifact(artifactData[0]);
|
34
|
-
}
|
35
|
-
else if (artifactType === 'artifact-list') {
|
36
|
-
renderListArtifact(artifactData);
|
37
|
-
}
|
38
|
-
else if (artifactType === 'artifact-filing') {
|
39
|
-
renderFilingArtifact(artifactData);
|
40
|
-
}
|
41
|
-
else {
|
42
|
-
console.log('Unsupported artifact type:', artifactType);
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
export function showArtifacts() {
|
47
|
-
if (artifactContainer && suggestionContainer) {
|
48
|
-
artifactContainer.style.display = 'block';
|
49
|
-
suggestionContainer.style.display = 'none';
|
50
|
-
if (toggleArtifactsBtn) toggleArtifactsBtn.textContent = 'Hide Artifacts';
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
export function hideArtifacts() {
|
55
|
-
if (artifactContainer && suggestionContainer) {
|
56
|
-
artifactContainer.style.display = 'none';
|
57
|
-
suggestionContainer.style.display = 'block';
|
58
|
-
if (toggleArtifactsBtn) toggleArtifactsBtn.textContent = 'Show Artifacts';
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
function toggleArtifacts() {
|
63
|
-
if (artifactContainer.style.display === 'none') {
|
64
|
-
showArtifacts();
|
65
|
-
} else {
|
66
|
-
hideArtifacts();
|
67
|
-
}
|
1
|
+
// artifacts.js
|
2
|
+
import { renderTableArtifact } from './tableArtifacts.js';
|
3
|
+
import { renderListArtifact } from './listArtifacts.js';
|
4
|
+
import { renderFilingArtifact } from './filingArtifacts.js';
|
5
|
+
|
6
|
+
export let artifactContent = null;
|
7
|
+
export let artifactContainer = null;
|
8
|
+
export let suggestionContainer = null;
|
9
|
+
export let toggleArtifactsBtn = null;
|
10
|
+
export let allArtifacts = [];
|
11
|
+
|
12
|
+
export function initializeArtifacts() {
|
13
|
+
artifactContent = document.getElementById('artifact-content');
|
14
|
+
artifactContainer = document.getElementById('artifact-container');
|
15
|
+
suggestionContainer = document.querySelector('.suggestion-box');
|
16
|
+
toggleArtifactsBtn = document.getElementById('toggle-artifacts');
|
17
|
+
|
18
|
+
if (toggleArtifactsBtn) {
|
19
|
+
toggleArtifactsBtn.addEventListener('click', toggleArtifacts);
|
20
|
+
}
|
21
|
+
|
22
|
+
// Initially hide artifacts
|
23
|
+
hideArtifacts();
|
24
|
+
}
|
25
|
+
|
26
|
+
export function renderArtifact(artifactData, artifactType) {
|
27
|
+
if (artifactType === 'artifact-table') {
|
28
|
+
const newArtifacts = Array.isArray(artifactData) ? artifactData : [artifactData];
|
29
|
+
newArtifacts.forEach(artifact => {
|
30
|
+
artifact.type = artifactType;
|
31
|
+
});
|
32
|
+
allArtifacts = [...allArtifacts, ...newArtifacts];
|
33
|
+
renderTableArtifact(artifactData[0]);
|
34
|
+
}
|
35
|
+
else if (artifactType === 'artifact-list') {
|
36
|
+
renderListArtifact(artifactData);
|
37
|
+
}
|
38
|
+
else if (artifactType === 'artifact-filing') {
|
39
|
+
renderFilingArtifact(artifactData);
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
console.log('Unsupported artifact type:', artifactType);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
export function showArtifacts() {
|
47
|
+
if (artifactContainer && suggestionContainer) {
|
48
|
+
artifactContainer.style.display = 'block';
|
49
|
+
suggestionContainer.style.display = 'none';
|
50
|
+
if (toggleArtifactsBtn) toggleArtifactsBtn.textContent = 'Hide Artifacts';
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
export function hideArtifacts() {
|
55
|
+
if (artifactContainer && suggestionContainer) {
|
56
|
+
artifactContainer.style.display = 'none';
|
57
|
+
suggestionContainer.style.display = 'block';
|
58
|
+
if (toggleArtifactsBtn) toggleArtifactsBtn.textContent = 'Show Artifacts';
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
function toggleArtifacts() {
|
63
|
+
if (artifactContainer.style.display === 'none') {
|
64
|
+
showArtifacts();
|
65
|
+
} else {
|
66
|
+
hideArtifacts();
|
67
|
+
}
|
68
68
|
}
|
@@ -1,92 +1,92 @@
|
|
1
|
-
// chat.js
|
2
|
-
import { renderArtifact, showArtifacts } from './artifacts.js';
|
3
|
-
|
4
|
-
let thinkingIndicator = null;
|
5
|
-
let isHandlingResponse = false;
|
6
|
-
|
7
|
-
export function appendMessage(sender, message) {
|
8
|
-
console.log(`Appending message from ${sender}: ${message}`);
|
9
|
-
const chatContainer = document.getElementById('chat-container');
|
10
|
-
const messageElement = document.createElement('div');
|
11
|
-
messageElement.innerHTML = `<strong>${sender}:</strong> ${message}`;
|
12
|
-
chatContainer.appendChild(messageElement);
|
13
|
-
scrollChatToBottom();
|
14
|
-
}
|
15
|
-
|
16
|
-
function scrollChatToBottom() {
|
17
|
-
const chatContainer = document.getElementById('chat-container');
|
18
|
-
chatContainer.scrollTop = chatContainer.scrollHeight;
|
19
|
-
}
|
20
|
-
|
21
|
-
export function showThinkingIndicator() {
|
22
|
-
if (!thinkingIndicator) {
|
23
|
-
thinkingIndicator = document.createElement('div');
|
24
|
-
thinkingIndicator.className = 'thinking-indicator';
|
25
|
-
thinkingIndicator.innerHTML = '<span>Bot is thinking</span><span class="dot-animation">...</span>';
|
26
|
-
document.getElementById('chat-container').appendChild(thinkingIndicator);
|
27
|
-
}
|
28
|
-
thinkingIndicator.style.display = 'block';
|
29
|
-
scrollChatToBottom();
|
30
|
-
}
|
31
|
-
|
32
|
-
export function hideThinkingIndicator() {
|
33
|
-
if (thinkingIndicator) {
|
34
|
-
thinkingIndicator.style.display = 'none';
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
export async function sendMessage(message) {
|
39
|
-
console.log(`Sending message: ${message}`);
|
40
|
-
showThinkingIndicator();
|
41
|
-
try {
|
42
|
-
const response = await fetch('/chat', {
|
43
|
-
method: 'POST',
|
44
|
-
headers: {
|
45
|
-
'Content-Type': 'application/json',
|
46
|
-
},
|
47
|
-
body: JSON.stringify({ message }),
|
48
|
-
});
|
49
|
-
const data = await response.json();
|
50
|
-
console.log('Received response:', data);
|
51
|
-
return data;
|
52
|
-
} finally {
|
53
|
-
hideThinkingIndicator();
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
export function handleResponse(response) {
|
58
|
-
if (isHandlingResponse) {
|
59
|
-
console.log('Already handling a response, skipping.');
|
60
|
-
return;
|
61
|
-
}
|
62
|
-
isHandlingResponse = true;
|
63
|
-
console.log('Handling response:', response);
|
64
|
-
|
65
|
-
try {
|
66
|
-
if (response.response.type === 'text') {
|
67
|
-
appendMessage('Bot', response.response.content);
|
68
|
-
} else if (response.response.type === 'artifact') {
|
69
|
-
let artifactType = response.response.artifact_type;
|
70
|
-
let artifactContent = response.response.content;
|
71
|
-
|
72
|
-
if (artifactType === 'artifact-filing') {
|
73
|
-
artifactContent = {
|
74
|
-
content: response.response.content,
|
75
|
-
data: response.response.data,
|
76
|
-
section_id: response.response.section_id
|
77
|
-
};
|
78
|
-
}
|
79
|
-
|
80
|
-
appendMessage('Bot', `I have prepared an ${artifactType} for you. Please check the artifact view.`);
|
81
|
-
renderArtifact(artifactContent, artifactType);
|
82
|
-
showArtifacts();
|
83
|
-
} else {
|
84
|
-
appendMessage('Bot', 'I have received a response, but it is not a supported type.');
|
85
|
-
}
|
86
|
-
} finally {
|
87
|
-
isHandlingResponse = false;
|
88
|
-
}
|
89
|
-
}
|
90
|
-
|
91
|
-
// Make sendMessage globally accessible
|
1
|
+
// chat.js
|
2
|
+
import { renderArtifact, showArtifacts } from './artifacts.js';
|
3
|
+
|
4
|
+
let thinkingIndicator = null;
|
5
|
+
let isHandlingResponse = false;
|
6
|
+
|
7
|
+
export function appendMessage(sender, message) {
|
8
|
+
console.log(`Appending message from ${sender}: ${message}`);
|
9
|
+
const chatContainer = document.getElementById('chat-container');
|
10
|
+
const messageElement = document.createElement('div');
|
11
|
+
messageElement.innerHTML = `<strong>${sender}:</strong> ${message}`;
|
12
|
+
chatContainer.appendChild(messageElement);
|
13
|
+
scrollChatToBottom();
|
14
|
+
}
|
15
|
+
|
16
|
+
function scrollChatToBottom() {
|
17
|
+
const chatContainer = document.getElementById('chat-container');
|
18
|
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
19
|
+
}
|
20
|
+
|
21
|
+
export function showThinkingIndicator() {
|
22
|
+
if (!thinkingIndicator) {
|
23
|
+
thinkingIndicator = document.createElement('div');
|
24
|
+
thinkingIndicator.className = 'thinking-indicator';
|
25
|
+
thinkingIndicator.innerHTML = '<span>Bot is thinking</span><span class="dot-animation">...</span>';
|
26
|
+
document.getElementById('chat-container').appendChild(thinkingIndicator);
|
27
|
+
}
|
28
|
+
thinkingIndicator.style.display = 'block';
|
29
|
+
scrollChatToBottom();
|
30
|
+
}
|
31
|
+
|
32
|
+
export function hideThinkingIndicator() {
|
33
|
+
if (thinkingIndicator) {
|
34
|
+
thinkingIndicator.style.display = 'none';
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
export async function sendMessage(message) {
|
39
|
+
console.log(`Sending message: ${message}`);
|
40
|
+
showThinkingIndicator();
|
41
|
+
try {
|
42
|
+
const response = await fetch('/chat', {
|
43
|
+
method: 'POST',
|
44
|
+
headers: {
|
45
|
+
'Content-Type': 'application/json',
|
46
|
+
},
|
47
|
+
body: JSON.stringify({ message }),
|
48
|
+
});
|
49
|
+
const data = await response.json();
|
50
|
+
console.log('Received response:', data);
|
51
|
+
return data;
|
52
|
+
} finally {
|
53
|
+
hideThinkingIndicator();
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
export function handleResponse(response) {
|
58
|
+
if (isHandlingResponse) {
|
59
|
+
console.log('Already handling a response, skipping.');
|
60
|
+
return;
|
61
|
+
}
|
62
|
+
isHandlingResponse = true;
|
63
|
+
console.log('Handling response:', response);
|
64
|
+
|
65
|
+
try {
|
66
|
+
if (response.response.type === 'text') {
|
67
|
+
appendMessage('Bot', response.response.content);
|
68
|
+
} else if (response.response.type === 'artifact') {
|
69
|
+
let artifactType = response.response.artifact_type;
|
70
|
+
let artifactContent = response.response.content;
|
71
|
+
|
72
|
+
if (artifactType === 'artifact-filing') {
|
73
|
+
artifactContent = {
|
74
|
+
content: response.response.content,
|
75
|
+
data: response.response.data,
|
76
|
+
section_id: response.response.section_id
|
77
|
+
};
|
78
|
+
}
|
79
|
+
|
80
|
+
appendMessage('Bot', `I have prepared an ${artifactType} for you. Please check the artifact view.`);
|
81
|
+
renderArtifact(artifactContent, artifactType);
|
82
|
+
showArtifacts();
|
83
|
+
} else {
|
84
|
+
appendMessage('Bot', 'I have received a response, but it is not a supported type.');
|
85
|
+
}
|
86
|
+
} finally {
|
87
|
+
isHandlingResponse = false;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
// Make sendMessage globally accessible
|
92
92
|
window.sendMessage = sendMessage;
|