-
![Logo](./ai.png)
+
@@ -53,7 +54,7 @@
chat.contoso.com
-
@@ -64,7 +65,7 @@
chat.contoso.com
-
+
\ No newline at end of file
diff --git a/src/ai/.x/templates/openai-asst-webpage-js/package.json b/src/ai/.x/templates/openai-asst-webpage-js/package.json
index 3051bcea..18a7a9f6 100644
--- a/src/ai/.x/templates/openai-asst-webpage-js/package.json
+++ b/src/ai/.x/templates/openai-asst-webpage-js/package.json
@@ -5,7 +5,9 @@
"main": "script.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
- "webpack": "webpack"
+ "start": "vite",
+ "build": "vite build",
+ "preview": "vite preview"
},
"author": "",
"license": "MIT",
@@ -16,8 +18,6 @@
},
"keywords": [],
"devDependencies": {
- "dotenv-webpack": "^7.0.3",
- "webpack": "^5.89.0",
- "webpack-cli": "^5.1.4"
+ "vite": "^5.2.8"
}
-}
+}
\ No newline at end of file
diff --git a/src/ai/.x/templates/openai-asst-webpage-js/src/OpenAIAssistantsStreamingClass.js b/src/ai/.x/templates/openai-asst-webpage-js/src/OpenAIAssistantsStreamingClass.js
index 6d387e85..f0b3f911 100644
--- a/src/ai/.x/templates/openai-asst-webpage-js/src/OpenAIAssistantsStreamingClass.js
+++ b/src/ai/.x/templates/openai-asst-webpage-js/src/OpenAIAssistantsStreamingClass.js
@@ -1,9 +1,7 @@
<#@ template hostspecific="true" #>
<#@ output extension=".js" encoding="utf-8" #>
<#@ parameter type="System.String" name="ClassName" #>
-const { OpenAI } = require('openai');
-
-class <#= ClassName #> {
+export class <#= ClassName #> {
// Constructor
constructor(openAIAssistantId, openai, simulateTypingDelay = 0) {
diff --git a/src/ai/.x/templates/openai-asst-webpage-js/src/script.js b/src/ai/.x/templates/openai-asst-webpage-js/src/script.js
index aa8774a1..4691ef5f 100644
--- a/src/ai/.x/templates/openai-asst-webpage-js/src/script.js
+++ b/src/ai/.x/templates/openai-asst-webpage-js/src/script.js
@@ -9,11 +9,11 @@
<#@ parameter type="System.String" name="OPENAI_API_KEY" #>
<#@ parameter type="System.String" name="OPENAI_ORG_ID" #>
<#@ parameter type="System.String" name="OPENAI_MODEL_NAME" #>
-const marked = require("marked");
-const hljs = require("highlight.js");
+import { setOptions, parse } from "marked";
+import * as hljs from "highlight.js";
-const { CreateOpenAI } = require("./CreateOpenAI");
-const { <#= ClassName #> } = require("./OpenAIAssistantsStreamingClass");
+import { CreateOpenAI } from "./CreateOpenAI";
+import { <#= ClassName #> } from "./OpenAIAssistantsStreamingClass";
// NOTE: Never deploy your key in client-side environments like browsers or mobile apps
// SEE: https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
@@ -506,10 +506,8 @@ async function init() {
userInputTextAreaFocus();
- window.newChat = newChat;
- window.loadThread = loadThread;
- window.sendMessage = sendMessage;
- window.toggleTheme = toggleTheme;
+ document.querySelector('#sendButton').addEventListener('click', sendMessage);
+ document.querySelector('#newChatButton').addEventListener('click', newChat);
}
-init();
\ No newline at end of file
+window.addEventListener('DOMContentLoaded', init);
\ No newline at end of file
diff --git a/src/ai/.x/templates/openai-asst-webpage-js/vite.config.js b/src/ai/.x/templates/openai-asst-webpage-js/vite.config.js
new file mode 100644
index 00000000..0e35e81e
--- /dev/null
+++ b/src/ai/.x/templates/openai-asst-webpage-js/vite.config.js
@@ -0,0 +1,3 @@
+export default {
+ envPrefix: ["ASSISTANT_ID", "AZURE_", "OPENAI_"],
+};
\ No newline at end of file
diff --git a/src/ai/.x/templates/openai-asst-webpage-js/webpack.config.js b/src/ai/.x/templates/openai-asst-webpage-js/webpack.config.js
deleted file mode 100644
index 9ba185a5..00000000
--- a/src/ai/.x/templates/openai-asst-webpage-js/webpack.config.js
+++ /dev/null
@@ -1,25 +0,0 @@
-const path = require('path');
-const webpack = require('webpack');
-const Dotenv = require('dotenv-webpack');
-
-module.exports = {
- mode: 'development',
- entry: './src/script.js',
- output: {
- filename: 'main.js',
- path: path.resolve(__dirname, 'dist'),
- },
- plugins: [
- new Dotenv(),
- new webpack.DefinePlugin({
- 'process.env.ASSISTANT_ID': JSON.stringify(process.env.ASSISTANT_ID),
- 'process.env.AZURE_OPENAI_API_KEY': JSON.stringify(process.env.AZURE_OPENAI_API_KEY),
- 'process.env.AZURE_OPENAI_API_VERSION': JSON.stringify(process.env.AZURE_OPENAI_API_VERSION),
- 'process.env.AZURE_OPENAI_ENDPOINT': JSON.stringify(process.env.AZURE_OPENAI_ENDPOINT),
- 'process.env.AZURE_OPENAI_CHAT_DEPLOYMENT': JSON.stringify(process.env.AZURE_OPENAI_CHAT_DEPLOYMENT),
- 'process.env.OPENAI_API_KEY': JSON.stringify(process.env.OPENAI_API_KEY),
- 'process.env.OPENAI_ORG_ID': JSON.stringify(process.env.OPENAI_ORG_ID),
- 'process.env.OPENAI_MODEL_NAME': JSON.stringify(process.env.OPENAI_MODEL_NAME),
- }),
- ],
-};
\ No newline at end of file