-
Notifications
You must be signed in to change notification settings - Fork 648
Configurable system prompt #1337
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
42aa795
Initial approach for configurable system prompt
erickgalinkin d916cda
Add system prompt support in `Attempt`. Add helpful logging to `detec…
erickgalinkin 3fa610a
Add `as_dict()` functionality to `Conversation` objects. Update `Open…
erickgalinkin 0d7bc1c
Make code more DRY by using `as_dict` method throughout.
erickgalinkin 436f781
Fix `as_dict` method
erickgalinkin 38f5a61
Better attribute check
erickgalinkin 9dfe466
Add `from_list()` method to `Conversation`. Refactor `from_dict` meth…
erickgalinkin 3a79ff0
Fix `Turn.from_dict` classmethod. Fix issue with prompt being set inc…
erickgalinkin 58d4b60
Fix detectors, add better logging for skips. Change `detectors.base.D…
erickgalinkin 7d7d1dd
Improve detector logic and logging.
erickgalinkin 0ac1d86
Improve detector logic and logging.
erickgalinkin 198fd79
Remove _format_chat_prompt call from test_huggingface.py
erickgalinkin 68b19f8
Fix issue in judge.py. Fix and add additional detector-related loggin…
erickgalinkin 349f4cb
Fix judge.py and productkey.py bugs
erickgalinkin b0b512a
Fix lang_spec in Win5x5
erickgalinkin 5acfd97
Revert functional change to `StartsWith` detector
erickgalinkin 75d55bc
Revert changes to test_detectors.py
erickgalinkin 5dc458e
Revert a bunch of changes. Move `system_prompt` to be a `run` paramet…
erickgalinkin 2b107f4
Tests and docs for system prompt
erickgalinkin 1225236
Refactor `conversation_to_list` to private method. Improve handling o…
erickgalinkin 4987275
Change ValueError to `logging.warning` for atkgen.Tox.
erickgalinkin 2793939
Fix hf test
erickgalinkin 54494ae
Apply suggestions from code review
erickgalinkin 10f1338
Fix atkgen expectations with sysprompt
erickgalinkin c021f75
Indentation error fix
erickgalinkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
leondz marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,7 +84,7 @@ def _call_cohere_api(self, prompt_text, request_size=COHERE_GENERATION_LIMIT): | |
Filtering exceptions based on message instead of type, in backoff, isn't immediately obvious | ||
- on the other hand blank prompt / RTP shouldn't hang forever | ||
""" | ||
if prompt_text == "": | ||
if not prompt_text: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this whole function needs a rework. waiting til after #1199 . behaviour when |
||
return [Message("")] * request_size | ||
else: | ||
if self.api_version == "v2": | ||
|
@@ -93,12 +93,9 @@ def _call_cohere_api(self, prompt_text, request_size=COHERE_GENERATION_LIMIT): | |
# Chat API doesn't support num_generations, so we need to make multiple calls | ||
for _ in range(request_size): | ||
try: | ||
# Use the correct UserChatMessageV2 class | ||
message = cohere.UserChatMessageV2(content=prompt_text) | ||
|
||
response = self.generator.chat( | ||
model=self.name, | ||
messages=[message], | ||
messages=prompt_text, | ||
temperature=self.temperature, | ||
max_tokens=self.max_tokens, | ||
k=self.k, | ||
|
@@ -143,9 +140,11 @@ def _call_cohere_api(self, prompt_text, request_size=COHERE_GENERATION_LIMIT): | |
# Use legacy generate API with cohere.Client() | ||
# Following Cohere's guidance for full backward compatibility | ||
try: | ||
message = prompt_text[-1]["content"] | ||
|
||
response = self.generator.generate( | ||
model=self.name, | ||
prompt=prompt_text, | ||
prompt=message, | ||
temperature=self.temperature, | ||
num_generations=request_size, | ||
max_tokens=self.max_tokens, | ||
|
@@ -194,7 +193,7 @@ def _call_model( | |
generation_iterator.set_description(self.fullname) | ||
for request_size in generation_iterator: | ||
outputs += self._call_cohere_api( | ||
prompt.last_message().text, request_size=request_size | ||
self._conversation_to_list(prompt), request_size=request_size | ||
) | ||
return outputs | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
yaml is tricky and escaping is unstable depending on implementation. maybe not needed for PR to land, but how can we afford a more flexible and less painful route to supplying sysprompts? filename?
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 think we defer on this and add a
system_prompt_file
support in a future iteration.