0.4.2 • Published 5 months ago

koah-react-native v0.4.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

Prerequisites

Before you begin, make sure you have:

Installation

Expo Apps

npx expo install koah-react-native expo-file-system expo-application expo-device

React Native Apps

yarn add koah-react-native @react-native-async-storage/async-storage react-native-device-info react-native-webview
# or
npm i -s koah-react-native @react-native-async-storage/async-storage react-native-device-info react-native-webview

React Native Web and macOS

If you are using React Native Web or React Native macOS, do not use the expo-file-system package since the Web and macOS targets aren't supported. Instead, use the @react-native-async-storage/async-storage package instead.

Configuration

Provider & Browser Modal

Initialize the SDK by wrapping your parent component with the KoahProvider component and adding the KoahBrowserModal component as a top-level component.

import { KoahProvider, KoahBrowserModal } from "koah-react-native";

export default function App() {
  return (
    <KoahProvider publisherId="YOUR_PUBLISHER_ID">
      <YourApp />

      {/* Top-level component that will render the browser modal when a user clicks on an ad */}
      <KoahBrowserModal />
    </KoahProvider>
  );
}

Render the Ad

To render the ad, surround the component used to display the LLM generated response with the KoahTextAdComponent component. This component will render the ad in the UI and handle the ad click event.

<KoahTextAdComponent
  key={index}
  adFormat="suffix"
  question={messages[index - 1]?.content}
  response={msg.content}
  isResponseReady={!isStreaming && msg.content.length > 0}
  shouldGenerateAd={index !== 0}
  didReceiveAd={ad => { console.log(ad) }}
  styles={{ adContainer: { backgroundColor: "red" }, adText: { color: "white" } }}
>
  <LLMResponseBubble />
</KoahTextAdComponent>

Demo Application

There are 2 demo applications available in this repository: one for Expo and one for React Native applications. Each demo application provides a comprehensive example of how to integrate and use the KOAH React Native SDK in different environments.

For more details on how to set up and run these demo applications, please refer to their respective README files:

Getting a Publisher ID

To use the Koah LLM Ad Network SDK, you'll need a publisher ID. Visit app.koah.ai to create an account and obtain your publisher ID.

Workflow

Your development workflow will most likely be a 2 step process.

  1. Make changes to the SDK in src
  2. See changes in the demo app

To make sure the demo app is aware of the changes you made to the SDK, follow these steps:

  1. Start npm run dev-watch in the root of the repository.

    • This watches for changes to the SDK and automatically push them to the demo app using yalc.
  2. Make changes to the SDK

    • As you mutate and save the files in src, yalc will automatically push the changes to the demo app, causing it to reload.
  3. See the changes in the demo application.

  4. Repeat

License

This project is licensed under the Apache 2.0 - see the LICENSE file for details.

Support

0.4.2

5 months ago

0.4.1

5 months ago

0.4.0

5 months ago

0.3.8

5 months ago

0.3.7

5 months ago

0.3.6

5 months ago

0.3.5

5 months ago

0.3.4

5 months ago

0.3.3

6 months ago

0.3.2

6 months ago

0.3.1

6 months ago

0.3.0

6 months ago

0.2.5

6 months ago

0.2.4

6 months ago

0.2.3

7 months ago

0.2.2

7 months ago

0.2.1

7 months ago

0.2.0

7 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.0

8 months ago

0.1.1

8 months ago