Set up AI chatbot in my React Native app using Hugging Face free inference API.
Requirements:
1. Use Hugging Face model endpoint:
- Example model: "HuggingFaceH4/zephyr-7b-beta" (free LLM for chat).
- API endpoint: https://api-inference.huggingface.co/models/HuggingFaceH4/zephyr-7b-beta
2. Authentication:
- Use my Hugging Face free API key (from https://huggingface.co/settings/tokens).
- Store key in a .env file, load it with react-native-dotenv.
3. Chat Screen:
- User types a message.
- App sends POST request to Hugging Face endpoint with this format:
{
"inputs": "Hello AI, how are you?",
"parameters": {"max_new_tokens": 200}
}
- Display AI response in a chat bubble (real-time chat style).
4. Error Handling:
- If API limit is reached, show "Server busy, try again later".
- Make sure app does not crash.
5. UI:
- Simple chat screen with input box at bottom, messages scroll up.
- Use React Native Gifted Chat for smooth chat UI…