"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { AiOutlineSearch } from "react-icons/ai"; const PresearchPrompt = "Please extract search terms from the user’s question. The search terms is a concise sentence, which will be searched on Google to obtain relevant information to answer the user’s question, too generalized search terms doesn’t help. Please provide no more than two search terms. Please provide the most relevant search terms only, the search terms should directly correspond to the user’s question. Please separate different search items with commas, with no quote marks. The user’s question is:" export default function HomeSearch() { const router = useRouter(); const [input, setInput] = useState(""); const [randomSearchLoading, setRandomSearchLoading] = useState(false); function handleSubmit(e) { e.preventDefault(); if (!input.trim()) return; router.push(`/search/web?searchTerm=${input}`); } async function randomSearch() { setRandomSearchLoading(true); // const response = await fetch("https://random-word-api.herokuapp.com/word") .then((res) => res.json()) if (!response) return; router.push(`/search/web?searchTerm=${response}`); setRandomSearchLoading(false); } return ( <>
setInput(e.target.value)} value={input} />
); }