This serverless function can be used to automatically add annotations to Omnivore articles when a specific label (say, "summarize") is added to them. It uses Omnivore's API and webhooks as well as OpenAI's chat completions API.
See this article for detailed instructions: https://blog.omnivore.app/p/using-chatgpt-to-automatically-add
For most convenience, deployment using Vercel is recommended. Theoretically it could work on other serverless functions providers but I have only tested it with Vercel. Vercel offers a free hobby plan that should cover basic usage of this function.
Deploy the example using Vercel:
When adding the repo to Vercel, set the environment variables to make the APIs work and allow customization.
OMNIVORE_API_KEY
(required): omnivore.app --> API KeyOPENAI_API_KEY
(required): platform.openai.com --> API KeysOMNIVORE_ANNOTATE_LABEL
(optional): set this to the name of label you want to use to trigger processing. Example: "Summarize" (without quotes). Use colons to seperate label variants e.g. naming a label "Summarize:outline" will match the environment variable value "Summarize". Not required if you use thePAGE_CREATED
Omnivore webhook event type which process every article added to Omnivore.OPENAI_PROMPT
(optional): the instruction that's send to OpenAI's GPT model in addition to the article content if no label description has been entered. Uses the label description from Omnivore if available.OPENAI_MODEL
(optional): the model name to use. Defaults to "gpt-4o-mini" (without quotes).OPENAI_SETTINGS
(optional, advanced): additional request parameters send when generating the chat completion. Use JSON. Example:{"temperature": 0, "seed": 1234}
.
Deploy and copy the URL of your deployment.
In Omnivore add a new webhook and set the URL to the deployed Vercel function URL from the step above and add the path /api/annotate
to it. Example: https://projectname.vercel.app/api/annotate
If you have defined a label name to listen for in the step above, then select LABEL_ADDED
as event type.
If you want the function to process every article you add to Omnivore, then instead select PAGE_CREATED
.
Now either add a new article to Omnivore or your label to an existing article. Within less than a minute, the response of the model's completion should appear in the notebook of the article.
Check the runtime logs if you encounter issues. Check your API keys and never share them publicly.
git clone https://github.com/jancbeck/omnivore-ai-annotations
Install the Vercel CLI and dependencies:
npm i -g vercel
npm i
Then run the app at the root of the repository:
vercel dev
- POST /api/annotate: Annotates an article with an AI generated response.
- Local Testing: Vercel offers a local development environment using the
vercel dev
command. Run this command in your project directory. - Postman Setup: Open Postman and create a new request. Set the request type to whatever your function expects (likely POST or GET).
- Request URL: Use
http://localhost:3000/api/annotate
as the URL, replacing3000
with whatever portvercel dev
is using. - Send Request: Click "Send" in Postman to trigger the function.
Observe the response and terminal output for logging information.
- 2024-08-24: allow prompts from label description and label variants
- 2023-09-28: inital release
MIT License.
- use individual article highlights to allow "chatting" within Omnivore (e.g. highlight text, add note "explain" and GPT will generate the highlight with a reply based on the prompt and context.
- instruct the model to highlight the article for you via function calls. Perhaps using the article notebook as an instruction input.