Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/additional frontend features #72

Merged
merged 24 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
51eed1d
feat: add show thought process layout logic
anfibiacreativa Oct 9, 2023
06cf626
feat: add lightbulb icon
anfibiacreativa Oct 9, 2023
e226775
feat: add hide aside panel label
anfibiacreativa Oct 9, 2023
c0419f4
feat: improve logic for show thought process
anfibiacreativa Oct 9, 2023
b0ddd83
feat: add close button
anfibiacreativa Oct 9, 2023
50430b9
fix: fix reactive
anfibiacreativa Oct 9, 2023
56ace77
feat: add styles for aside
anfibiacreativa Oct 9, 2023
c7c5396
feat: add variables for printing aside
anfibiacreativa Oct 9, 2023
6b6453f
feat: add activate tab initial logic
anfibiacreativa Oct 9, 2023
cbf2a23
feat: add data from response to vars
anfibiacreativa Oct 9, 2023
3deb4ff
feat: add aside to html
anfibiacreativa Oct 9, 2023
33ac6c1
feat: improve layout aside
anfibiacreativa Oct 9, 2023
3d5291a
feat: add a tab component
anfibiacreativa Oct 9, 2023
f338928
docs: add comments about decoupling
anfibiacreativa Oct 9, 2023
118d934
feat: complete thought process display
anfibiacreativa Oct 10, 2023
7a43168
fix: fix bug with show thoughts when not yet back from stream process
anfibiacreativa Oct 10, 2023
0774181
fix: fix bug with show thoughts when not yet back from stream process…
anfibiacreativa Oct 10, 2023
878fbf7
feat: add thought process support for streaming disabled
anfibiacreativa Oct 11, 2023
9b73eac
feat: add accessibility controls for tab sub component
anfibiacreativa Oct 11, 2023
a0787d2
fix: add cosmetic improvements to footer and form
anfibiacreativa Oct 11, 2023
f8ff1c6
fix: fix bug when hitting show default prompts and thought process is…
anfibiacreativa Oct 11, 2023
f0fe13e
fix: remove unused return object
anfibiacreativa Oct 11, 2023
094af8e
chore: remove console.log and update config
anfibiacreativa Oct 11, 2023
8470474
Merge branch 'main' into feat/addional-frontend-features
anfibiacreativa Oct 12, 2023
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
2 changes: 1 addition & 1 deletion packages/chat-component/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h1>Welcome to this Azure OpenAI JavaScript Chat Sample</h1>
}
@media screen and (min-width: 768px) {
.chat__main {
width: 50%;
width: 80%;
padding: 50px;
margin: 0 auto;
}
Expand Down
1 change: 1 addition & 0 deletions packages/chat-component/public/svg/close-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/chat-component/public/svg/lightbulb-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/chat-component/public/svg/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All icons in this sample are free and open source
- [Copy Icon](https://fontawesome.com/icons/copy?f=classic&s=solid)
- [Double Check Icon](https://fontawesome.com/icons/check-double?f=classic&s=solid)
- [Email Icon](https://fontawesome.com/icons/envelope-open-text?f=classic&s=solid)
- [Lightbulb Icon](https://fontawesome.com/icons/lightbulb?f=classic&s=solid)

## FontAwesome License

Expand Down
5 changes: 5 additions & 0 deletions packages/chat-component/src/config/global-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ const globalConfig = {
// Copy response to clipboard
COPY_RESPONSE_BUTTON_LABEL_TEXT: 'Copy Response',
COPIED_SUCCESSFULLY_MESSAGE: 'Response copied!',
SHOW_THOUGH_PROCESS_BUTTON_LABEL_TEXT: 'Show thought process',
HIDE_THOUGH_PROCESS_BUTTON_LABEL_TEXT: 'Hide thought process',
LOADING_INDICATOR_TEXT: 'Please wait. We are searching for an answer...',
// API ERROR HANDLING IN UI
API_ERROR_MESSAGE: 'Sorry, we are having some problems. Please try again later.',
// Config pertaining the response format
THOUGHT_PROCESS_LABEL: 'Thought Process',
SUPPORT_CONTEXT_LABEL: 'Support Context',
CITATIONS_LABEL: 'Citations',
};

const NEXT_QUESTION_INDICATOR = 'Next Questions:';
Expand Down
1 change: 0 additions & 1 deletion packages/chat-component/src/core/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export async function getAPIResponse(
if (httpOptions.stream) {
return response;
}

const parsedResponse: BotResponse = await response.json();
if (response.status > 299 || !response.ok) {
throw new Error(response.statusText) || 'API Response Error';
Expand Down
10 changes: 8 additions & 2 deletions packages/chat-component/src/core/parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ export async function parseStreamedMessages({
let isFollowupQuestion = false;
let stepIndex = 0;
let textBlockIndex = 0;
const thoughtProcess: string[] = [];

for await (const chunk of chunks) {
// eslint-disable-next-line no-prototype-builtins
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably disable this rule, makes no sense to me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

if (chunk.hasOwnProperty('data_points')) {
thoughtProcess.push(chunk as string);
continue;
}
let chunkValue = chunk.answer as string;

if (chunkValue === '') {
continue;
}
Expand Down Expand Up @@ -110,8 +117,7 @@ export async function parseStreamedMessages({

visit();
}

return streamedMessageRaw.join('');
return streamedMessageRaw.join(''), thoughtProcess;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not what's the intent here? I you want to return both it should be in an array [streamedMessageRaw.join(''), thoughtProcess], as currently only thoughtProcess is returned?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good catch. Initially I was going to wrap both in an object, but streamedMessageRaw is not used, so I was going to delete it all together. I left it for later to decide, and I simply forgot :)

}

// update the citations entry and wrap the citations in a sup tag
Expand Down
Loading