Skip to content

Commit

Permalink
Remove Davinci from Workshop
Browse files Browse the repository at this point in the history
  • Loading branch information
akshata29 committed Aug 2, 2023
1 parent ece444f commit 46465f4
Show file tree
Hide file tree
Showing 21 changed files with 1,249 additions and 1,060 deletions.
276 changes: 168 additions & 108 deletions Workshop/0A_PromptEngg.ipynb

Large diffs are not rendered by default.

258 changes: 68 additions & 190 deletions Workshop/0B_EmbeddingCluster.ipynb

Large diffs are not rendered by default.

380 changes: 192 additions & 188 deletions Workshop/0_SetupandConfig.ipynb

Large diffs are not rendered by default.

73 changes: 26 additions & 47 deletions Workshop/10_PibCoPilot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
{
"cell_type": "code",
"execution_count": 245,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -46,13 +46,12 @@
"openAiEndPoint = f\"https://{OpenAiService}.openai.azure.com\"\n",
"assert openAiEndPoint, \"ERROR: Azure OpenAI Endpoint is missing\"\n",
"assert \"openai.azure.com\" in openAiEndPoint.lower(), \"ERROR: Azure OpenAI Endpoint should be in the form: \\n\\n\\t<your unique endpoint identifier>.openai.azure.com\"\n",
"openai.api_base = openAiEndPoint\n",
"davincimodel = OpenAiDavinci\n"
"openai.api_base = openAiEndPoint"
]
},
{
"cell_type": "code",
"execution_count": 246,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -69,7 +68,7 @@
},
{
"cell_type": "code",
"execution_count": 247,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -100,7 +99,7 @@
},
{
"cell_type": "code",
"execution_count": 248,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -110,15 +109,8 @@
" openai.api_key = OpenAiKey\n",
" openai.api_version = OpenAiVersion\n",
" openai.api_base = OpenAiBase\n",
"\n",
" llm = AzureOpenAI(deployment_name=OpenAiDavinci,\n",
" temperature=temperature,\n",
" openai_api_key=OpenAiKey,\n",
" max_tokens=tokenLength,\n",
" batch_size=10, \n",
" max_retries=12)\n",
" \n",
" llmChat = AzureChatOpenAI(\n",
" llm = AzureChatOpenAI(\n",
" openai_api_base=openai.api_base,\n",
" openai_api_version=OpenAiVersion,\n",
" deployment_name=OpenAiChat16k,\n",
Expand All @@ -136,20 +128,14 @@
" openai.api_key = OpenAiApiKey\n",
" llm = OpenAI(temperature=temperature,\n",
" openai_api_key=OpenAiApiKey,\n",
" model_name=\"gpt-3.5-turbo\",\n",
" max_tokens=tokenLength)\n",
" embeddings = OpenAIEmbeddings(openai_api_key=OpenAiApiKey)\n",
"\n",
" llmChat = ChatOpenAI(temperature=temperature,\n",
" openai_api_key=OpenAiApiKey,\n",
" model_name=\"gpt-3.5-turbo\",\n",
" max_tokens=tokenLength)\n",
" \n",
" embeddings = OpenAIEmbeddings(openai_api_key=OpenAiApiKey)"
" embeddings = OpenAIEmbeddings(openai_api_key=OpenAiApiKey) \n"
]
},
{
"cell_type": "code",
"execution_count": 249,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -164,7 +150,7 @@
},
{
"cell_type": "code",
"execution_count": 250,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -174,7 +160,7 @@
},
{
"cell_type": "code",
"execution_count": 251,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -191,7 +177,7 @@
},
{
"cell_type": "code",
"execution_count": 252,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand All @@ -200,7 +186,7 @@
"'73124'"
]
},
"execution_count": 252,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -211,12 +197,12 @@
},
{
"cell_type": "code",
"execution_count": 254,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"# deletePibData(SearchService, SearchKey, pibIndexName, \"73124\", \"4\", returnFields=['id', 'symbol', 'cik', 'step', 'description', 'insertedDate',\n",
"# 'pibData'])"
"# deletePibData(SearchService, SearchKey, pibIndexName, \"1535929\", \"2\", returnFields=['id', 'symbol', 'cik', 'step', 'description', 'insertedDate',\n",
"# 'pibData'])"
]
},
{
Expand Down Expand Up @@ -288,18 +274,11 @@
" \"\"\"\n",
" optimizedPrompt = qaPromptTemplate.format(query=query)\n",
" qaPrompt = PromptTemplate(input_variables=[\"query\"],template=qaPromptTemplate)\n",
" chain = LLMChain(llm=llmChat, prompt=qaPrompt)\n",
" chain = LLMChain(llm=llm, prompt=qaPrompt)\n",
" q = chain.run(query=query)\n",
" # completion = openai.Completion.create(\n",
" # engine=OpenAiDavinci,\n",
" # prompt=optimizedPrompt,\n",
" # temperature=temperature,\n",
" # max_tokens=100,\n",
" # n=1)\n",
" # q = completion.choices[0].text\n",
" bingSearch = BingSearchAPIWrapper(k=20)\n",
" results = bingSearch.run(query=q)\n",
" chain = load_summarize_chain(llmChat, chain_type=\"stuff\")\n",
" chain = load_summarize_chain(llm, chain_type=\"stuff\")\n",
" docs = [Document(page_content=results)]\n",
" summary = chain.run(docs)\n",
" step1Executives.append({\n",
Expand Down Expand Up @@ -626,7 +605,7 @@
" ]\n",
"\n",
" for question in commonQuestions:\n",
" answer = findAnswer('stuff', 3, symbol, quarter, year, question, earningVectorIndexName, llmChat)\n",
" answer = findAnswer('stuff', 3, symbol, quarter, year, question, earningVectorIndexName, llm)\n",
" if \"I don't know\" not in answer:\n",
" earningCallQa.append({\"question\": question, \"answer\": answer})\n",
"\n",
Expand All @@ -642,7 +621,7 @@
" ]\n",
"\n",
" for question in commonQuestions:\n",
" answer = findAnswer('stuff', 3, symbol, quarter, year, question, earningVectorIndexName, llmChat)\n",
" answer = findAnswer('stuff', 3, symbol, quarter, year, question, earningVectorIndexName, llm)\n",
" if \"I don't know\" not in answer:\n",
" earningCallQa.append({\"question\": question, \"answer\": answer})\n",
"\n",
Expand All @@ -660,7 +639,7 @@
" \"\"\"\n",
" customPrompt = PromptTemplate(template=promptTemplate, input_variables=[\"text\"])\n",
" chainType = \"map_reduce\"\n",
" summaryChain = load_summarize_chain(llmChat, chain_type=chainType, return_intermediate_steps=False, \n",
" summaryChain = load_summarize_chain(llm, chain_type=chainType, return_intermediate_steps=False, \n",
" combine_prompt=customPrompt)\n",
" summaryOutput = summaryChain({\"input_documents\": docs}, return_only_outputs=True)\n",
"\n",
Expand Down Expand Up @@ -697,12 +676,12 @@
" customPrompt = PromptTemplate(template=promptTemplate, input_variables=[\"text\"])\n",
" try:\n",
" chainType = \"stuff\"\n",
" summaryChain = load_summarize_chain(llmChat, chain_type=chainType, prompt=customPrompt)\n",
" summaryChain = load_summarize_chain(llm, chain_type=chainType, prompt=customPrompt)\n",
" summaryOutput = summaryChain({\"input_documents\": docs}, return_only_outputs=True)\n",
" output = summaryOutput['output_text']\n",
" except:\n",
" chainType = \"map_reduce\"\n",
" summaryChain = load_summarize_chain(llmChat, chain_type=chainType, combine_prompt=customPrompt)\n",
" summaryChain = load_summarize_chain(llm, chain_type=chainType, combine_prompt=customPrompt)\n",
" summaryOutput = summaryChain({\"input_documents\": docs}, return_only_outputs=True)\n",
" output = summaryOutput['output_text']\n",
" s2Data.append({\n",
Expand Down Expand Up @@ -955,7 +934,7 @@
" i = 0\n",
" for pDocs in pressReleasesDocs:\n",
" try:\n",
" outputAnswer = summarizePressReleases(llmChat, [pDocs])\n",
" outputAnswer = summarizePressReleases(llm, [pDocs])\n",
" jsonStep = json.loads(outputAnswer)\n",
" pressReleasesPib.append({\n",
" \"releaseDate\": last25PressReleases[i]['releaseDate'],\n",
Expand Down Expand Up @@ -1331,7 +1310,7 @@
}
],
"source": [
"print(getItem8Answer(llmChat, itemDocs8, \"What was the reported revenue for 2021?\", \"map_reduce\"))"
"print(getItem8Answer(llm, itemDocs8, \"What was the reported revenue for 2021?\", \"map_reduce\"))"
]
},
{
Expand Down Expand Up @@ -2147,7 +2126,7 @@
"from langchain.tools.python.tool import PythonREPLTool\n",
"from langchain.python import PythonREPL\n",
"\n",
"agent = create_pandas_dataframe_agent(llmChat,df=incomeStmtDf, verbose=True)\n",
"agent = create_pandas_dataframe_agent(llm,df=incomeStmtDf, verbose=True)\n",
"\n",
"Question = 'What is the total revenue for the year 2022?'\n",
"#Question = 'How much did revenue increased in 2022 in comparision to 2021?'\n",
Expand Down
3 changes: 1 addition & 2 deletions Workshop/11_Prospectus.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"openAiEndPoint = f\"https://{OpenAiService}.openai.azure.com\"\n",
"assert openAiEndPoint, \"ERROR: Azure OpenAI Endpoint is missing\"\n",
"assert \"openai.azure.com\" in openAiEndPoint.lower(), \"ERROR: Azure OpenAI Endpoint should be in the form: \\n\\n\\t<your unique endpoint identifier>.openai.azure.com\"\n",
"openai.api_base = openAiEndPoint\n",
"davincimodel = OpenAiDavinci\n"
"openai.api_base = openAiEndPoint"
]
},
{
Expand Down
21 changes: 10 additions & 11 deletions Workshop/1A_GenerateQuestions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
"openAiEndPoint = f\"https://{OpenAiService}.openai.azure.com\"\n",
"assert openAiEndPoint, \"ERROR: Azure OpenAI Endpoint is missing\"\n",
"assert \"openai.azure.com\" in openAiEndPoint.lower(), \"ERROR: Azure OpenAI Endpoint should be in the form: \\n\\n\\t<your unique endpoint identifier>.openai.azure.com\"\n",
"openai.api_base = openAiEndPoint\n",
"davincimodel = OpenAiDavinci\n"
"openai.api_base = openAiEndPoint"
]
},
{
Expand All @@ -53,7 +52,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -71,7 +70,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -116,7 +115,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -136,7 +135,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -145,7 +144,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -154,17 +153,17 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'question': 'What are the steps to certify an item in Power BI?',\n",
" 'answer': \"To certify an item in Power BI, you need to get write permissions on the item, review it to ensure it meets your organization's certification standards, open the settings of the item, expand the endorsement section and select Certified, and finally select Apply.\"}]"
"[{'question': 'What are the steps to certify an item?',\n",
" 'answer': '1. Get write permissions on the item you want to certify. 2. Review the item and determine if it meets certification standards. 3. Open the settings of the item and select Certified. 4. Select Apply.'}]"
]
},
"execution_count": 22,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
19 changes: 9 additions & 10 deletions Workshop/1_LoadData.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%pip install ./azure_search_documents-11.4.0b4-py3-none-any.whl"
"#%pip install ./azure_search_documents-11.4.0b4-py3-none-any.whl"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Install langchain\n",
"%pip install langchain"
"#%pip install langchain"
]
},
{
Expand All @@ -58,7 +58,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -79,8 +79,7 @@
"openAiEndPoint = f\"https://{OpenAiService}.openai.azure.com\"\n",
"assert openAiEndPoint, \"ERROR: Azure OpenAI Endpoint is missing\"\n",
"assert \"openai.azure.com\" in openAiEndPoint.lower(), \"ERROR: Azure OpenAI Endpoint should be in the form: \\n\\n\\t<your unique endpoint identifier>.openai.azure.com\"\n",
"openai.api_base = openAiEndPoint\n",
"davincimodel = OpenAiDavinci\n"
"openai.api_base = openAiEndPoint"
]
},
{
Expand All @@ -93,7 +92,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -118,12 +117,12 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"# Flexibility to change the call to OpenAI or Azure OpenAI\n",
"embeddingModelType = \"openai\""
"embeddingModelType = \"azureopenai\""
]
},
{
Expand Down
Loading

0 comments on commit 46465f4

Please sign in to comment.