Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Transformerlab App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
TransformerLab
Transformerlab App
Commits
5689ed6f
Commit
5689ed6f
authored
10 months ago
by
Ali Asaria
Browse files
Options
Downloads
Patches
Plain Diff
scroll api logs to bottom
parent
a8ea8796
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/renderer/components/Logs.tsx
+42
-4
42 additions, 4 deletions
src/renderer/components/Logs.tsx
with
42 additions
and
4 deletions
src/renderer/components/Logs.tsx
+
42
−
4
View file @
5689ed6f
...
@@ -8,6 +8,7 @@ import {
...
@@ -8,6 +8,7 @@ import {
AccordionSummary
,
AccordionSummary
,
Box
,
Box
,
Sheet
,
Sheet
,
Typography
,
}
from
'
@mui/joy
'
;
}
from
'
@mui/joy
'
;
import
*
as
chatAPI
from
'
renderer/lib/transformerlab-api-sdk
'
;
import
*
as
chatAPI
from
'
renderer/lib/transformerlab-api-sdk
'
;
...
@@ -21,6 +22,24 @@ function objectMinusPrompt(obj) {
...
@@ -21,6 +22,24 @@ function objectMinusPrompt(obj) {
return
rest
;
return
rest
;
}
}
function
isToday
(
someDateString
)
{
const
someDate
=
new
Date
(
someDateString
);
const
today
=
new
Date
();
const
t
=
someDate
.
getDate
()
===
today
.
getDate
()
&&
someDate
.
getMonth
()
===
today
.
getMonth
()
&&
someDate
.
getFullYear
()
===
today
.
getFullYear
();
console
.
log
(
t
);
console
.
log
(
someDate
+
'
-
'
+
today
);
return
(
someDate
.
getDate
()
===
today
.
getDate
()
&&
someDate
.
getMonth
()
===
today
.
getMonth
()
&&
someDate
.
getFullYear
()
===
today
.
getFullYear
()
);
}
function
renderJSONLinesLog
(
logs
)
{
function
renderJSONLinesLog
(
logs
)
{
return
logs
?.
split
(
'
\n
'
).
map
((
line
,
i
)
=>
{
return
logs
?.
split
(
'
\n
'
).
map
((
line
,
i
)
=>
{
try
{
try
{
...
@@ -30,7 +49,11 @@ function renderJSONLinesLog(logs) {
...
@@ -30,7 +49,11 @@ function renderJSONLinesLog(logs) {
{
/* {i}:{' '} */
}
{
/* {i}:{' '} */
}
<
Accordion
key
=
{
i
}
color
=
"primary"
variant
=
"soft"
>
<
Accordion
key
=
{
i
}
color
=
"primary"
variant
=
"soft"
>
<
AccordionSummary
>
<
AccordionSummary
>
{
line_object
.
date
}
-
{
line_object
?.
log
?.
model
}
<
Typography
color
=
{
isToday
(
line_object
.
date
)
?
'
black
'
:
'
neutral
'
}
>
{
line_object
.
date
}
-
{
line_object
?.
log
?.
model
}
</
Typography
>
</
AccordionSummary
>
</
AccordionSummary
>
<
AccordionDetails
>
<
AccordionDetails
>
<
pre
style
=
{
{
whiteSpace
:
'
pre-wrap
'
}
}
>
<
pre
style
=
{
{
whiteSpace
:
'
pre-wrap
'
}
}
>
...
@@ -46,8 +69,8 @@ function renderJSONLinesLog(logs) {
...
@@ -46,8 +69,8 @@ function renderJSONLinesLog(logs) {
}
catch
(
e
)
{
}
catch
(
e
)
{
return
(
return
(
<>
<>
{
/* {i}: {e.message} - {line}
*/
}
{
/* {i}: {e.message} - {line}
<
br
/>
<br />
*/
}
</>
</>
);
);
}
}
...
@@ -56,10 +79,25 @@ function renderJSONLinesLog(logs) {
...
@@ -56,10 +79,25 @@ function renderJSONLinesLog(logs) {
export
default
function
Logs
({})
{
export
default
function
Logs
({})
{
const
{
data
}
=
useSWR
(
chatAPI
.
Endpoints
.
Global
.
PromptLog
,
fetcher
);
const
{
data
}
=
useSWR
(
chatAPI
.
Endpoints
.
Global
.
PromptLog
,
fetcher
);
React
.
useEffect
(()
=>
{
// Scroll to bottom
const
ae
=
document
.
getElementById
(
'
logs_accordion
'
);
ae
.
scrollTop
=
ae
.
scrollHeight
;
});
return
(
return
(
<
Sheet
style
=
{
{
display
:
'
flex
'
,
flexDirection
:
'
column
'
,
height
:
'
100%
'
}
}
>
<
Sheet
style
=
{
{
display
:
'
flex
'
,
flexDirection
:
'
column
'
,
height
:
'
100%
'
,
paddingBottom
:
'
1rem
'
,
}
}
>
<
h1
>
Prompt Log
</
h1
>
<
h1
>
Prompt Log
</
h1
>
<
Box
<
Box
id
=
"logs_accordion"
style
=
{
{
style
=
{
{
overflow
:
'
auto
'
,
overflow
:
'
auto
'
,
height
:
'
100%
'
,
height
:
'
100%
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment