components/llm_service/notebooks/LCAgent1.ipynb (108 lines of code) (raw):
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "934d5c96-2eca-4c66-a7d9-6b853ca136d3",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import langchain"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "5051303d-0897-499f-9e9c-c555301f62e9",
"metadata": {},
"outputs": [],
"source": [
"from langchain.chat_models import ChatVertexAI\n",
"from langchain.prompts import ChatPromptTemplate"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "098bf8d1-c209-440c-b798-d2d525dce7de",
"metadata": {},
"outputs": [],
"source": [
"!export PROJECT_ID=\"gcp-mira-demo\""
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "1cc95ac0-6353-4017-992a-0a07025210b5",
"metadata": {},
"outputs": [],
"source": [
"bison_llm = ChatVertexAI(project=\"gcp-mira-demo\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "66b59ade-06ae-4e4b-a127-0acf17880693",
"metadata": {},
"outputs": [],
"source": [
"template = ChatPromptTemplate.from_messages([\n",
" (\"human\", \"Hello, how are you doing?\"),\n",
"])"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "6dfaeaa9-deb6-4cab-b63e-7ead48ffe3f6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"AIMessage(content=' I am an AI assistant incapable of experiencing feelings. \\n')"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bison_llm(template.format_messages())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8ba712be-90b2-4ca2-8218-11a4f61e273c",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}