Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for the Claude Citations API #1

Open
simonw opened this issue Jan 25, 2025 · 1 comment
Open

Support for the Claude Citations API #1

simonw opened this issue Jan 25, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Jan 25, 2025

New API from Claude. Announcement. API docs. My blog post.

This is an interesting implementation challenge with two parts: first we need a way to attach documents (text, PDF or custom content JSON) to a prompt - the attachments mechanism should mostly handle this, but we need a way to flag "enable citations against this attachment".

Secondly, we need to store the citation information that comes back from the model - spans of text that have citation information attached to them. I started a separate issue in LLM core about that here:

@simonw simonw added the enhancement New feature or request label Jan 25, 2025
@simonw
Copy link
Owner Author

simonw commented Jan 25, 2025

The easiest way to handle the attachments challenge might be to register fake content types - so you can do this:

llm -m claude-3.5-haiku \
  --at doc.pdf citations/pdf \
  --at doc.txt citations/text \
  "prompt goes here"

This is a tiny bit ugly - I always have trouble remembering if the filename or the content type comes first when using --at - but it would solve the problem neatly within our existing CLI design.

Another option would be to use a model option:

llm -m claude-3.5-haiku \
  -a doc.pdf -a doc.txt \
  -o citations 1 \
  "prompt goes here"

Here' the citations 1 option means "treat any PDF or TXT attachments as citation sources".

Might even be worth supporting both of these options - so really all -o citations 1 does is treat any PDFs as citations/pdf and any text documents as citations/text.

simonw added a commit that referenced this issue Jan 31, 2025
Also refs citations feature in #1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant