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

(Anthropic) Directive not being sent #276

Closed
jwr opened this issue Apr 3, 2024 · 4 comments
Closed

(Anthropic) Directive not being sent #276

jwr opened this issue Apr 3, 2024 · 4 comments

Comments

@jwr
Copy link

jwr commented Apr 3, 2024

I think I found out why my directives weren't having much effect with Anthropic: it seems they are not in fact appended to the system message. I've spent an hour looking at the code and couldn't find where the directive gets appended. The "Dry run" options ("I"/"J") do not show what actually gets sent, but append the directive to the system message themselves. And the Anthropic code doesn't seem to do anything with the directive.

If I may suggest: the directive needs to be prepended to the first user message with Anthropic, or we should have an option. Appending to the system message is not a good general solution.

This is related to #249

karthink added a commit that referenced this issue Apr 3, 2024
* gptel.el (gptel-request): let-bind `gptel--system-message`
correctly in `gptel-request`.  The Anthropic API requires the
system message to be attached to the query differently from the
others, causing the let-bindings in `gptel-request` to not work as
expected. (#276)
@karthink
Copy link
Owner

karthink commented Apr 3, 2024

Fixed, thank you.

I've spent an hour looking at the code and couldn't find where the directive gets appended.

Sorry for the frustration, the Anthropic API is different enough from OpenAI's that I made an error when unifying the interfaces. For future reference, it's better to run (setq gptel-log-level 'info) and look at the *gptel-log* buffer, since that's a record of exactly what was sent/received. The dry-run options (I/J) involve a bit of simulation.

@karthink
Copy link
Owner

karthink commented Apr 3, 2024

If I may suggest: the directive needs to be prepended to the first user message with Anthropic, or we should have an option. Appending to the system message is not a good general solution.

Why do you think they should be prepended?

@jwr
Copy link
Author

jwr commented Apr 3, 2024

Sorry for the frustration

Don't be sorry, I'm happy to have helped solve a real issue 🙂 The outcome is good for everyone!

If I may suggest: the directive needs to be prepended to the first user message with Anthropic, or we should have an option. Appending to the system message is not a good general solution.
Why do you think they should be prepended?

According to Anthropic documentation:

"in general, you can think about system prompts as a space to provide guidance about the overall interaction with Claude, and the user turn as part of the interaction itself, or when you have only a one-off task you want to accomplish"

That's how I work: system prompt defines the context, while the user prompt sends the specific directive and the text to be operated on.

This isn't clear-cut and is definitely up for debate, but I think we should at least have the option.

@karthink
Copy link
Owner

karthink commented Apr 3, 2024

"in general, you can think about system prompts as a space to provide guidance about the overall interaction with Claude, and the user turn as part of the interaction itself, or when you have only a one-off task you want to accomplish"

That's how I work: system prompt defines the context, while the user prompt sends the specific directive and the text to be operated on.

I understand this, but there's no mention of the difference between appending or prepending the additional directive to the system prompt. The additional directive is an idea we made up -- in both cases it is included with the full system prompt (and not with the "user turn")

My apologies, I misread your point entirely.

If I may suggest: the directive needs to be prepended to the first user message with Anthropic, or we should have an option. Appending to the system message is not a good general solution.

I read this as "needs to be prepended to the system prompt" (as opposed to "appended to the system prompt").

@karthink karthink closed this as completed Apr 3, 2024
karthink added a commit that referenced this issue Apr 4, 2024
* gptel.el (gptel--inspect-query): `gptel--inspect-query` now
takes data to display as an argument.  Reduce its function to
displaying a buffer with the data.

* gptel-transient.el (gptel-menu, gptel--suffix-send): Fold
dry-run the option into `gptel--suffix-send` and call it with a
dry-run flag instead of using an alternate pathway for dry-runs.
The "Inspect query" suffixes of `gptel-menu` now perform actual
dry-runs, avoiding issues like #276.
karthink added a commit that referenced this issue Apr 4, 2024
* gptel.el (gptel--inspect-query): `gptel--inspect-query` now
takes data to display as an argument.  Reduce its function to
displaying a buffer with the data.

* gptel-transient.el (gptel-menu, gptel--suffix-send): Fold
dry-run the option into `gptel--suffix-send` and call it with a
dry-run flag instead of using an alternate pathway for dry-runs.
The "Inspect query" suffixes of `gptel-menu` now perform actual
dry-runs, avoiding issues like #276.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants