model garden nit (#10194)

This commit is contained in:
Bagatur 2023-09-04 11:42:35 -07:00 committed by GitHub
parent bb8c095127
commit a94dc6ee44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -236,7 +236,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"llm_oss = VertexAIModelGarden(\n", "llm = VertexAIModelGarden(\n",
" project=\"YOUR PROJECT\",\n", " project=\"YOUR PROJECT\",\n",
" endpoint_id=\"YOUR ENDPOINT_ID\"\n", " endpoint_id=\"YOUR ENDPOINT_ID\"\n",
")" ")"
@ -248,14 +248,25 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"llm_oss(\"What is the meaning of life?\")" "llm(\"What is the meaning of life?\")"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"You can also use it as a chain:" "Like all LLMs, we can then compose it with other components:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from langchain.prompts import PromptTemplate\n",
"\n",
"prompt = PromptTemplate.from_template(\"What is the meaning of {thing}?\")"
] ]
}, },
{ {
@ -264,17 +275,17 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"llm_oss_chain = LLMChain(prompt=prompt, llm=llm_oss(\"What is the meaning of life?\")\n", "llm_oss_chain = prompt | llm\n",
")\n", "\n",
"llm_oss_chain.run(question)" "llm_oss_chain.invoke({\"thing\": \"life\"})"
] ]
} }
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3 (ipykernel)", "display_name": "poetry-venv",
"language": "python", "language": "python",
"name": "python3" "name": "poetry-venv"
}, },
"language_info": { "language_info": {
"codemirror_mode": { "codemirror_mode": {
@ -286,7 +297,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.10.12" "version": "3.9.1"
}, },
"vscode": { "vscode": {
"interpreter": { "interpreter": {