feat: implement AI chat with vector search and random loading messages
Major Features: - ✅ AI chat with Azure OpenAI GPT-4o integration - ✅ Vector search across Bible versions (ASV English, RVA 1909 Spanish) - ✅ Multi-language support with automatic English fallback - ✅ Bible version citations in responses [ASV] [RVA 1909] - ✅ Random Bible-themed loading messages (5 variants) - ✅ Safe build script with memory guardrails - ✅ 8GB swap memory for build safety - ✅ Stripe donation integration (multiple payment methods) AI Chat Improvements: - Implement vector search with 1536-dim embeddings (Azure text-embedding-ada-002) - Search all Bible versions in user's language, fallback to English - Cite Bible versions properly in AI responses - Add 5 random loading messages: "Searching the Scriptures...", etc. - Fix Ollama conflict (disabled to use Azure OpenAI exclusively) - Optimize hybrid search queries for actual table schema Build & Infrastructure: - Create safe-build.sh script with memory monitoring (prevents server crashes) - Add 8GB swap memory for emergency relief - Document build process in BUILD_GUIDE.md - Set Node.js memory limits (4GB max during builds) Database: - Clean up 115 old vector tables with wrong dimensions - Keep only 2 tables with correct 1536-dim embeddings - Add Stripe schema for donations and subscriptions Documentation: - AI_CHAT_FINAL_STATUS.md - Complete implementation status - AI_CHAT_IMPLEMENTATION_COMPLETE.md - Technical details - BUILD_GUIDE.md - Safe building guide with guardrails - CHAT_LOADING_MESSAGES.md - Loading messages implementation - STRIPE_IMPLEMENTATION_COMPLETE.md - Stripe integration docs - STRIPE_SETUP_GUIDE.md - Stripe configuration guide 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
35
lib/stripe.ts
Normal file
35
lib/stripe.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { loadStripe, Stripe as StripeClient } from '@stripe/stripe-js'
|
||||
|
||||
// Initialize Stripe on the client side
|
||||
let stripePromise: Promise<StripeClient | null>
|
||||
export const getStripe = () => {
|
||||
if (!stripePromise) {
|
||||
stripePromise = loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY!)
|
||||
}
|
||||
return stripePromise
|
||||
}
|
||||
|
||||
// Donation amount presets (in USD)
|
||||
export const DONATION_PRESETS = [
|
||||
{ amount: 5, label: '$5' },
|
||||
{ amount: 10, label: '$10' },
|
||||
{ amount: 25, label: '$25' },
|
||||
{ amount: 50, label: '$50' },
|
||||
{ amount: 100, label: '$100' },
|
||||
{ amount: 250, label: '$250' },
|
||||
]
|
||||
|
||||
// Helper function to format amount in cents to dollars
|
||||
export const formatAmount = (amountInCents: number, currency: string = 'usd'): string => {
|
||||
const formatter = new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency: currency.toUpperCase(),
|
||||
minimumFractionDigits: 2,
|
||||
})
|
||||
return formatter.format(amountInCents / 100)
|
||||
}
|
||||
|
||||
// Helper function to convert dollars to cents
|
||||
export const dollarsToCents = (dollars: number): number => {
|
||||
return Math.round(dollars * 100)
|
||||
}
|
||||
Reference in New Issue
Block a user