An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
Update .env.local.example with improved documentation and structure
Yoshiki Miuraf72eb345361a
diff --git a/.env.local.example b/.env.local.exampleindex ce0b399d..175ab933 100644--- a/.env.local.example+++ b/.env.local.example@@ -1,76 +1,84 @@-# Required-# The settings below are essential for the basic functionality of the system.+###############################################################################+# Required Configuration+# These settings are essential for the basic functionality of the system.+################################################################################ OpenAI API key retrieved here: https://platform.openai.com/api-keysOPENAI_API_KEY=[YOUR_OPENAI_API_KEY]-# Tavily API Key retrieved here: https://app.tavily.com/home-TAVILY_API_KEY=[YOUR_TAVILY_API_KEY]+# Search Configuration+TAVILY_API_KEY=[YOUR_TAVILY_API_KEY] # Get your API key at: https://app.tavily.com/home-# Redis Configuration-USE_LOCAL_REDIS=false-LOCAL_REDIS_URL=redis://localhost:6379 # or redis://redis:6379 if you're using docker compose+###############################################################################+# Optional Features+# Enable these features by uncommenting and configuring the settings below+###############################################################################-# Upstash Redis URL and Token retrieved here: https://console.upstash.com/redis-UPSTASH_REDIS_REST_URL=[YOUR_UPSTASH_REDIS_REST_URL]-UPSTASH_REDIS_REST_TOKEN=[YOUR_UPSTASH_REDIS_REST_TOKEN]+#------------------------------------------------------------------------------+# Chat History Storage+# Enable persistent chat history across sessions+#------------------------------------------------------------------------------+# NEXT_PUBLIC_ENABLE_SAVE_CHAT_HISTORY=true # enable chat history storage-# SearXNG Configuration-SEARXNG_API_URL=http://localhost:8080 # Replace with your local SearXNG API URL or docker http://searxng:8080-SEARCH_API=tavily # use searxng, tavily or exa-SEARXNG_SECRET="" # generate a secret key e.g. openssl rand -base64 32-SEARXNG_PORT=8080 # default port-SEARXNG_BIND_ADDRESS=0.0.0.0 # default address-SEARXNG_IMAGE_PROXY=true # enable image proxy-SEARXNG_LIMITER=false # can be enabled to limit the number of requests per IP address-SEARXNG_DEFAULT_DEPTH=basic # Set to 'basic' or 'advanced', only affects SearXNG searches-SEARXNG_MAX_RESULTS=50 # Maximum number of results to return from SearXNG-SEARXNG_ENGINES=google,bing,duckduckgo,wikipedia # Search engines to use-SEARXNG_TIME_RANGE=None # Time range for search results: day, week, month, year, or None (for all time)-SEARXNG_SAFESEARCH=0 # Safe search setting: 0 (off), 1 (moderate), 2 (strict)+# Redis Configuration (Required if NEXT_PUBLIC_ENABLE_SAVE_CHAT_HISTORY=true)+# Choose between local Redis or Upstash Redis+# OPTION 1: Local Redis+# USE_LOCAL_REDIS=false # use local Redis+# LOCAL_REDIS_URL=redis://localhost:6379 # local Redis URL (if USE_LOCAL_REDIS=true)-#NEXT_PUBLIC_BASE_URL=http://localhost:3000--# Optional-# The settings below can be used optionally as needed.+# OPTION 2: Upstash Redis (Recommended for production)+# UPSTASH_REDIS_REST_URL=[YOUR_UPSTASH_REDIS_REST_URL] # Upstash Redis REST URL (if USE_LOCAL_REDIS=false)+# UPSTASH_REDIS_REST_TOKEN=[YOUR_UPSTASH_REDIS_REST_TOKEN] # Upstash Redis REST Token (if USE_LOCAL_REDIS=false)+#------------------------------------------------------------------------------# Additional AI Providers-# Uncomment and configure the API keys below to enable other AI providers.-# Each provider requires its own API key and configuration.--# Google Generative AI API key retrieved here: https://aistudio.google.com/app/apikey+# Enable alternative AI models by configuring these providers+#------------------------------------------------------------------------------+# Google Generative AI# GOOGLE_GENERATIVE_AI_API_KEY=[YOUR_GOOGLE_GENERATIVE_AI_API_KEY]-# Anthropic API key retrieved here: https://console.anthropic.com/settings/keys+# Anthropic (Claude)# ANTHROPIC_API_KEY=[YOUR_ANTHROPIC_API_KEY]-# Groq API key retrieved here: https://console.groq.com/keys+# Groq# GROQ_API_KEY=[YOUR_GROQ_API_KEY]-# If you want to use Ollama, set the base URL here.+# Ollama (Local AI)# OLLAMA_BASE_URL=http://localhost:11434-# Azure OpenAI API key retrieved here: https://oai.azure.com/resource/deployments/+# Azure OpenAI# AZURE_API_KEY=-# The resource name is used in the assembled URL: https://{resourceName}.openai.azure.com/openai/deployments/{modelId}{path}.# AZURE_RESOURCE_NAME=-# The deployment name is the name of the Azure OpenAI deployment you want to use.# NEXT_PUBLIC_AZURE_DEPLOYMENT_NAME=-# OpenAI Compatible Model-# Note: Only models with tool-use capabilities can be used-# NEXT_PUBLIC_OPENAI_COMPATIBLE_MODEL=[YOUR_OPENAI_COMPATIBLE_MODEL]-# OPENAI_COMPATIBLE_API_KEY=[YOUR_OPENAI_COMPATIBLE_API_KEY]-# OPENAI_COMPATIBLE_API_BASE_URL=[YOUR_OPENAI_COMPATIBLE_API_BASE_URL]--# enable the share feature-# If you enable this feature, separate account management implementation is required.-# ENABLE_SHARE=true--# enable the video search tool-# Serper API Key retrieved here: https://serper.dev/api-key-# SERPER_API_KEY=[YOUR_SERPER_API_KEY]--# If you want to use Jina instead of Tavily for retrieve tool, enable the following variables.-# JINA_API_KEY=[YOUR_JINA_API_KEY]\ No newline at end of file+# NEXT_PUBLIC_OPENAI_COMPATIBLE_MODEL=+# OPENAI_COMPATIBLE_API_KEY=+# OPENAI_COMPATIBLE_API_BASE_URL=++#------------------------------------------------------------------------------+# Alternative Search Providers+# Configure different search backends (default: Tavily)+#------------------------------------------------------------------------------+# SEARCH_API=searxng # Available options: tavily, searxng, exa++# SearXNG Configuration (Required if SEARCH_API=searxng)+# SEARXNG_API_URL=http://localhost:8080+# SEARXNG_SECRET="" # generate a secret key e.g. openssl rand -base64 32+# SEARXNG_PORT=8080+# SEARXNG_BIND_ADDRESS=0.0.0.0+# SEARXNG_IMAGE_PROXY=true+# SEARXNG_LIMITER=false+# SEARXNG_DEFAULT_DEPTH=basic+# SEARXNG_MAX_RESULTS=50+# SEARXNG_ENGINES=google,bing,duckduckgo,wikipedia+# SEARXNG_TIME_RANGE=None+# SEARXNG_SAFESEARCH=0++#------------------------------------------------------------------------------+# Additional Features+# Enable extra functionality as needed+#------------------------------------------------------------------------------+# NEXT_PUBLIC_ENABLE_SHARE=true # Enable sharing of chat conversations+# SERPER_API_KEY=[YOUR_SERPER_API_KEY] # Enable video search capability+# JINA_API_KEY=[YOUR_JINA_API_KEY] # Alternative to Tavily for retrieve tool\ No newline at end of filediff --git a/app/layout.tsx b/app/layout.tsxindex d1b3caf1..be4d8842 100644--- a/app/layout.tsx+++ b/app/layout.tsx@@ -1,12 +1,12 @@-import type { Metadata, Viewport } from 'next'-import { Inter as FontSans } from 'next/font/google'-import './globals.css'-import { cn } from '@/lib/utils'-import { ThemeProvider } from '@/components/theme-provider'-import Header from '@/components/header'import Footer from '@/components/footer'+import Header from '@/components/header'import { Sidebar } from '@/components/sidebar'+import { ThemeProvider } from '@/components/theme-provider'import { Toaster } from '@/components/ui/sonner'+import { cn } from '@/lib/utils'+import type { Metadata, Viewport } from 'next'+import { Inter as FontSans } from 'next/font/google'+import './globals.css'const fontSans = FontSans({subsets: ['latin'],@@ -45,6 +45,8 @@ export default function RootLayout({}: Readonly<{children: React.ReactNode}>) {+ const enableSaveChatHistory =+ process.env.NEXT_PUBLIC_ENABLE_SAVE_CHAT_HISTORY === 'true'return (<html lang="en" suppressHydrationWarning><body className={cn('font-sans antialiased', fontSans.variable)}>@@ -56,7 +58,7 @@ export default function RootLayout({><Header />{children}- <Sidebar />+ {enableSaveChatHistory && <Sidebar />}<Footer /><Toaster /></ThemeProvider>diff --git a/components/answer-section.tsx b/components/answer-section.tsxindex 75740826..3aa22193 100644--- a/components/answer-section.tsx+++ b/components/answer-section.tsx@@ -1,10 +1,10 @@'use client'-import { BotMessage } from './message'-import { DefaultSkeleton } from './default-skeleton'-import { CollapsibleMessage } from './collapsible-message'import { Text } from 'lucide-react'import { ChatShare } from './chat-share'+import { CollapsibleMessage } from './collapsible-message'+import { DefaultSkeleton } from './default-skeleton'+import { BotMessage } from './message'export type AnswerSectionProps = {content: string@@ -30,7 +30,7 @@ export function AnswerSection({const message = content ? (<div className="flex flex-col gap-1"><BotMessage message={content} />- {!enableShare && chatId && (+ {enableShare && chatId && (<ChatShare chatId={chatId} className="self-end" />)}</div>diff --git a/components/history-container.tsx b/components/history-container.tsxindex 16488e53..7414c530 100644--- a/components/history-container.tsx+++ b/components/history-container.tsx@@ -9,6 +9,12 @@ type HistoryContainerProps = {const HistoryContainer: React.FC<HistoryContainerProps> = async ({location}) => {+ const enableSaveChatHistory =+ process.env.NEXT_PUBLIC_ENABLE_SAVE_CHAT_HISTORY === 'true'+ if (!enableSaveChatHistory) {+ return null+ }+return (<divclassName={location === 'header' ? 'block sm:hidden' : 'hidden sm:block'}