From b6a780e7c7fb1995815d9213ff15d4356e20a03e Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 24 Oct 2023 01:52:19 -0700 Subject: [PATCH 1/6] feat: enable api_base_url edit from ui --- package-lock.json | 77 ++++++++++++++++++++ package.json | 1 + src/lib/components/chat/SettingsModal.svelte | 63 +++++++++++++++- src/routes/+page.svelte | 52 +++++++------ tailwind.config.js | 2 +- 5 files changed, 167 insertions(+), 28 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7080e3cd..e071c47e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/adapter-static": "^2.0.3", "@sveltejs/kit": "^1.20.4", + "@tailwindcss/typography": "^0.5.10", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", "autoprefixer": "^10.4.16", @@ -838,6 +839,34 @@ "vite": "^4.0.0" } }, + "node_modules/@tailwindcss/typography": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.5.10.tgz", + "integrity": "sha512-Pe8BuPJQJd3FfRnm6H0ulKIGoMEQS+Vq01R6M5aCrFB/ccR/shT+0kXLjouGC1gFLm9hopTFN+DMP0pfwRWzPw==", + "dev": true, + "dependencies": { + "lodash.castarray": "^4.4.0", + "lodash.isplainobject": "^4.0.6", + "lodash.merge": "^4.6.2", + "postcss-selector-parser": "6.0.10" + }, + "peerDependencies": { + "tailwindcss": ">=3.0.0 || insiders" + } + }, + "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser": { + "version": "6.0.10", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz", + "integrity": "sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==", + "dev": true, + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/@types/cookie": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.5.2.tgz", @@ -2603,6 +2632,18 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "node_modules/lodash.castarray": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz", + "integrity": "sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==", + "dev": true + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "dev": true + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -4670,6 +4711,30 @@ "debug": "^4.3.4" } }, + "@tailwindcss/typography": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.5.10.tgz", + "integrity": "sha512-Pe8BuPJQJd3FfRnm6H0ulKIGoMEQS+Vq01R6M5aCrFB/ccR/shT+0kXLjouGC1gFLm9hopTFN+DMP0pfwRWzPw==", + "dev": true, + "requires": { + "lodash.castarray": "^4.4.0", + "lodash.isplainobject": "^4.0.6", + "lodash.merge": "^4.6.2", + "postcss-selector-parser": "6.0.10" + }, + "dependencies": { + "postcss-selector-parser": { + "version": "6.0.10", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz", + "integrity": "sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==", + "dev": true, + "requires": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + } + } + } + }, "@types/cookie": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.5.2.tgz", @@ -5909,6 +5974,18 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "lodash.castarray": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz", + "integrity": "sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==", + "dev": true + }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "dev": true + }, "lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", diff --git a/package.json b/package.json index 2f454eda..9959f20c 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/adapter-static": "^2.0.3", "@sveltejs/kit": "^1.20.4", + "@tailwindcss/typography": "^0.5.10", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", "autoprefixer": "^10.4.16", diff --git a/src/lib/components/chat/SettingsModal.svelte b/src/lib/components/chat/SettingsModal.svelte index 66b5f72f..58d27e4c 100644 --- a/src/lib/components/chat/SettingsModal.svelte +++ b/src/lib/components/chat/SettingsModal.svelte @@ -1,13 +1,14 @@ @@ -615,7 +660,9 @@ {:else} -
+
{@html marked.parse(message.content)}
{/if} @@ -869,4 +916,33 @@ clip-path: inset(0 -1ch 0 0); } } + + pre[class*='language-'] { + position: relative; + overflow: auto; + + /* make space */ + margin: 5px 0; + padding: 1.75rem 0 1.75rem 1rem; + border-radius: 10px; + } + + pre[class*='language-'] button { + position: absolute; + top: 5px; + right: 5px; + + font-size: 0.9rem; + padding: 0.15rem; + background-color: #828282; + + border: ridge 1px #7b7b7c; + border-radius: 5px; + text-shadow: #c4c4c4 0 0 2px; + } + + pre[class*='language-'] button:hover { + cursor: pointer; + background-color: #bcbabb; + } diff --git a/tailwind.config.js b/tailwind.config.js index b8f9f10f..54ab6813 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -17,6 +17,17 @@ export default { 900: '#202123', 950: '#050509' } + }, + typography: { + DEFAULT: { + css: { + pre: false, + code: false, + 'pre code': false, + 'code::before': false, + 'code::after': false + } + } } } }, From 28ea56c95afb8bafe48386c3421957a716037a70 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 24 Oct 2023 17:57:09 -0700 Subject: [PATCH 5/6] feat: copy code block added --- src/routes/+page.svelte | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 0534cb12..513a10d4 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -123,7 +123,8 @@ blocks.forEach((block) => { // only add button if browser supports Clipboard API - if (navigator.clipboard) { + + if (navigator.clipboard && block.childNodes.length < 2) { let button = document.createElement('button'); button.innerText = 'Copy Code'; @@ -380,6 +381,7 @@ responseMessage.context = data.context; messages = messages; hljs.highlightAll(); + createCopyCodeBlockButton(); } } } @@ -477,6 +479,7 @@ responseMessage.context = data.context; messages = messages; hljs.highlightAll(); + createCopyCodeBlockButton(); } } } @@ -661,7 +664,7 @@
{:else}
{@html marked.parse(message.content)}
From 7d0ec543b7398ce5cf54fb3eb8d441ee8136a1e5 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 24 Oct 2023 18:12:00 -0700 Subject: [PATCH 6/6] doc: troubleshooting guide added --- README.md | 28 ++++++++++++++++++++ src/lib/components/chat/SettingsModal.svelte | 5 +++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e7ac235..a4ad977d 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,34 @@ docker run -d -p 3000:8080 --name ollama-webui --restart always ollama-webui caddy run --envfile .env --config ./Caddyfile.localhost ``` +## Troubleshooting + +### Connection Errors + +If you encounter difficulties connecting to the Ollama server, please follow these steps to diagnose and resolve the issue: + +**1. Verify Ollama Server Configuration** + +Ensure that the Ollama server is properly configured to accept incoming connections from all origins. To do this, make sure the server is launched with the `OLLAMA_ORIGINS=*` environment variable, as shown in the following command: + +```bash +OLLAMA_HOST=0.0.0.0 OLLAMA_ORIGINS=* ollama serve +``` + +This configuration allows Ollama to accept connections from any source. + +**2. Check Ollama URL Format** + +Ensure that the Ollama URL is correctly formatted in the application settings. Follow these steps: + +- Go to "Settings" within the Ollama WebUI. +- Navigate to the "General" section. +- Verify that the Ollama URL is in the following format: `http://localhost:11434/api`. + +It is crucial to include the `/api` at the end of the URL to ensure that the Ollama Web UI can communicate with the server. + +By following these troubleshooting steps, you should be able to identify and resolve connection issues with your Ollama server configuration. If you require further assistance or have additional questions, please don't hesitate to reach out or refer to our documentation for comprehensive guidance. + ## What's Next? 🚀 ### To-Do List 📝 diff --git a/src/lib/components/chat/SettingsModal.svelte b/src/lib/components/chat/SettingsModal.svelte index 66e39525..42fd8c6f 100644 --- a/src/lib/components/chat/SettingsModal.svelte +++ b/src/lib/components/chat/SettingsModal.svelte @@ -35,12 +35,15 @@ }; const checkOllamaConnection = async () => { + if (API_BASE_URL === '') { + API_BASE_URL = BUILD_TIME_API_BASE_URL; + } const res = await getModelTags(API_BASE_URL); if (res) { toast.success('Server connection verified'); saveSettings( - API_BASE_URL === '' ? BUILD_TIME_API_BASE_URL : API_BASE_URL, + API_BASE_URL, system != '' ? system : null, temperature != 0.8 ? temperature : null );