diff --git a/README.md b/README.md index eae048f..3952c0c 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,26 @@ -# @candlefinance/react-native-openai +
+ Candle / OpenAI +
-OpenAI API for React Native +
+ +
+ npm downloads + discord users online +
+ +
+ +

+ Lightweight OpenAI API for React Native (iOS only) +

## Installation ```sh -npm install @candlefinance/react-native-openai +yarn add @candlefinance/react-native-openai ``` ## Usage @@ -13,19 +28,30 @@ npm install @candlefinance/react-native-openai ```js import { multiply } from '@candlefinance/react-native-openai'; -// ... +const openAI = new OpenAI('API_KEY', 'ORG_ID'); + +const [result, setResult] = React.useState(''); + +React.useEffect(() => { + openAI.addListener('onMessageReceived', (event) => { + setResult((message) => message + event.payload.message); + }); -const result = await multiply(3, 7); + return () => { + openAI.removeListener('onMessageReceived'); + }; +}, []); + +// Create a new completion +openAI.stream(e.nativeEvent.text); ``` ## Contributing +Join our [Discord](https://discord.gg/qnAgjxhg6n) in #dev channel to chat and ask questions! + See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow. ## License MIT - ---- - -Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)