This repository serves as an example usage of the open-source React Native package called react-native-gen-ui
. The package facilitates the integration of AI chat capabilities into React Native applications. In this example, we demonstrate how to effectively utilize the tools provided by react-native-gen-ui
to obtain the user's location and fetch weather information based on that location.
- Integration of AI chat functionality
- Retrieval of user's location
- Fetching weather information based on the user's location
To run the example application:
- Clone this repository to your local machine.
- Navigate to the root directory of the cloned repository.
- Install dependencies using
npm install
oryarn install
. - Ensure you have the necessary environment variables set up, including
EXPO_PUBLIC_OPENAI_API_KEY
andEXPO_PUBLIC_OPENAI_MODEL
. - Run the application using
expo start
.
The main code of the application can be found in the App.js
file. Here's a brief overview of its functionality:
- Initialization of
OpenAI
instance with appropriate API key and model. - Integration of chat functionality using
useChat
hook provided byreact-native-gen-ui
. - Implementation of tools for obtaining location and fetching weather data.
- Rendering of chat interface with message components and user input field.
This example application relies on the following dependencies:
react-native-gen-ui
: Open-source React Native package for integrating AI chat functionality.expo-location
: For accessing device location information.zod
: For parameter validation in tool implementations.- Other dependencies for UI components and utilities.
- Original
react-native-gen-ui
Repository: Link to the original library package repository. react-native-gen-ui
on npm: npm package link forreact-native-gen-ui
.
This example application is licensed under the MIT License.
Feel free to explore the code and adapt it to suit your needs! If you encounter any issues or have suggestions for improvements, please don't hesitate to open an issue or submit a pull request.