-
Notifications
You must be signed in to change notification settings - Fork 37
Add citations #58
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
base: main
Are you sure you want to change the base?
Add citations #58
Conversation
Found 1 changed notebook. Review the changes at https://app.gitnotebooks.com/AnswerDotAI/claudette/pull/58 |
Thanks @galopyz for this PR! its coming together nicely 🤓 How about we work on getting the response to look better especially when it does a lot of citations? If you look at Simon Willison's blog post on it, he has a little section on rendering these citations: https://simonwillison.net/2025/Jan/24/anthropics-new-citations-api/#rendering-the-citations. How about you see if you could add something similar? |
Hi, @ncoop57 Let me know if anything needs to be changed. And should I run the whole notebooks? To make sure I didn't break anything? I tried my best to follow coding style and not break anything. |
@galopyz thanks for the awesome PR!! I fixed the formatting a bit for the citations and a slight bug in the contents function. @jph00 want your thoughts on how these citations are now handled in claudette. Is automatically formatting them with inline citations for the response okay or do you think we need to handle it a different way? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how I feel about changing contents()
like this -- it feels a bit too much like a fixed format. E.g. I suspect I'd prefer to use markdown footnotes instead -- different people will have different preferences for how citations are handled. Any thoughts on how it could be made more flexible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#| hide
from anthropic.types import Model
Note that imports and non-import statements must not be mixed in a single cell. So this cell should be split in two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah @austinvhuang this is actually originally your code I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude is capable of providing detailed citations when answering questions about documents, helping you track and verify information sources in responses.
Claude expects an documents to have the following structure
"a document"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
llms_ctx = xget("https://claudette.answer.ai/llms-ctx.txt").text[:2_048]
doc = mk_doc(llms_ctx, title="Claudette LLM Context", context="This is a trustworthy document.", citation=True)
doc
Let's trim this output - it's too long for good docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#| exports
Each exported cell should have an example of use with it, and also prose explaining it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c = Chat(model)
q = "What is Claudette?"
r = c([doc, q])
r
This output is a bit too lengthy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#| exports
def cite_msgs(msg) -> str:
This function name should probably have "markdown" or "md" somewhere in it -- it's specifically a function to create markdown output.
@jph00 We can also add the citation option to How does it sound? Am I providing too many options for users when they may not need them? Or should I let users take full control of the response message? |
Hi, @ncoop57
Adding an example to use citations in claudette as stated in #53.
I am still new to git, claudette, and open source projects, so I might have messed up something.
I only provided an example to use plain text. PDF takes many tokens, but if we want to have a PDF example, I could find a small one and show how it can be used.
When using citations, Claude responds with alternating text and citation blocks. The response doesn't look pretty because only the first text block is shown without any citation blocks.
Please let me know if I need to make any corrections.
Thanks.