Skip to content

Commit

Permalink
Extract API code
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhellsten committed Dec 29, 2023
1 parent 95d9df4 commit 6127416
Show file tree
Hide file tree
Showing 40 changed files with 566 additions and 268 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
tmp

# Logs
logs
*.log
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ A HTML UI for Ollama.

## Goals

- Zero dependencies: vanilla HTML, CSS, and Javascript
- Simple installation: download and open in browser
- Minimal & responsive UI: mobile & desktop
- Zero dependencies: vanilla HTML, CSS, and Javascript
- Simple installation

## Features

Expand All @@ -22,6 +22,7 @@ A HTML UI for Ollama.
- Edit chat
- Delete chat
- Download chat
- Scroll to top/bottom
- Copy chat to clipboard

**Chats**
Expand All @@ -32,8 +33,10 @@ A HTML UI for Ollama.

**Settings**

- View settings
- Update settings
- URL
- Model
- System prompt
- Model parameters

## Screenshots

Expand All @@ -56,7 +59,7 @@ A HTML UI for Ollama.
First, install and start [Olama](https://ollama.ai/).

```bash
$ ollama run mistral
$ ollama run dolphin-phi
```

Next, clone this repository:
Expand Down Expand Up @@ -97,7 +100,7 @@ Tests are written using `Playwright` and `node:test`.
The the tests can be run from the command line using this command:

```bash
$ ollama run mistral
$ ollama run dolphin-phi
$ node test
```

Expand All @@ -116,6 +119,7 @@ $ node test

## Done

- [x] Model parameters
- [x] System prompt
- [x] Copy message to clipboard
- [x] Select model in settings (global)
Expand Down
1 change: 1 addition & 0 deletions css/ChatArea.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
}

#chat-title {
@extend h1;
padding-left: 0.5rem;
@extend .font-weight-boldest;
text-overflow: ellipsis;
Expand Down
5 changes: 5 additions & 0 deletions css/ChatMenu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
padding: 0.5rem;
}


.hamburger-menu:hover {
@extend .box-shadow;
}

.hamburger-menu .bar {
width: 1.5rem;
height: 2px;
Expand Down
1 change: 1 addition & 0 deletions css/Sidebar.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Sidebar styling */
#sidebar {
@extend .box-shadow;
min-width: 200px;
max-width: 480px;
//flex: 0 0 250px; /* fixed width */
Expand Down
8 changes: 6 additions & 2 deletions css/Tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
outline: none;
}

.active-tab-button {
@extend .box-shadow;
}

.tab-content {
display: none;
padding: 20px;
border-top: 1px solid #ccc;
//padding: 20px;
//border-top: 1px solid #ccc;
}
6 changes: 5 additions & 1 deletion css/UINotification.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
padding: 1rem;
margin: 1rem;
@extend .box-shadow;
border-radius: 1rem;
border-radius: $border-radius;

