Skip to content

Commit

Permalink
Merge pull request #190 from nasa-petal/azure
Browse files Browse the repository at this point in the history
Azure support
  • Loading branch information
bruffridge authored Dec 18, 2024
2 parents f6f5cc0 + 917a0fd commit c8fe99f
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 90 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"@rollup/plugin-terser": "^0.4.4",
"highlight.js": "^11.9.0",
"npm-run-all": "^4.1.5",
"rollup": "^4.18.0",
"rollup": "^4.28.1",
"rollup-plugin-baked-env": "^1.0.1",
"rollup-plugin-css-only": "^4.5.2",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-svelte": "^7.2.2",
"svelte": "^4.2.18"
"svelte": "^4.2.19"
},
"dependencies": {
"deep-chat-dev": "^9.0.179",
"deep-chat-dev": "^9.0.202",
"jspdf": "^2.5.1",
"pino": "^9.5.0",
"sirv-cli": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/assistant/bidara.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const ADVISORY = "**Do not share any sensitive information** in your conv
export const GREETING = "How can I assist you today?";

export const MODEL = "gpt-4o-2024-08-06";
//export const MODEL = "gpt-4o"; // Azure Model Deployment Name

const now = new Date();
const formattedDate = now.toLocaleDateString();
Expand Down
69 changes: 57 additions & 12 deletions src/components/AssistantDeepChat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@
if (thread.length === 0 || thread.length === asst.history + 1) {
const maxCharLen = 50;
const words = message.message.text.split(/\s+/);
let words = message.message.text?.split(/\s+/);
if(!words) {
// first user message is a file upload.
words = message.message.files?.[0]?.name?.split(/\s+/);
}
if(!words) {
// first user message is an image upload.
words = message.message.files?.[0]?.ref?.name?.split(/\s+/);
}
let name = "";
Expand Down Expand Up @@ -130,6 +138,20 @@
imagesToProcess.push(imageFile);
}
function fileTools(fileNames) {
let fileTool = "code_interpreter";
if (Array.isArray(fileNames) && fileNames.length > 0) {
let fileType = threadUtils.getFileTypeByName(fileNames[0]);
if (fileType == "image") {
fileTool = "images";
}
else if (["txt","powerpoint","pdf","word"].indexOf(fileType) !== -1) {
fileTool = "file_search";
}
}
return fileTool;
}
async function handleFuncCalling(functionDetails) {
let context = {
lastMessageId,
Expand Down Expand Up @@ -234,6 +256,12 @@
newFileIds = request.body.attachments.map(attachment => attachment.file_id);
handleFileUploads(newFileIds, newFileUploads);
}
else if(Array.isArray(request.body?.content) && request.body?.content.length > 0) {
//image uploaded
newFileIds = request.body.content.map(attachment => attachment.image_file?.file_id);
newFileIds = newFileIds.filter(item => item !== undefined); // an undefined array entry is created if an image is uploaded alongside a text message. This line removes that undefined array entry.
handleFileUploads(newFileIds, newFileUploads);
}
}
// Debug modified request
Expand Down Expand Up @@ -271,17 +299,19 @@
<deep-chat
id="chat-element"
directConnection={{
//azure: {
openAI: {
key: key,
validateKeyProperty: key ? false : true, // if apiKey is not null it has already been validated.
assistant: key ? {
assistant_id: asstId,
new_assistant: asstConfig,
thread_id: threadId,
load_thread_history: false,
files_tool_type: 'file_search',
function_handler: handleFuncCalling
} : null
//openAI: {
assistant: key ? {
assistant_id: asstId,
new_assistant: asstConfig,
thread_id: threadId,
load_thread_history: false,
files_tool_type: fileTools,
function_handler: handleFuncCalling
} : null
}
}}
history={asst?.history}
Expand All @@ -295,6 +325,7 @@
requestInterceptor={requestInterceptor}
_insertKeyViewStyles={{displayCautionText: false}}
demo={false}
displayLoadingBubble={true}
speechToText={{
webSpeech: "true",
commands: {
Expand Down Expand Up @@ -410,9 +441,13 @@
}
},
loading: {
shared: {
bubble: {
padding: "0.6em 0.75em 0.6em 1.3em"
message: {
styles: {
bubble: {
color: "var(--text-primary-color)",
backgroundColor: "var(--ai-message-background-color)",
padding: '0.6em 0.75em 0.6em 1.3em'
}
}
}
}
Expand All @@ -433,6 +468,16 @@
svg: {
content: '<svg viewBox="2 2 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 3C12.2652 3 12.5196 3.10536 12.7071 3.29289L19.7071 10.2929C20.0976 10.6834 20.0976 11.3166 19.7071 11.7071C19.3166 12.0976 18.6834 12.0976 18.2929 11.7071L13 6.41421V20C13 20.5523 12.5523 21 12 21C11.4477 21 11 20.5523 11 20V6.41421L5.70711 11.7071C5.31658 12.0976 4.68342 12.0976 4.29289 11.7071C3.90237 11.3166 3.90237 10.6834 4.29289 10.2929L11.2929 3.29289C11.4804 3.10536 11.7348 3 12 3Z" fill="#ffffff" stroke="white" stroke-width="1"/></svg>'
}
},
loading: {
container: {
default: {
backgroundColor: "var(--chat-background-color)",
}
},
svg: {
content: '<svg viewBox="2 2 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 3C12.2652 3 12.5196 3.10536 12.7071 3.29289L19.7071 10.2929C20.0976 10.6834 20.0976 11.3166 19.7071 11.7071C19.3166 12.0976 18.6834 12.0976 18.2929 11.7071L13 6.41421V20C13 20.5523 12.5523 21 12 21C11.4477 21 11 20.5523 11 20V6.41421L5.70711 11.7071C5.31658 12.0976 4.68342 12.0976 4.29289 11.7071C3.90237 11.3166 3.90237 10.6834 4.29289 10.2929L11.2929 3.29289C11.4804 3.10536 11.7348 3 12 3Z" fill="#b1b1b1" stroke="#b1b1b1" stroke-width="1"/></svg>'
}
}
}}
auxiliaryStyle={`
Expand Down
Binary file removed src/utils/FitchGroupDisabilityForm.pdf
Binary file not shown.
Loading

0 comments on commit c8fe99f

Please sign in to comment.