-
-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🗂️ move actual prompts out of chains
- Loading branch information
1 parent
d7fa612
commit 000213d
Showing
5 changed files
with
77 additions
and
86 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -1 +1,3 @@ | ||
from .system_message import system_message as code_interpreter_system_message | ||
from .modifications_check import determine_modifications_function, determine_modifications_prompt | ||
from .remove_dl_link import remove_dl_link_prompt |
This file contains 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
from langchain.schema import SystemMessage | ||
from langchain.prompts.chat import ChatPromptTemplate, HumanMessagePromptTemplate | ||
|
||
|
||
determine_modifications_prompt = ChatPromptTemplate( | ||
input_variables=["code"], | ||
messages=[ | ||
SystemMessage( | ||
content="The user will input some code and you will need to determine if the code makes any changes to the file system. \n" | ||
"With changes it means creating new files or modifying exsisting ones.\n" | ||
"Answer with a function call `determine_modifications` and list them inside.\n" | ||
"If the code does not make any changes to the file system, still answer with the function call but return an empty list.\n", | ||
), | ||
HumanMessagePromptTemplate.from_template("{code}"), | ||
], | ||
) | ||
|
||
|
||
determine_modifications_function = { | ||
"name": "determine_modifications", | ||
"description": "Based on code of the user determine if the code makes any changes to the file system. \n" | ||
"With changes it means creating new files or modifying exsisting ones.\n", | ||
"parameters": { | ||
"type": "object", | ||
"properties": { | ||
"modifications": { | ||
"type": "array", | ||
"items": {"type": "string"}, | ||
"description": "The filenames that are modified by the code.", | ||
}, | ||
}, | ||
"required": ["modifications"], | ||
}, | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from langchain.prompts.chat import ( | ||
ChatPromptTemplate, | ||
HumanMessagePromptTemplate, | ||
) | ||
from langchain.schema import ( | ||
AIMessage, | ||
SystemMessage, | ||
HumanMessage, | ||
) | ||
|
||
|
||
remove_dl_link_prompt = ChatPromptTemplate( | ||
input_variables=["input_response"], | ||
messages=[ | ||
SystemMessage( | ||
content="The user will send you a response and you need to remove the download link from it.\n" | ||
"Reformat the remaining message so no whitespace or half sentences are still there.\n" | ||
"If the response does not contain a download link, return the response as is.\n" | ||
), | ||
HumanMessage( | ||
content="The dataset has been successfully converted to CSV format. You can download the converted file [here](sandbox:/Iris.csv)." | ||
), | ||
AIMessage(content="The dataset has been successfully converted to CSV format."), | ||
HumanMessagePromptTemplate.from_template("{input_response}"), | ||
], | ||
) |