You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -30,7 +29,8 @@ async function initAzureOpenAI(context) {
30
29
constassistantDefinition={
31
30
name: "Finance Assistant",
32
31
instructions:
33
-
"You are a personal finance assistant. Retrieve the latest closing price of a stock using its ticker symbol. You also know how to generate a full body email in both plain text and html.",
32
+
"You are a personal finance assistant. Retrieve the latest closing price of a stock using its ticker symbol. "
33
+
+"You also know how to generate a full body email in both plain text and html. Only use the functions you have been provideded with",
34
34
tools: [
35
35
{
36
36
type: "function",
@@ -80,54 +80,73 @@ const assistantDefinition = {
80
80
model: AZURE_DEPLOYMENT_NAME,
81
81
};
82
82
83
-
asyncfunction*processQuery(userQuery,context){
84
-
context.log('Step 0: Connect and acquire an OpenAI instance');
85
-
constopenai=awaitinitAzureOpenAI(context);
83
+
asyncfunction*processQuery(userQuery){
84
+
console.log('Step 0: Connect and acquire an OpenAI instance');
85
+
constopenai=awaitinitAzureOpenAI();
86
86
87
-
context.log('Step 1: Retrieve or Create an Assistant');
87
+
console.log('Step 1: Retrieve or Create an Assistant');
"Based on the latest financial data and current stock market trends, can you provide a detailed analysis of Microsoft's current state? Please include insights into their recent performance, market position, and future outlook. Additionally, retrieve and include the latest closing price of Microsoft's stock using its ticker symbol (MSFT). Send me the full analysis by email.";
@@ -22,69 +23,68 @@ submitQueryRef
22
23
.addEventListener("click",async(event)=>{
23
24
const{ value }=userQueryRef;
24
25
if(value){
26
+
statusLabelRef.innerHTML="waiting";
27
+
outputRef.innerHTML="";
25
28
26
29
loadingRef.classList.remove("hidden");
27
30
outputRef.classList.add("hidden");
28
31
cancelQueryRef.classList.remove("hidden");
29
32
submitQueryRef.classList.add("hidden");
30
33
31
34
autoTimeout();
32
-
submitQuery(value,insertText);
35
+
submitQuery(value);
33
36
}
34
37
});
35
38
36
39
functionautoTimeout(){
37
40
autoAbortTimeout=setTimeout(()=>{
38
41
cancelQueryRef.click();
39
-
42
+
outputRef.classList.remove("hidden");
40
43
if(outputRef.innerHTML===""){
41
44
outputRef.innerHTML="Your Assistant could not fetch data. Please try again!"
42
45
}
43
-
44
-
},30_000);// in case, cancel request after 30 of timeout
45
-
46
+
},60_000);// cancel request if it times out
46
47
}
47
48
48
-
functioninsertText(chunk){
49
-
constdelta=newTextDecoder().decode(chunk);
50
-
outputRef.innerHTML+=delta;
51
-
outputRef.scrollTop=outputRef.scrollHeight;// scroll to bottom
0 commit comments