Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Node Functions",
"type": "node",
"request": "attach",
"port": 9229,
"preLaunchTask": "func: host start"
}
]
}
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Chrome",
"port": 9222,
"url": "http://localhost:4200/",
"request": "attach",
"type": "chrome",
"webRoot": "${workspaceFolder}/samples/openai-acs-msgraph/client"
}
]
}
66 changes: 66 additions & 0 deletions DEBUGGING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Debugging (Tested on Ubuntu Linux)
- node/npm must be installed (eg using nvm)
- set the default versions: ``nvm alias default node``



To debug server and client code in VS Code do the following:

## To run the postgres database
1. Launch docker compose from the terminal:
```
cd samples/openai-acs-msgraph
docker compose up # or if using V1 docker-compose up
```

## To run the server in debug mode
2. Launch the server in debug mode:

![Alt text](images/launch-debug-server.png)

in the package.json of the server


## To run the client in debug mode
3. Launch the browser in debug mode (here we use chrome):

google-chrome-stable --remote-debugging-port=9222


4. Modify your launch.json like this:
```
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Chrome",
"port": 9222,
"url": "http://localhost:4200/",
"request": "attach",
"type": "chrome",
"webRoot": "${workspaceFolder}/samples/openai-acs-msgraph/client"
}
]
}
```
5. Launch your client from the terminal:
```
cd samples/openai-acs-msgraph/client
npm start

```

6. Attach client side debugger
![Alt text](images/attach-to-chrome.png)


## See how the debugger is working

6. ![Alt text](images/generate-email-sms-messages.png)


7. client-side-breakpoint
![Alt text](images/client-side-breakpoint.png)

8. server-side-breakpoint
![Alt text](images/server-side-breakpoint.png)
Binary file added images/attach-to-chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/client-side-breakpoint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/generate-email-sms-messages.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/launch-debug-server.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/server-side-breakpoint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions samples/openai-acs-msgraph/server/typescript/openAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async function getAzureOpenAIBYODCompletion(systemPrompt: string, userPrompt: st
const fetchUrl = `${OPENAI_ENDPOINT}/openai/deployments/${OPENAI_MODEL}/extensions/chat/completions?api-version=${OPENAI_API_VERSION}`;

const messageData: ChatGPTData = {
max_tokens: 1024,
max_tokens: 800,
temperature,
messages: [
{ role: 'system', content: systemPrompt },
Expand Down Expand Up @@ -100,10 +100,10 @@ async function getAzureOpenAIBYODCompletion(systemPrompt: string, userPrompt: st
return completion.error.message;
}

const citations = (completion.choices[0]?.messages[0]?.content?.trim() ?? '') as string;
console.log('Azure OpenAI BYOD Citations: \n', citations);
// const citations = (completion.choices[0]?.message?.context?.trim() ?? '') as string;
// console.log('Azure OpenAI BYOD Citations: \n', citations);

let content = (completion.choices[0]?.messages[1]?.content?.trim() ?? '') as string;
let content = (completion.choices[0]?.message?.content?.trim() ?? '') as string;
console.log('Azure OpenAI BYOD Output: \n', content);

return content;
Expand Down