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 Claude's prefill feature #2

Closed
simonw opened this issue Jan 31, 2025 · 3 comments · Fixed by #3
Closed

Support Claude's prefill feature #2

simonw opened this issue Jan 31, 2025 · 3 comments · Fixed by #3
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Jan 31, 2025

https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/prefill-claudes-response

@simonw simonw added the enhancement New feature or request label Jan 31, 2025
simonw added a commit that referenced this issue Jan 31, 2025
@simonw
Copy link
Owner Author

simonw commented Jan 31, 2025

Documented in the new model options section (partly maintained by Cog): https://github.com/simonw/llm-anthropic/blob/ffd23912afaa0ba7674c6f0e16229bb1eeced06a/README.md#model-options

simonw added a commit that referenced this issue Jan 31, 2025
Also refs citations feature in #1
simonw added a commit that referenced this issue Jan 31, 2025
@simonw simonw linked a pull request Jan 31, 2025 that will close this issue
@simonw simonw closed this as completed in #3 Jan 31, 2025
@simonw simonw closed this as completed in 04df4ee Jan 31, 2025
simonw referenced this issue Jan 31, 2025
@simonw
Copy link
Owner Author

simonw commented Jan 31, 2025

Example usage:

llm -m claude-3.5-sonnet -o prefill '{' 'Fun data about pelicans'
{
    "Pelican Fun Facts": [
        {
            "Size": "One of the largest flying birds, with wingspans up to 10 feet (3 meters)",
            "Pouch": "Can hold up to 3 gallons (11 liters) of water - more than 3 times what their stomach can hold",
            "Diet": [
                "Can eat up to 4 pounds (1.8 kg) of fish per day",
                "Don't store fish in their pouch - it's just used as a fishing net"
            ],
            "Cool Features": [
                "Can dive from 60+ feet high to catch fish",
                "Have internal air sacs that help them float and protect them during dives",
                "Can live up to 25-30 years in the wild",
                "All young pelicans are born blind"
            ],
            "Social Behavior": "Often fish cooperatively in groups, herding fish into shallow water",
            "Interesting Tidbit": "Baby pelicans will eat up to 150 pounds of fish before they can fly"
        }
    ]
}

@simonw
Copy link
Owner Author

simonw commented Jan 31, 2025

More complex example (from the README):

llm -m claude-3.5-haiku 'Short python function describing a pelican' \
  -o prefill '```python' \
  -o hide_prefill true \
  -o stop_sequences '```'
def describe_pelican():
    """
    Returns a brief description of a pelican's characteristics.
    
    Returns:
        str: A descriptive string about pelicans
    """
    return "A large seabird with a distinctive long, pouched bill, known for diving into water to catch fish and often found along coastal areas."

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

Successfully merging a pull request may close this issue.

1 participant