Skip to content

Commit

Permalink
Define model config variables in separate cells to avoid calling Open…
Browse files Browse the repository at this point in the history
…AI unnecessarily
  • Loading branch information
gustavocidornelas authored and whoseoyster committed Sep 29, 2023
1 parent 46f1f0a commit d1a7f32
Showing 1 changed file with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,16 @@
"system_message_prompt = SystemMessagePromptTemplate.from_template(template)\n",
"\n",
"human_template = \"{question}\"\n",
"human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)\n",
"\n",
"human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bbd06c94",
"metadata": {},
"outputs": [],
"source": [
"chat_prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt])"
]
},
Expand Down Expand Up @@ -485,6 +493,20 @@
"Let's create a `model_config` for our model:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1053c839",
"metadata": {},
"outputs": [],
"source": [
"# Useful variable that will also go into our config\n",
"template = \"\"\"You are a helpful assistant who answers user's questions about Python.\n",
"A user will pass in a question, and you should answer it very objectively.\n",
"Use AT MOST 5 sentences. If you need more than 5 sentences to answer, say that the\n",
"user should make their question more objective.\"\"\""
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -498,7 +520,7 @@
" \"modelType\": \"shell\",\n",
" \"prompt\": [ # Optionally log the prompt, following the same format as OpenAI\n",
" {\"role\": \"system\", \"content\": template}, \n",
" {\"role\": \"user\", \"content\": human_template}\n",
" {\"role\": \"user\", \"content\": \"{question}\"}\n",
" ], \n",
" \"metadata\": { # Can add anything here, as long as it is a dict\n",
" \"output_parser\": None,\n",
Expand Down

0 comments on commit d1a7f32

Please sign in to comment.