2023-02-16 07:24:32 +00:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
2023-03-27 02:49:46 +00:00
|
|
|
"id": "38f26d7a",
|
2023-02-16 07:24:32 +00:00
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
2023-03-27 02:49:46 +00:00
|
|
|
"# Azure\n",
|
2023-02-16 07:24:32 +00:00
|
|
|
"\n",
|
2023-03-27 02:49:46 +00:00
|
|
|
"This notebook goes over how to connect to an Azure hosted OpenAI endpoint"
|
2023-02-16 07:24:32 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-03-27 02:49:46 +00:00
|
|
|
"execution_count": 2,
|
|
|
|
"id": "96164b42",
|
2023-02-16 07:24:32 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2023-03-27 02:49:46 +00:00
|
|
|
"from langchain.chat_models import AzureChatOpenAI\n",
|
|
|
|
"from langchain.schema import HumanMessage"
|
2023-02-16 07:24:32 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-03-27 02:49:46 +00:00
|
|
|
"execution_count": 4,
|
|
|
|
"id": "8161278f",
|
2023-02-16 07:24:32 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2023-03-27 02:49:46 +00:00
|
|
|
"BASE_URL = \"https://${TODO}.openai.azure.com\"\n",
|
|
|
|
"API_KEY = \"...\"\n",
|
|
|
|
"DEPLOYMENT_NAME = \"chat\"\n",
|
|
|
|
"model = AzureChatOpenAI(\n",
|
|
|
|
" openai_api_base=BASE_URL,\n",
|
2023-07-18 16:50:15 +00:00
|
|
|
" openai_api_version=\"2023-05-15\",\n",
|
2023-03-27 02:49:46 +00:00
|
|
|
" deployment_name=DEPLOYMENT_NAME,\n",
|
|
|
|
" openai_api_key=API_KEY,\n",
|
2023-06-16 18:52:56 +00:00
|
|
|
" openai_api_type=\"azure\",\n",
|
2023-03-27 02:49:46 +00:00
|
|
|
")"
|
2023-02-16 07:24:32 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-03-27 02:49:46 +00:00
|
|
|
"execution_count": 5,
|
|
|
|
"id": "99509140",
|
2023-02-16 07:24:32 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
2023-03-27 02:49:46 +00:00
|
|
|
"AIMessage(content=\"\\n\\nJ'aime programmer.\", additional_kwargs={})"
|
2023-02-16 07:24:32 +00:00
|
|
|
]
|
|
|
|
},
|
2023-03-27 02:49:46 +00:00
|
|
|
"execution_count": 5,
|
2023-02-16 07:24:32 +00:00
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
2023-06-16 18:52:56 +00:00
|
|
|
"model(\n",
|
|
|
|
" [\n",
|
|
|
|
" HumanMessage(\n",
|
|
|
|
" content=\"Translate this sentence from English to French. I love programming.\"\n",
|
|
|
|
" )\n",
|
|
|
|
" ]\n",
|
|
|
|
")"
|
2023-02-16 07:24:32 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
2023-03-27 02:49:46 +00:00
|
|
|
"id": "3b6e9376",
|
2023-02-16 07:24:32 +00:00
|
|
|
"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.1"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 5
|
|
|
|
}
|