Exa-powered Writing Assistant
Click here to try the Exa-powered Writing Assistant
Click here to see the relevant GitHub repo and hosting instructions
What this doc covers
- Live demo link for hands-on experience (above!)
- Overview of a real-time writing assistant using Exa and Claude
- Breakdown of Exa query prompt engineering and generative AI system prompt
Demo overview
High-level overview
This demo showcases a real-time writing assistant that uses Exa’s search capabilities to provide relevant information and citations as a user writes. The system combines Exa’s neural search with Anthropic’s Claude AI model to generate contextually appropriate content and citations.
Conceptual block diagram of how the writing assistant works
Exa prompting and query style
The Exa search is performed using a unique query style that appends the user’s input with a prompt for continuation. Here’s the relevant code snippet:
Key aspects of this query style:
- Continuation prompt: The crucial post-pend “A helpful source to read so you can continue writing the above:“
- This prompt is designed to find sources that can logically continue the user’s writing when passed to an LLM to generate content.
- It leverages Exa’s ability to understand context and find semantically relevant results.
- By framing the query as a request for continuation, it aligns with how people naturally share helpful links.
- Length limitation: It caps the query at 1000 characters to maintain relevance and continue writing just based on the last section of the text.
Note this prompt is not a hard and fast rule for this use-case - we encourage experimentation with query styles to get the best results for your specific use case. For instance, you could further constrain down to just research papers.
Prompting Claude with Exa results
The Claude AI model is prompted with a carefully crafted system message and passed the above formatted Exa results. Here is an example system prompt:
This prompt ensures that:
- Claude will only do completions, not parrot back the user query like in a typical chat based scenario. Note the inclusion of multiple examples that demonstrate Claude should not reply back with the stub even if there are errors, like spelling or grammar, in the input text (which we found to be a common issue)
- We define the citation style and formatting. We also tell the bot went to collapse authors into ‘et al’ style citations, as some webpages have many authors
Once again, experimenting with this prompt is crucial to getting best results for your particular use case.
Conclusion
This demo illustrates the power of combining Exa’s advanced search capabilities with generative AI to create a writing assistant. By leveraging Exa’s neural search and content retrieval features, the system can provide relevant, up-to-date information to any AI model, resulting in contextually appropriate content generation with citations.
This approach showcases how Exa can be integrated into AI-powered applications to enhance user experiences and productivity.