.button {
border-radius: 2px;
Expand All @@ -21,3 +21,7 @@
.notification-message {
color: $white;
}

.notification-error {
background: $error-color;
}
3 changes: 3 additions & 0 deletions css/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ button {
cursor: pointer;
i {
color: $button-primary-color;
width: 1rem; // Center the icon
display: inline-block;
}
}

button:hover,
button.selected {
color: $button-primary-color;
background-color: $light-color;
@extend .box-shadow;
}

.button-small {
Expand Down
14 changes: 11 additions & 3 deletions css/form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,29 @@ label {
margin-bottom: .5rem;
}

input {
input, textarea {
width: 100%;
padding: 0.5rem 0.75rem;
display: inline-block;
border: 1px solid $border-color;
}

input.error,
textarea.error {
border: 1px solid $error-color !important;
}

input:focus,
textarea:focus,
[contenteditable]:focus {
border: 1px solid $border-color;
border-color: lighten($secondary-color, 40%);
outline: none;
outline: none !important;
@extend .box-shadow;
}

input:hover {
input:hover,
textarea:hover {
border: 1px solid lighten($secondary-color, 20%);
}

Expand All @@ -32,4 +39,5 @@ label {

textarea {
padding: 0.5rem;
resize: none;
}
4 changes: 4 additions & 0 deletions css/grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@
.flex-align-end {
align-self: flex-end;
}

.justify-left {
justify-content: left;
}
42 changes: 39 additions & 3 deletions css/icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ i[class^="icon-"] {
}

.icon-menu:before {
content: '\22EF'; /* Unicode character for the chevron down icon followed by a non-breaking space */
font-size: 14px; /* Adjust the size of the icon */
font-weight: 900;
content: '\22EF'; /* Unicode character for three dots */
}

.icon-user:before {
Expand All @@ -84,3 +82,41 @@ i[class^="icon-"] {
.icon-speech2:before {
content: "\1F5E8"; /* Unicode for 🗨️ */
}

.icon-scroll-to-top:before {
content: "\21A5";
}

.icon-scroll-to-end:before {
content: "\21A7";
}

.icon-gpt {
display: inline-block;
width: 24px;
height: 24px;
background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBjbGFzcz0iaWNvbi1tZCI+PGNpcmNsZSBjeD0iNi43NSIgY3k9IjYuNzUiIHI9IjMuMjUiIHN0cm9rZT0iY3VycmVudENvbG9yIiBzdHJva2Utd2lkdGg9IjIiPjwvY2lyY2xlPjxjaXJjbGUgY3g9IjE3LjI1IiBjeT0iNi43NSIgcj0iMy4yNSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS13aWR0aD0iMiI+PC9jaXJjbGU+PGNpcmNsZSBjeD0iNi43NSIgY3k9IjE3LjI1IiByPSIzLjI1IiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIj48L2NpcmNsZT48Y2lyY2xlIGN4PSIxNy4yNSIgY3k9IjE3LjI1IiByPSIzLjI1IiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIj48L2NpcmNsZT48L3N2Zz4=");
}

.icon-models {
display: inline-block;
width: 24px;
height: 24px;
background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBjbGFzcz0iaWNvbi1tZCI+CiAgPHJlY3QgeD0iNC4yNSIgeT0iNC4yNSIgd2lkdGg9IjUiIGhlaWdodD0iNSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS13aWR0aD0iMiI+PC9yZWN0PgogIDxyZWN0IHg9IjE0Ljc1IiB5PSI0LjI1IiB3aWR0aD0iNSIgaGVpZ2h0PSI1IiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIj48L3JlY3Q+CiAgPHJlY3QgeD0iNC4yNSIgeT0iMTQuNzUiIHdpZHRoPSI1IiBoZWlnaHQ9IjUiIHN0cm9rZT0iY3VycmVudENvbG9yIiBzdHJva2Utd2lkdGg9IjIiPjwvcmVjdD4KICA8cmVjdCB4PSIxNC43NSIgeT0iMTQuNzUiIHdpZHRoPSI1IiBoZWlnaHQ9IjUiIHN0cm9rZT0iY3VycmVudENvbG9yIiBzdHJva2Utd2lkdGg9IjIiPjwvcmVjdD4KPC9zdmc+Cg==");
}

.icon-chats {
display: inline-block;
//background-image: url('data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjUwIiBoZWlnaHQ9IjMwIiB2aWV3Qm94PSIwIDAgNTAgMzAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPCEtLSBSb3VuZGVkIFJlY3RhbmdsZSBmb3IgdGhlIEJ1YmJsZSAtLT4KICA8cmVjdCB4PSIxIiB5PSIxIiB3aWR0aD0iNDgiIGhlaWdodD0iMjAiIHJ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cG9seWdvbj4KPC9zdmc+Cg==");
width: 24px; /* Adjust as needed */
height: 24px; /* Adjust as needed */
}

.icon-hamburger {
background-image: url('data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDI0IDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDwhLS0gVG9wIFN0cmlwZSAtLT4KICA8cmVjdCB4PSI0IiB5PSI2IiB3aWR0aD0iMTYiIGhlaWdodD0iMiIgZmlsbD0iYmxhY2siPjwvcmVjdD4KCiAgPCEtLSBNaWRkbGUgU3RyaXBlIC0tPgogIDxyZWN0IHg9IjQiIHk9IjExIiB3aWR0aD0iMTYiIGhlaWdodD0iMiIgZmlsbD0iYmxhY2siPjwvcmVjdD4KCiAgPCEtLSBCb3R0b20gU3RyaXBlIC0tPgogIDxyZWN0IHg9IjQiIHk9IjE2IiB3aWR0aD0iMTYiIGhlaWdodD0iMiIgZmlsbD0iYmxhY2siPjwvcmVjdD4KPC9zdmc+Cg==');
width: 24px; /* Adjust as needed */
height: 24px; /* Adjust as needed */
background-size: contain;
background-repeat: no-repeat;
}
11 changes: 6 additions & 5 deletions css/list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ ul {
width: 100%;

li {
@extend .row;
display: flex; /* Use flexbox layout */
justify-content: left;
padding: 0.5rem 0.75rem;
cursor: pointer;
width: 100%;
Expand All @@ -32,13 +33,13 @@ ul {

li.selected {
@extend .font-weight-boldest;
color: $button-primary-color;
background-color: $light-color;
@extend .box-shadow;
//color: $button-primary-color;
//background-color: $light-color;
//@extend .box-shadow;
}

li.selected:before {
//content: "\203A\00a0"; // \00a0 is a non-breaking space
content: "\203A\00a0"; // \00a0 is a non-breaking space
}

li.hover {
Expand Down
13 changes: 0 additions & 13 deletions css/menu.scss

This file was deleted.

7 changes: 4 additions & 3 deletions css/modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
height: 100%;
background-color: rgba(0, 0, 0, 0.5); /* semi-transparent background */
z-index: 1000; /* ensures modal is on top */
overflow: scroll;
}

.modal-header {
Expand All @@ -16,7 +17,7 @@
border-bottom: 1px solid $border-color;

.button {
border-radius: 2px;
border-radius: $border-radius;
padding: .5rem;
line-height: 0.5rem;
}
Expand All @@ -33,8 +34,8 @@
min-width: 320px;
max-width: 50vw;
margin: auto; /* Center the modal */
border-radius: 2px;
overflow: hidden; /* Ensures the border-radius applies to children */
// border-radius: 2px;
// overflow: hidden; /* Ensures the border-radius applies to children */
box-shadow: 0 0 15px #444;
}

Expand Down
13 changes: 13 additions & 0 deletions css/spinner.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.spinner {
border: 2px solid #f3f3f3;
border-top: 2px solid $primary-color;
border-radius: 50%;
width: 20px;
height: 20px;
animation: spin 2s linear infinite;
}

@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
15 changes: 0 additions & 15 deletions css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,3 @@ a {
.text-right {
text-align: right;
}

/* Spinner */
.spinner {
border: 2px solid #f3f3f3;
border-top: 2px solid $primary-color;
border-radius: 50%;
width: 20px;
height: 20px;
animation: spin 2s linear infinite;
}

@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
2 changes: 2 additions & 0 deletions css/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
@import 'list';
@import 'button';
@import 'utils';
@import 'spinner';
@import 'style';
// Components
@import 'Tabs';
@import 'ChatApp';
@import 'ChatMenu';
@import 'ChatHistory';
Expand Down
8 changes: 8 additions & 0 deletions css/utils.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@
.mt-1 {
margin-top: 0.5rem;
}

.d-inline {
display: inline-block;
}

.d-block {
display: block;
}
4 changes: 3 additions & 1 deletion css/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ $secondary-color: #222831;
$tertiary-color: #EEEEEE;

$white: #fff;
$red: #EF4040;

$error-color: $red;
$text-color: $tertiary-color;
$bg-color: $tertiary-color;

Expand All @@ -14,7 +16,7 @@ $button-primary-bgcolor: #EEEEEE;
$button-secondary-color: lighten($primary-color, 2);
$button-secondary-bgcolor: #EEEEEE;

$border-radius: 0px;
$border-radius: 2px;
$border-color: $primary-color;
$border: $border-radius $border-color;

Expand Down
Loading

0 comments on commit 6127416

Please sign in to comment.