Skip to content

Commit

Permalink
pull main changes into working (#32)
Browse files Browse the repository at this point in the history
* added stepped notebooks for content delivery

* adding contoso products manuals

* adding contoso-manuals-index creation

* cleaning notebook

* added intent connections to round out full connectivity

* corrected environment issue and renamed local eval run
  • Loading branch information
sethjuarez authored Feb 5, 2024
1 parent 82e750a commit 1096c2d
Show file tree
Hide file tree
Showing 29 changed files with 4,615 additions and 8 deletions.
56 changes: 51 additions & 5 deletions connections/create-connections.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -24,7 +24,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -46,7 +46,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -70,7 +70,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -88,6 +88,52 @@
"result = pf.connections.create_or_update(connection)\n",
"print(result)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Create the local contoso-search connection\n",
"SUPPORT_ENDPOINT = os.environ[\"SUPPORT_ENDPOINT\"]\n",
"SUPPORT_KEY = os.environ[\"SUPPORT_KEY\"]\n",
"connection = CustomConnection(\n",
" name=\"support-endpoint\",\n",
" configs={\n",
" \"api_base\": SUPPORT_ENDPOINT,\n",
" },\n",
" secrets={\"api_key\": SUPPORT_KEY},\n",
")\n",
"\n",
"\n",
"print(f\"Creating connection {connection.name}...\")\n",
"result = pf.connections.create_or_update(connection)\n",
"print(result)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Create the local contoso-search connection\n",
"CHAT_ENDPOINT = os.environ[\"CHAT_ENDPOINT\"]\n",
"CHAT_KEY = os.environ[\"CHAT_KEY\"]\n",
"connection = CustomConnection(\n",
" name=\"chat-endpoint\",\n",
" configs={\n",
" \"api_base\": CHAT_ENDPOINT,\n",
" },\n",
" secrets={\"api_key\": CHAT_KEY},\n",
")\n",
"\n",
"\n",
"print(f\"Creating connection {connection.name}...\")\n",
"result = pf.connections.create_or_update(connection)\n",
"print(result)"
]
}
],
"metadata": {
Expand All @@ -106,7 +152,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion contoso-chat/flow.dag.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
environment:
image: docker.io/sethjuarez/contoso-store:v20240124.1
python_requirements_txt: requirements.txt
inputs:
chat_history:
type: list
Expand Down
129 changes: 129 additions & 0 deletions data/manual_info/contoso-manuals-index.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip install azure-ai-generative[evaluate,index,promptflow]==1.0.0b3"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from azure.ai.resources.client import AIClient\n",
"from azure.ai.resources.operations._index_data_source import (\n",
" LocalSource,\n",
" ACSOutputConfig,\n",
")\n",
"from azure.ai.generative.index import build_index\n",
"from azure.identity import DefaultAzureCredential\n",
"from dotenv import load_dotenv\n",
"\n",
"load_dotenv()\n",
"\n",
"contoso_search = os.environ[\"CONTOSO_SEARCH_SERVICE\"]\n",
"contoso_search_key = os.environ[\"CONTOSO_SEARCH_KEY\"]\n",
"index_name = \"contoso-manuals-index\"\n",
"\n",
"os.environ[\"OPENAI_API_TYPE\"] = \"azure\"\n",
"os.environ[\"OPENAI_API_BASE\"] = os.environ[\"CONTOSO_AI_SERVICES_ENDPOINT\"]\n",
"os.environ[\"OPENAI_API_KEY\"] = os.environ[\"CONTOSO_AI_SERVICES_KEY\"]\n",
"openai_deployment = \"text-embedding-ada-002\"\n",
"\n",
"path_to_data = \"./manuals\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Set up environment variables for cog search SDK\n",
"os.environ[\"AZURE_AI_SEARCH_ENDPOINT\"] = contoso_search\n",
"os.environ[\"AZURE_AI_SEARCH_KEY\"] = contoso_search_key\n",
"\n",
"\n",
"client = AIClient.from_config(DefaultAzureCredential())\n",
"\n",
"# Use the same index name when registering the index in AI Studio\n",
"index = build_index(\n",
" output_index_name=index_name,\n",
" vector_store=\"azure_cognitive_search\",\n",
" embeddings_model=f\"azure_open_ai://deployment/{openai_deployment}/model/{openai_deployment}\",\n",
" data_source_url=\"/products\",\n",
" index_input_config=LocalSource(input_data=path_to_data),\n",
" acs_config=ACSOutputConfig(\n",
" acs_index_name=index_name,\n",
" ),\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# register the index so that it shows up in the project\n",
"cloud_index = client.indexes.create_or_update(index)\n",
"\n",
"print(f\"Created index '{cloud_index.name}'\")\n",
"print(f\"Local Path: {index.path}\")\n",
"print(f\"Cloud Path: {cloud_index.path}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip uninstall azure-ai-generative[evaluate,index,promptflow]==1.0.0b3 -y"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip install azure-search-documents==11.4.0"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 1096c2d

Please sign in to comment.