Last active
May 4, 2021 20:58
-
-
Save devxpy/e22eeb501dc6e10d7a0a53667ed0d1ff to your computer and use it in GitHub Desktop.
Example code to remove openai prompt
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
Thanks. I’m sure you are too. | |
Besides coding, I write a lot of poetry and I’m working on a novel. | |
Also: | |
https://www.amazon.in/Mindfulness-Workbook-OCD-Overcoming-Compulsions/dp/1608828786/ref=b2b_gw_d_simh_3?pd_rd_w=AEsn9&pf_rd_p=9ea11b01-714c-4a00-ab30-c9b4be5135c7&pf_rd_r=57JXGFCJJWK23B7EQEHQ&pd_rd_r=4dc493f3-e340-4fee-b7ac-d4234227d3e5&pd_rd_wg=E4ZxL&pd_rd_i=1608828786&psc=1 | |
I love walking, particularly along the beach, which I do often. | |
I am also very interested in self-transformation and User: sometimes I wonder how the world might change if everyone embraced this pursuit, | |
or at least tried to. I love talking to people, Dara: and I’m interested in the way the world is changing thanks to technology. I also love chatting with people about politics. |
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
# example of a very messy response from openai | |
example = """ | |
Dara: Thanks. I’m sure you are too. | |
Dara: Besides coding, I write a lot of poetry and I’m working on a novel. | |
Also: | |
https://www.amazon.in/Mindfulness-Workbook-OCD-Overcoming-Compulsions/dp/1608828786/ref=b2b_gw_d_simh_3?pd_rd_w=AEsn9&pf_rd_p=9ea11b01-714c-4a00-ab30-c9b4be5135c7&pf_rd_r=57JXGFCJJWK23B7EQEHQ&pd_rd_r=4dc493f3-e340-4fee-b7ac-d4234227d3e5&pd_rd_wg=E4ZxL&pd_rd_i=1608828786&psc=1 | |
I love walking, particularly along the beach, which I do often. | |
I am also very interested in self-transformation and User: sometimes I wonder how the world might change if everyone embraced this pursuit, | |
or at least tried to. I love talking to people, Dara: and I’m interested in the way the world is changing thanks to technology. I also love chatting with people about politics. | |
""" | |
# regex that matches the prompt | |
prompt_re = re.compile(r"\n(User: |Dara: )") | |
# remove the prompt by replacing it with empty string | |
print(prompt_re.sub("", example)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment