Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into furn_experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisglein committed Nov 15, 2023
2 parents 3d6b77b + 947b3a4 commit dd90621
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 191 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Artifical Chat is an app to explore the wonders of conversational AI using React Native for Windows to build the user experience. The goal is to handle not just plain text but rich markdown documents, code, and faciliate image generation as well.

![image](https://user-images.githubusercontent.com/26607885/233441056-39033d3c-3420-4c31-b7db-ca39944fc00e.png)

# Setup
1. Install all dependencies per [RNW Dependencies](https://microsoft.github.io/react-native-windows/docs/rnw-dependencies)
1. `yarn`
Expand Down Expand Up @@ -101,5 +105,6 @@ The app's settings are handled by a `SettingsContext` object, which has dialog U
- Syntax Highlighting via [react-native-syntax-highlighter](https://github.com/conorhastings/react-native-syntax-highlighter)
- Dependency patching via [patch-package](https://github.com/ds300/patch-package)
- Storage via [react-native-async-storage](https://github.com/react-native-async-storage/async-storage)
- Markdown rendering via [react-native-markdown-display](https://github.com/iamacup/react-native-markdown-display)
- Button, Checkbox, Link via [@fluentui/react-native](https://github.com/microsoft/fluentui-react-native)
- Markdown rendering via [react-native-markdown-display-updated](https://github.com/willmac321/react-native-markdown-display)
- Dialogs via [react-native-content-dialog](https://github.com/chrisglein/react-native-content-dialog)
- Button, Checkbox, Link via [@fluentui/react-native](https://github.com/microsoft/fluentui-react-native)
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
"dependencies": {
"@fluentui/react-native": "^0.36.20",
"@react-native-async-storage/async-storage": "^1.17.11",
"@react-native-clipboard/clipboard": "^1.11.2",
"@react-native-picker/picker": "^2.2.1",
"@react-native-clipboard/clipboard": "^1.12.1",
"@react-native-picker/picker": "^2.5.1",
"patch-package": "^6.5.1",
"postinstall-postinstall": "^2.1.0",
"react": "18.2.0",
"react-native": "0.71.0",
"react-native-markdown-display": "^7.0.0-alpha.2",
"react-native-svg": "^14.0.0",
"react-native-content-dialog": "^0.2.0",
"react-native-markdown-display-updated": "^7.0.0",
"react-native-syntax-highlighter": "^2.1.0",
"react-native-svg": "^14.0.0",
"react-native-windows": "0.71.1"
},
"devDependencies": {
Expand Down
86 changes: 0 additions & 86 deletions patches/@react-native-clipboard+clipboard+1.11.2.patch

This file was deleted.

9 changes: 5 additions & 4 deletions src/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from 'react-native';
import {Hyperlink} from './Controls';
import {
DialogFrame,
ContentDialog,
} from './Popups';
import {StylesContext} from './Styles';
import VersionInfo from './NativeVersionInfo'
Expand All @@ -19,18 +19,19 @@ function AboutPopup({show, close}: AboutPopupProps): JSX.Element {
const styles = React.useContext(StylesContext);

return (
<DialogFrame
<ContentDialog
show={show}
close={close}
title="About">
title="About"
defaultButtonIndex={0}>
<Text>Version: <Text style={{fontWeight: 'bold'}}>{VersionInfo.getConstants().appVersion}</Text></Text>
<View style={{flexDirection: 'row', gap: 4, marginBottom: 40}}>
<Text>Source code:</Text>
<Hyperlink
text='GitHub'
url='https://github.com/chrisglein/artificial-chat/'/>
</View>
</DialogFrame>
</ContentDialog>
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/AiResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
import { StylesContext } from './Styles';
import { FeedbackContext } from './Feedback';
import Clipboard from '@react-native-clipboard/clipboard';
import Markdown from 'react-native-markdown-display';
import Markdown from 'react-native-markdown-display-updated';

type AiImageResponseProps = {
imageUrls?: string[];
Expand Down
30 changes: 17 additions & 13 deletions src/Feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
TextInput,
View,
} from 'react-native';
import {DialogFrame} from './Popups';
import { ContentDialog } from './Popups';
import { StylesContext } from './Styles';
import VersionInfo from './NativeVersionInfo'

Expand All @@ -29,27 +29,31 @@ function FeedbackPopup({show, close, isPositive, response}: FeedbackPopupProps):
const [thisIsNotHelpful, setThisIsNotHelpful] = React.useState(false);

const buttons = [
<Button
accessibilityLabel="Submit feedback"
title="Submit feedback"
onPress={() => {
{
title: "Submit feedback",
onPress: () => {
const version = VersionInfo?.getConstants().appVersion;
if (isPositive) {
Linking.openURL(`https://github.com/chrisglein/artificial-chat/issues/new?template=feedback-positive.yaml&version=${version}&expected=${feedbackText}&response=${response}`);
} else {
Linking.openURL(`https://github.com/chrisglein/artificial-chat/issues/new?template=feedback-negative.yaml&version=${version}&expected=${feedbackText}&response=${response}`);
}
close();
}}/>
];
}
},
{
title: "Cancel",
onPress: () => { }
}
];

return (
<DialogFrame
<ContentDialog
show={show}
close={close}
title="Provide additional feedback"
buttons={buttons}>
<Text>{"Your feedback: " + (isPositive ? "👍" : "👎")}</Text>
titleIconStyle={{backgroundColor: isPositive ? 'green' : 'red'}}
title={(isPositive ? "👍" : "👎") + "Provide additional feedback"}
buttons={buttons}
defaultButtonIndex={1}>
<TextInput
multiline={true}
placeholder="What would the ideal answer have been?"
Expand Down Expand Up @@ -80,7 +84,7 @@ function FeedbackPopup({show, close, isPositive, response}: FeedbackPopupProps):
<Text>This isn't helpful</Text>
</View>
</View>)}
</DialogFrame>
</ContentDialog>
);
}

Expand Down
54 changes: 4 additions & 50 deletions src/Popups.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { PropsWithChildren } from 'react';
import React from 'react';
import type { PropsWithChildren } from 'react';
import {
ScrollView,
Text,
View,
} from 'react-native';
import {Popup} from 'react-native-windows';
import {StylesContext} from './Styles';
import { ButtonV1 as Button } from '@fluentui/react-native';
import {ContentDialog} from 'react-native-content-dialog';

type PopupsContextType = {
showAbout: boolean,
Expand All @@ -21,51 +20,6 @@ const PopupsContext = React.createContext<PopupsContextType>({
setShowSettings: () => {},
});

type DialogFrameType = PropsWithChildren<{
show: boolean,
close: () => void;
isLightDismissEnabled?: boolean,
title: string,
buttons?: JSX.Element[],
}>;
function DialogFrame({children, show, close, isLightDismissEnabled, title, buttons}: DialogFrameType) {
const styles = React.useContext(StylesContext);

const populatedButtons = buttons ?? [
<Button
appearance='primary'
onClick={() => {
close();
}}>OK</Button>];
const buttonList = populatedButtons.map((button, index) => <View key={index}>{button}</View>);

return (
<Popup
isOpen={show}
isLightDismissEnabled={isLightDismissEnabled ?? true}
onDismiss={() => close()}
style={{height: '100%'}}>
<View style={{justifyContent: 'center', height: '100%', padding: 24}}>
<View style={[styles.dialogBackground, {flexShrink: 1}]}>
<Text
accessibilityRole="header"
style={styles.dialogTitle}>
{title}
</Text>
<ScrollView style={[styles.dialogContentArea, {flexShrink: 1}]}>
{children}
</ScrollView>
</View>
<View style={styles.dialogButtonBackground}>
<View style={styles.dialogButtons}>
{buttonList}
</View>
</View>
</View>
</Popup>
)
}

type DialogSectionProps = PropsWithChildren<{
header: string,
}>;
Expand All @@ -81,4 +35,4 @@ function DialogSection({children, header}: DialogSectionProps): JSX.Element {
);
}

export { PopupsContext, DialogFrame, DialogSection }
export { PopupsContext, ContentDialog, DialogSection }
29 changes: 16 additions & 13 deletions src/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
View,
} from 'react-native';
import {
DialogFrame,
ContentDialog,
DialogSection,
} from './Popups';
import {StylesContext} from './Styles';
Expand Down Expand Up @@ -160,24 +160,27 @@ function SettingsPopup({show, close}: SettingsPopupProps): JSX.Element {
}

const buttons = [
<Button
onClick={() => {
{
title: "OK",
onPress: () => {
save();
}}>OK</Button>,
<Button
appearance='primary'
onClick={() => {
}
},
{
title: "Cancel",
onPress: () => {
cancel();
}}>Cancel</Button>
];
}
}
];

return (
<DialogFrame
<ContentDialog
show={show}
close={cancel}
isLightDismissEnabled={false}
title="OpenAI Settings"
buttons={buttons}>
buttons={buttons}
defaultButtonIndex={0}>
<View style={styles.dialogSectionsContainer}>
<DialogSection header="Chat">
<Text>AI Endpoint</Text>
Expand Down Expand Up @@ -248,7 +251,7 @@ function SettingsPopup({show, close}: SettingsPopupProps): JSX.Element {
value={delayForArtificialResponse.toString()}/>
</DialogSection>
</View>
</DialogFrame>
</ContentDialog>
);
}

Expand Down
5 changes: 1 addition & 4 deletions windows/artificialChat/artificialChat.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@
<AppxBundle>Always</AppxBundle>
<AppxBundlePlatforms>x86|x64</AppxBundlePlatforms>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<PackageCertificateThumbprint>910162D19999963017448FD45AA25C7B5FC5467F</PackageCertificateThumbprint>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<AppxPackageSigningEnabled>False</AppxPackageSigningEnabled>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
</PropertyGroup>
<ItemDefinitionGroup>
Expand Down Expand Up @@ -201,8 +200,6 @@
</Midl>
</ItemGroup>
<ItemGroup>
<None Include="artificialChat_TemporaryKey.pfx" />
<None Include="packages.config" />
<None Include="PropertySheet.props" />
<Text Include="readme.txt">
<DeploymentContent>false</DeploymentContent>
Expand Down
1 change: 0 additions & 1 deletion windows/artificialChat/artificialChat.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
<None Include="artificialChat_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<Text Include="readme.txt" />
Expand Down
Binary file not shown.
3 changes: 2 additions & 1 deletion windows/artificialChat/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Win2D.uwp" version="1.27.0-preview2" targetFramework="native"/>
<package id="Microsoft.Windows.CppWinRT" version="2.0.210312.4" targetFramework="native"/>
<package id="Microsoft.UI.Xaml" version="2.7.0" targetFramework="native"/>
<package id="Win2D.uwp" version="1.27.0-preview2" targetFramework="native"/>
</packages>
Loading

0 comments on commit dd90621

Please sign in to comment.