Misc julien tweaks (#525)
Browse files* Fix formatting (whitespace)
* typo
* i think we can remove this now
- .env +0 -1
- .env.template +15 -16
- scripts/updateProdEnv.ts +1 -1
- src/app.html +0 -28
- src/hooks.server.ts +2 -5
.env
CHANGED
|
@@ -76,7 +76,6 @@ TASK_MODEL='' # name of the model used for tasks such as summarizing title, crea
|
|
| 76 |
PUBLIC_ORIGIN=#https://huggingface.co
|
| 77 |
PUBLIC_SHARE_PREFIX=#https://hf.co/chat
|
| 78 |
PUBLIC_GOOGLE_ANALYTICS_ID=#G-XXXXXXXX / Leave empty to disable
|
| 79 |
-
PUBLIC_DEPRECATED_GOOGLE_ANALYTICS_ID=#UA-XXXXXXXX-X / Leave empty to disable
|
| 80 |
PUBLIC_ANNOUNCEMENT_BANNERS=`[
|
| 81 |
{
|
| 82 |
"title": "Llama v2 is live on HuggingChat! 🦙",
|
|
|
|
| 76 |
PUBLIC_ORIGIN=#https://huggingface.co
|
| 77 |
PUBLIC_SHARE_PREFIX=#https://hf.co/chat
|
| 78 |
PUBLIC_GOOGLE_ANALYTICS_ID=#G-XXXXXXXX / Leave empty to disable
|
|
|
|
| 79 |
PUBLIC_ANNOUNCEMENT_BANNERS=`[
|
| 80 |
{
|
| 81 |
"title": "Llama v2 is live on HuggingChat! 🦙",
|
.env.template
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# template used in production for HuggingChat.
|
| 2 |
|
| 3 |
MODELS=`[
|
| 4 |
-
|
| 5 |
"name": "meta-llama/Llama-2-70b-chat-hf",
|
| 6 |
"description": "The latest and biggest model from Meta, fine-tuned for chat.",
|
| 7 |
"websiteUrl": "https://ai.meta.com/llama/",
|
|
@@ -31,8 +31,8 @@ MODELS=`[
|
|
| 31 |
"truncate": 1000,
|
| 32 |
"max_new_tokens": 1024
|
| 33 |
}
|
| 34 |
-
|
| 35 |
-
|
| 36 |
"name": "codellama/CodeLlama-34b-Instruct-hf",
|
| 37 |
"displayName": "codellama/CodeLlama-34b-Instruct-hf",
|
| 38 |
"description": "Code Llama, a state of the art code model from Meta.",
|
|
@@ -110,18 +110,18 @@ MODELS=`[
|
|
| 110 |
"stop": ["</s>"]
|
| 111 |
},
|
| 112 |
"promptExamples": [
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
]`
|
| 126 |
|
| 127 |
OLD_MODELS=`[{"name":"bigcode/starcoder"}, {"name":"OpenAssistant/oasst-sft-6-llama-30b-xor"}, {"name":"HuggingFaceH4/zephyr-7b-alpha"}]`
|
|
@@ -145,7 +145,6 @@ RATE_LIMIT=16
|
|
| 145 |
MESSAGES_BEFORE_LOGIN=1# how many messages a user can send in a conversation before having to login. set to 0 to force login right away
|
| 146 |
|
| 147 |
PUBLIC_GOOGLE_ANALYTICS_ID=G-8Q63TH4CSL
|
| 148 |
-
PUBLIC_DEPRECATED_GOOGLE_ANALYTICS_ID=UA-83738774-2
|
| 149 |
|
| 150 |
# Not part of the .env but set as other variables in the space
|
| 151 |
# ADDRESS_HEADER=X-Forwarded-For
|
|
|
|
| 1 |
# template used in production for HuggingChat.
|
| 2 |
|
| 3 |
MODELS=`[
|
| 4 |
+
{
|
| 5 |
"name": "meta-llama/Llama-2-70b-chat-hf",
|
| 6 |
"description": "The latest and biggest model from Meta, fine-tuned for chat.",
|
| 7 |
"websiteUrl": "https://ai.meta.com/llama/",
|
|
|
|
| 31 |
"truncate": 1000,
|
| 32 |
"max_new_tokens": 1024
|
| 33 |
}
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
"name": "codellama/CodeLlama-34b-Instruct-hf",
|
| 37 |
"displayName": "codellama/CodeLlama-34b-Instruct-hf",
|
| 38 |
"description": "Code Llama, a state of the art code model from Meta.",
|
|
|
|
| 110 |
"stop": ["</s>"]
|
| 111 |
},
|
| 112 |
"promptExamples": [
|
| 113 |
+
{
|
| 114 |
+
"title": "Write an email from bullet list",
|
| 115 |
+
"prompt": "As a restaurant owner, write a professional email to the supplier to get these products every week: \n\n- Wine (x10)\n- Eggs (x24)\n- Bread (x12)"
|
| 116 |
+
}, {
|
| 117 |
+
"title": "Code a snake game",
|
| 118 |
+
"prompt": "Code a basic snake game in python, give explanations for each step."
|
| 119 |
+
}, {
|
| 120 |
+
"title": "Assist in a task",
|
| 121 |
+
"prompt": "How do I make a delicious lemon cheesecake?"
|
| 122 |
+
}
|
| 123 |
+
]
|
| 124 |
+
}
|
| 125 |
]`
|
| 126 |
|
| 127 |
OLD_MODELS=`[{"name":"bigcode/starcoder"}, {"name":"OpenAssistant/oasst-sft-6-llama-30b-xor"}, {"name":"HuggingFaceH4/zephyr-7b-alpha"}]`
|
|
|
|
| 145 |
MESSAGES_BEFORE_LOGIN=1# how many messages a user can send in a conversation before having to login. set to 0 to force login right away
|
| 146 |
|
| 147 |
PUBLIC_GOOGLE_ANALYTICS_ID=G-8Q63TH4CSL
|
|
|
|
| 148 |
|
| 149 |
# Not part of the .env but set as other variables in the space
|
| 150 |
# ADDRESS_HEADER=X-Forwarded-For
|
scripts/updateProdEnv.ts
CHANGED
|
@@ -18,7 +18,7 @@ SERPER_API_KEY=${SERPER_API_KEY}
|
|
| 18 |
HF_ACCESS_TOKEN=${HF_ACCESS_TOKEN}
|
| 19 |
`;
|
| 20 |
|
| 21 |
-
// Make an HTTP POST request to add the space
|
| 22 |
fetch(`https://huggingface.co/api/spaces/huggingchat/chat-ui/secrets`, {
|
| 23 |
method: "POST",
|
| 24 |
body: JSON.stringify({
|
|
|
|
| 18 |
HF_ACCESS_TOKEN=${HF_ACCESS_TOKEN}
|
| 19 |
`;
|
| 20 |
|
| 21 |
+
// Make an HTTP POST request to add the space secrets
|
| 22 |
fetch(`https://huggingface.co/api/spaces/huggingchat/chat-ui/secrets`, {
|
| 23 |
method: "POST",
|
| 24 |
body: JSON.stringify({
|
src/app.html
CHANGED
|
@@ -17,7 +17,6 @@
|
|
| 17 |
|
| 18 |
// For some reason, Sveltekit doesn't let us load env variables from .env here, so we load it from hooks.server.ts
|
| 19 |
window.gaId = "%gaId%";
|
| 20 |
-
window.gaIdDeprecated = "%gaIdDeprecated%";
|
| 21 |
</script>
|
| 22 |
%sveltekit.head%
|
| 23 |
</head>
|
|
@@ -44,32 +43,5 @@
|
|
| 44 |
/// TODO: ask the user for their consent and update this with gtag('consent', 'update')
|
| 45 |
}
|
| 46 |
</script>
|
| 47 |
-
|
| 48 |
-
<!-- Google Analytics v3 (deprecated on 1 July 2023) -->
|
| 49 |
-
<script>
|
| 50 |
-
if (window.gaIdDeprecated) {
|
| 51 |
-
(function (i, s, o, g, r, a, m) {
|
| 52 |
-
i["GoogleAnalyticsObject"] = r;
|
| 53 |
-
(i[r] =
|
| 54 |
-
i[r] ||
|
| 55 |
-
function () {
|
| 56 |
-
(i[r].q = i[r].q || []).push(arguments);
|
| 57 |
-
}),
|
| 58 |
-
(i[r].l = 1 * new Date());
|
| 59 |
-
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
|
| 60 |
-
a.async = 1;
|
| 61 |
-
a.src = g;
|
| 62 |
-
m.parentNode.insertBefore(a, m);
|
| 63 |
-
})(
|
| 64 |
-
window,
|
| 65 |
-
document,
|
| 66 |
-
"script",
|
| 67 |
-
"https://www.google-analytics.com/analytics.js",
|
| 68 |
-
"ganalytics"
|
| 69 |
-
);
|
| 70 |
-
ganalytics("create", window.gaIdDeprecated, "auto");
|
| 71 |
-
ganalytics("send", "pageview");
|
| 72 |
-
}
|
| 73 |
-
</script>
|
| 74 |
</body>
|
| 75 |
</html>
|
|
|
|
| 17 |
|
| 18 |
// For some reason, Sveltekit doesn't let us load env variables from .env here, so we load it from hooks.server.ts
|
| 19 |
window.gaId = "%gaId%";
|
|
|
|
| 20 |
</script>
|
| 21 |
%sveltekit.head%
|
| 22 |
</head>
|
|
|
|
| 43 |
/// TODO: ask the user for their consent and update this with gtag('consent', 'update')
|
| 44 |
}
|
| 45 |
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
</body>
|
| 47 |
</html>
|
src/hooks.server.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { COOKIE_NAME, MESSAGES_BEFORE_LOGIN } from "$env/static/private";
|
|
| 2 |
import type { Handle } from "@sveltejs/kit";
|
| 3 |
import {
|
| 4 |
PUBLIC_GOOGLE_ANALYTICS_ID,
|
| 5 |
-
PUBLIC_DEPRECATED_GOOGLE_ANALYTICS_ID,
|
| 6 |
PUBLIC_ORIGIN,
|
| 7 |
PUBLIC_APP_DISCLAIMER,
|
| 8 |
} from "$env/static/public";
|
|
@@ -98,14 +97,12 @@ export const handle: Handle = async ({ event, resolve }) => {
|
|
| 98 |
const response = await resolve(event, {
|
| 99 |
transformPageChunk: (chunk) => {
|
| 100 |
// For some reason, Sveltekit doesn't let us load env variables from .env in the app.html template
|
| 101 |
-
if (replaced || !chunk.html.includes("%gaId%")
|
| 102 |
return chunk.html;
|
| 103 |
}
|
| 104 |
replaced = true;
|
| 105 |
|
| 106 |
-
return chunk.html
|
| 107 |
-
.replace("%gaId%", PUBLIC_GOOGLE_ANALYTICS_ID)
|
| 108 |
-
.replace("%gaIdDeprecated%", PUBLIC_DEPRECATED_GOOGLE_ANALYTICS_ID);
|
| 109 |
},
|
| 110 |
});
|
| 111 |
|
|
|
|
| 2 |
import type { Handle } from "@sveltejs/kit";
|
| 3 |
import {
|
| 4 |
PUBLIC_GOOGLE_ANALYTICS_ID,
|
|
|
|
| 5 |
PUBLIC_ORIGIN,
|
| 6 |
PUBLIC_APP_DISCLAIMER,
|
| 7 |
} from "$env/static/public";
|
|
|
|
| 97 |
const response = await resolve(event, {
|
| 98 |
transformPageChunk: (chunk) => {
|
| 99 |
// For some reason, Sveltekit doesn't let us load env variables from .env in the app.html template
|
| 100 |
+
if (replaced || !chunk.html.includes("%gaId%")) {
|
| 101 |
return chunk.html;
|
| 102 |
}
|
| 103 |
replaced = true;
|
| 104 |
|
| 105 |
+
return chunk.html.replace("%gaId%", PUBLIC_GOOGLE_ANALYTICS_ID);
|
|
|
|
|
|
|
| 106 |
},
|
| 107 |
});
|
| 108 |
|