simonw / llm-claude-3

LLM plugin for interacting with the Claude 3 family of models
Apache License 2.0
223 stars 21 forks source link

Add stop sequences and prefill options to Claude 3 models #15

Open irthomasthomas opened 1 month ago

irthomasthomas commented 1 month ago

Files changed:

irthomasthomas commented 1 month ago

Notes:

Neither the prefill, not the stop sequence are included in the response.

llm -m claude-3.5-sonnet -o prefill "<PLAN>" "Surprise me with  a dbus shell function" -o stop_sequences '["</PLAN>"]'

1. Create a D-Bus shell function that does something unexpected or interesting
2. Include comments explaining what the function does
3. Make sure it's a valid shell function that can be used in a bash script
4. Add some error handling and parameter checking
{"stop_sequences": ["</PLAN>"], "prefill": "<PLAN>", "max_tokens": 8192, "temperature": 1.0}

If you use multiple stop_sequences, you can determine which was received from the response_json:

{"id": "msg_01MTH7xDebox1v8VPqH9nVoG", "content": [{"text": "\n1. Create a D-Bus shell function that does something unexpected or interesting\n2. Include comments explaining what the function does\n3. Make sure it's a valid shell function that can be used in a bash script\n4. Add some error handling and parameter checking\n", "type": "text"}], "model": "claude-3-5-sonnet-20240620", "role": "assistant", "stop_reason": "stop_sequence", "stop_sequence": "", "type": "message", "usage": {"input_tokens": 21, "output_tokens": 60}}