
Building the input prompt
TurboSeek’s core interaction is a text field where the user can enter a question:
<input> and control it using some new React state:
JSX
- Use the Exa API to fetch sources from the web, and
- Pass the text from the sources to an LLM to summarize and generate an answer
/getSources :
JSX
/getSources :

Getting web sources with Exa
To create our API route, we’ll make a newapp/api/getSources/route.jsfile:
JSX
JSX
.env.local:
JSX
JSX

JSX
Fetching the content from each source
Now that our React app has the sources, we can send them to a second endpoint where we’ll use Together to summarize them into our final answer. Let’s add that second request to a new endpoint we’ll call/api/getAnswer, passing along the question and sources in the request body:
JSX
/api/getAnswer. Let’s create the second route!
Make a newapp/api/getAnswer/route.jsfile:
JSX
Summarizing the sources
Now that we have the text content from each source, we can pass it along with a prompt to Together to get a final answer. Let’s install Together’s node SDK:JSX
JSX
Displaying the answer in the UI
Back in our page, let’s create some new React state calledanswer to store the text from our LLM:
JSX
ChatCompletionStream helper from Together’s SDK to read the stream and update our answer state with each new chunk:
JSX
JSX
getAnswer endpoint responds with the first chunk, we’ll see the answer text start streaming into our UI!
The core features of our app are working great.