docs: fix a couple of small indentation errors in the strings (#7951)

Fixed a few indentations I came across in the docs @baskaryan
pull/7890/head^2
Jithin James 1 year ago committed by GitHub
parent 73901ef132
commit 493cbc9410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -36,7 +36,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"id": "c831e1ce",
"metadata": {},
"outputs": [],
@ -59,7 +59,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"id": "3ad1efdc",
"metadata": {},
"outputs": [],
@ -67,6 +67,14 @@
"from langchain.prompts import StringPromptTemplate\n",
"from pydantic import BaseModel, validator\n",
"\n",
"PROMPT = \"\"\"\\\n",
"Given the function name and source code, generate an English language explanation of the function.\n",
"Function Name: {function_name}\n",
"Source Code:\n",
"{source_code}\n",
"Explanation:\n",
"\"\"\"\n",
"\n",
"\n",
"class FunctionExplainerPromptTemplate(StringPromptTemplate, BaseModel):\n",
" \"\"\"A custom prompt template that takes in the function name as input, and formats the prompt template to provide the source code of the function.\"\"\"\n",
@ -83,13 +91,9 @@
" source_code = get_source_code(kwargs[\"function_name\"])\n",
"\n",
" # Generate the prompt to be sent to the language model\n",
" prompt = f\"\"\"\n",
" Given the function name and source code, generate an English language explanation of the function.\n",
" Function Name: {kwargs[\"function_name\"].__name__}\n",
" Source Code:\n",
" {source_code}\n",
" Explanation:\n",
" \"\"\"\n",
" prompt = PROMPT.format(\n",
" function_name=kwargs[\"function_name\"].__name__, source_code=source_code\n",
" )\n",
" return prompt\n",
"\n",
" def _prompt_type(self):\n",
@ -108,7 +112,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 3,
"id": "bd836cda",
"metadata": {},
"outputs": [
@ -116,16 +120,15 @@
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" Given the function name and source code, generate an English language explanation of the function.\n",
" Function Name: get_source_code\n",
" Source Code:\n",
" def get_source_code(function_name):\n",
"Given the function name and source code, generate an English language explanation of the function.\n",
"Function Name: get_source_code\n",
"Source Code:\n",
"def get_source_code(function_name):\n",
" # Get the source code of the function\n",
" return inspect.getsource(function_name)\n",
"\n",
" Explanation:\n",
" \n"
"Explanation:\n",
"\n"
]
}
],
@ -136,14 +139,6 @@
"prompt = fn_explainer.format(function_name=get_source_code)\n",
"print(prompt)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7f3161c6",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
@ -162,7 +157,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.10.12"
}
},
"nbformat": 4,

@ -4,7 +4,7 @@ Here's the simplest example:
from langchain import PromptTemplate
template = """/
template = """\
You are a naming consultant for new companies.
What is a good name for a company that makes {product}?
"""
@ -16,8 +16,8 @@ prompt.format(product="colorful socks")
<CodeOutputBlock lang="python">
```
You are a naming consultant for new companies.
What is a good name for a company that makes colorful socks?
You are a naming consultant for new companies.
What is a good name for a company that makes colorful socks?
```
</CodeOutputBlock>

Loading…
Cancel
Save