Skip to content

Commit

Permalink
Merge pull request #43 from ryanleung/ryanleung-ui-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
betterbrand authored Mar 6, 2024
2 parents 5d9514f + a499465 commit 186e139
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/frontend/components/buttons/connect-wallet-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default forwardRef<HTMLDivElement>((props: Props, ref) => {
<ConnectWalletButton.Wrapper onClick={onClick} ref={ref}>
<ConnectWalletButton.Logo src={wallet} />
<ConnectWalletButton.Text>{connected ? 'connected' : 'connect'}</ConnectWalletButton.Text>
{!connecting && <ConnectWalletButton.Badge $connected={connected} $connecting={connecting} />}
</ConnectWalletButton.Wrapper>
);
});
Expand Down
5 changes: 3 additions & 2 deletions src/frontend/components/buttons/navigation-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ const MainNavButton = {
height: 100%;
margin: 0 15px;
align-items: center;
color: ${(props) => (props.active === 'active' ? props.theme.colors.emerald : props.theme.colors.balance)};
color: ${(props) => props.theme.colors.balance};
opacity: ${(props) => (props.active === 'active' ? 1 : 0.5)};
font-family: ${(props) => props.theme.fonts.family.primary.bold};
font-size: ${(props) => props.theme.fonts.size.medium};
text-decoration: none;
transition: border 0.25s, color 0.25s;
&:hover span {
color: ${(props) => props.theme.colors.emerald};
opacity: 0.75;
}
`,
Icon: Styled.img`
Expand Down
1 change: 1 addition & 0 deletions src/frontend/components/layout/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const Main = {
border-radius: 30px;
border: 5px solid ${(props) => props.theme.colors.hunter};
padding: 10px;
overflow: hidden;
`,
BottomWrapper: Styled.div`
display: flex;
Expand Down
13 changes: 4 additions & 9 deletions src/frontend/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,17 @@ import { ModelResponse } from './types';
export const parseResponse = (jsonString: string) => {
// Assert the type of the parsed object.
console.log(jsonString);

// uses regex to remove comments that llama sometimes includes in the JSON string
// ranges from // to the end of the line or the end of the string
jsonString = jsonString.replace(/(?<!\\)\/\/.*?(?=\n|$)/gm, '');
// jsonString = jsonString.replace(/(?<!\\)\/\/.*?(?=\n|$)/gm, '');
let parsed: string;
try {
parsed = JSON.parse(jsonString);
} catch (error) {
try {
jsonString = jsonString + '}'; //llama often forgets this
parsed = JSON.parse(jsonString);
} catch (error) {
new Error('Ollama error');
return { response: 'error', action: {} };
}
new Error('Ollama error');
return { response: 'error', action: {} };
}

if (isModelResponse(parsed)) {
return { response: parsed.response, action: parsed.action };
} else {
Expand Down
9 changes: 5 additions & 4 deletions src/frontend/views/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ const ChatView = (): JSX.Element => {
console.log(inference);
if (inference) {
const { response, action: action } = parseResponse(inference.message.content);

if (response == 'error') {
updateDialogueEntries(question, 'Sorry, I had a problem with your request.');
} else {
Expand Down Expand Up @@ -276,7 +277,7 @@ const ChatView = (): JSX.Element => {
}}
/>
<Chat.SubmitButton
disabled={isOllamaBeingPolled}
disabled={isOllamaBeingPolled || !inputValue}
onClick={() => handleQuestionAsked(inputValue)}
/>
</Chat.InputWrapper>
Expand Down Expand Up @@ -371,11 +372,11 @@ const Chat = {
background: ${(props) => props.theme.colors.hunter};
position: absolute;
right: 5px;
cursor: pointer;
cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
border: none;
&:hover {
background: ${(props) => props.theme.colors.emerald};
background: ${(props) => (props.disabled ? props.theme.colors.hunter : props.theme.colors.emerald)};
}
`,
Dropdown: Styled.select`
Expand All @@ -389,7 +390,7 @@ const Chat = {
border: 2px solid ${(props) => props.theme.colors.hunter};
font-family: ${(props) => props.theme.fonts.family.primary.regular};
font-size: ${(props) => props.theme.fonts.size.small};
cursor: pointer;
cursor: pointer;
&:hover {
border: 2px solid ${(props) => props.theme.colors.emerald};
Expand Down

0 comments on commit 186e139

Please sign in to comment.