Skip to content

Commit

Permalink
Merge pull request #79 from STRIDES/langchain_updates_zy
Browse files Browse the repository at this point in the history
Langchain updates zy
  • Loading branch information
kyleoconnell-NIH authored Mar 11, 2024
2 parents 9ab7d75 + ece1e88 commit 2f704cd
Show file tree
Hide file tree
Showing 9 changed files with 847 additions and 814 deletions.
4 changes: 2 additions & 2 deletions notebooks/GenAI/Azure_Open_AI_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ On the far right, you can modify which model you are deploying, which allows you

![modify deployment](/docs/images/19_deployment.png)

Finally, you can select the `parameters` tab to modify the model parameters. Review [this presentation](/tutorials/notebooks/GenAI/search_documents/aoai_workshop_content.pdf) to learn more about the parameters.
Finally, you can select the `parameters` tab to modify the model parameters. Review [this presentation](/notebooks/GenAI/search_documents/aoai_workshop_content.pdf) to learn more about the parameters.

![modify parameters](/docs/images/20_parameters.png)

Expand Down Expand Up @@ -357,7 +357,7 @@ Creating embeddings of search documents allows you to use vector search, which i
### Environment Setup
Navigate to your [Azure Machine Learning Studio environment](https://github.com/STRIDES/NIHCloudLabAzure#launch-a-machine-learning-workspace-jupyter-environment-). If you have not created your environment, [create one now](https://learn.microsoft.com/en-us/azure/machine-learning/tutorial-cloud-workstation?view=azureml-api-2).

Navigate to `Notebooks`, then clone this Git repo into your environment and navigate to the notebook called [AzureOpenAI_embeddings.ipynb](/tutorials/notebooks/GenAI/notebooks/AzureOpenAI_embeddings.ipynb).
Navigate to `Notebooks`, then clone this Git repo into your environment and navigate to the notebook called [AzureOpenAI_embeddings.ipynb](/notebooks/GenAI/notebooks/AzureOpenAI_embeddings.ipynb).

You will need a variety of parameters to authenticate with the API. You can find these within the Chat Playground by clicking **View Code**. Input these parameters into the notebook cell when asked.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from langchain.chains import ConversationalRetrievalChain
from langchain.prompts import PromptTemplate
from langchain.chat_models import AzureChatOpenAI
from langchain.retrievers import AzureCognitiveSearchRetriever
from langchain_community.retrievers import AzureCognitiveSearchRetriever
from langchain_openai import AzureChatOpenAI
import sys
import json
import os
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from langchain.retrievers import PubMedRetriever
from langchain.chains import ConversationalRetrievalChain
from langchain.prompts import PromptTemplate
from langchain.llms import VertexAI
import sys
import json
import os
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
{
"cell_type": "markdown",
"id": "e421b4fd",
"metadata": {},
"source": [
"## Overview\n",
Expand All @@ -18,6 +19,7 @@
},
{
"cell_type": "markdown",
"id": "f3fe0439",
"metadata": {},
"source": [
"## Prerequisites\n",
Expand All @@ -26,6 +28,7 @@
},
{
"cell_type": "markdown",
"id": "6c5376ef",
"metadata": {},
"source": [
"## Learning objectives\n",
Expand All @@ -38,6 +41,7 @@
},
{
"cell_type": "markdown",
"id": "6fd8094c",
"metadata": {},
"source": [
"## Get started"
Expand All @@ -61,7 +65,7 @@
},
"outputs": [],
"source": [
"pip install -U \"langchain\" \"openai\""
"pip install -U \"langchain\" \"openai\" \"langchain-openai\" \"langchain-community\""
]
},
{
Expand Down Expand Up @@ -156,7 +160,18 @@
"metadata": {},
"outputs": [],
"source": [
"os.environ[\"AZURE_OPENAI_ENDPOINT\"] = \"<Your Azure Endpoint>\"\n",
"os.environ[\"AZURE_OPENAI_KEY\"] = \"<Your Azure AI Key>\"\n",
"\n",
"#create embeddings functions to apply to a given column\n",
"from openai import AzureOpenAI\n",
" \n",
"client = AzureOpenAI(\n",
" api_key=os.getenv(\"AZURE_OPENAI_KEY\"), \n",
" api_version=\"2023-05-15\",\n",
" azure_endpoint = os.getenv(\"AZURE_OPENAI_ENDPOINT\")\n",
" )\n",
"\n",
"def generate_embeddings(text, model=\"text-embedding-ada-002\"):\n",
" return client.embeddings.create(input = [text], model=model).data[0].embedding\n",
"\n",
Expand Down Expand Up @@ -770,6 +785,7 @@
},
{
"cell_type": "markdown",
"id": "31c915c9",
"metadata": {},
"source": [
"## Conclusion\n",
Expand Down
Loading

0 comments on commit 2f704cd

Please sign in to comment.