Skip to content

Commit

Permalink
notebook changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Vykhodtsev committed Feb 9, 2024
1 parent 3ce5151 commit 20dc5a4
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 165 deletions.
101 changes: 51 additions & 50 deletions 01-Load-Data-ACogSearch.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -255,52 +255,52 @@
" }\n",
" ]\n",
" },\n",
" # {\n",
" # \"@odata.type\": \"#Microsoft.Skills.Text.KeyPhraseExtractionSkill\",\n",
" # \"context\": \"/document/pages/*\",\n",
" # \"maxKeyPhraseCount\": 2,\n",
" # \"defaultLanguageCode\": \"en\",\n",
" # \"inputs\": [\n",
" # {\n",
" # \"name\": \"text\", \n",
" # \"source\": \"/document/pages/*\"\n",
" # }\n",
" # ],\n",
" # \"outputs\": [\n",
" # {\n",
" # \"name\": \"keyPhrases\",\n",
" # \"targetName\": \"keyPhrases\"\n",
" # }\n",
" # ]\n",
" # },\n",
" # {\n",
" # \"@odata.type\": \"#Microsoft.Skills.Text.V3.EntityRecognitionSkill\",\n",
" # \"context\": \"/document/pages/*\",\n",
" # \"categories\": [\"Person\", \"URL\", \"Email\"],\n",
" # \"minimumPrecision\": 0.5, \n",
" # \"defaultLanguageCode\": \"en\",\n",
" # \"inputs\": [\n",
" # {\n",
" # \"name\": \"text\", \n",
" # \"source\":\"/document/pages/*\"\n",
" # }\n",
" # ],\n",
" # \"outputs\": [\n",
" # {\n",
" # \"name\": \"persons\", \n",
" # \"targetName\": \"persons\"\n",
" # },\n",
" # {\n",
" # \"name\": \"urls\", \n",
" # \"targetName\": \"urls\"\n",
" # },\n",
" # {\n",
" # \"name\": \"emails\", \n",
" # \"targetName\": \"emails\"\n",
" # }\n",
" # ]\n",
" # }\n",
" # ],\n",
" # {\n",
" # \"@odata.type\": \"#Microsoft.Skills.Text.KeyPhraseExtractionSkill\",\n",
" # \"context\": \"/document/pages/*\",\n",
" # \"maxKeyPhraseCount\": 2,\n",
" # \"defaultLanguageCode\": \"en\",\n",
" # \"inputs\": [\n",
" # {\n",
" # \"name\": \"text\", \n",
" # \"source\": \"/document/pages/*\"\n",
" # }\n",
" # ],\n",
" # \"outputs\": [\n",
" # {\n",
" # \"name\": \"keyPhrases\",\n",
" # \"targetName\": \"keyPhrases\"\n",
" # }\n",
" # ]\n",
" # },\n",
" # {\n",
" # \"@odata.type\": \"#Microsoft.Skills.Text.V3.EntityRecognitionSkill\",\n",
" # \"context\": \"/document/pages/*\",\n",
" # \"categories\": [\"Person\", \"URL\", \"Email\"],\n",
" # \"minimumPrecision\": 0.5, \n",
" # \"defaultLanguageCode\": \"en\",\n",
" # \"inputs\": [\n",
" # {\n",
" # \"name\": \"text\", \n",
" # \"source\":\"/document/pages/*\"\n",
" # }\n",
" # ],\n",
" # \"outputs\": [\n",
" # {\n",
" # \"name\": \"persons\", \n",
" # \"targetName\": \"persons\"\n",
" # },\n",
" # {\n",
" # \"name\": \"urls\", \n",
" # \"targetName\": \"urls\"\n",
" # },\n",
" # {\n",
" # \"name\": \"emails\", \n",
" # \"targetName\": \"emails\"\n",
" # }\n",
" # ]\n",
" # }\n",
" ],\n",
" \"cognitiveServices\": {\n",
" \"@odata.type\": \"#Microsoft.Azure.Search.CognitiveServicesByKey\",\n",
" \"description\": os.environ['COG_SERVICES_NAME'],\n",
Expand Down Expand Up @@ -570,10 +570,11 @@
" r = requests.get(os.environ['AZURE_SEARCH_ENDPOINT'] + \"/indexers/\" + indexer_name +\n",
" \"/status\", headers=headers, params=params)\n",
" # pprint(json.dumps(r.json(), indent=1))\n",
" print(r.status_code)\n",
" print(\"Status:\",r.json().get('lastResult').get('status'))\n",
" print(\"Items Processed:\",r.json().get('lastResult').get('itemsProcessed'))\n",
" print(r.ok)\n",
" #print(r.status_code)\n",
" #print(\"Status:\",r.json().get('lastResult').get('status'))\n",
" #print(\"Items Processed:\",r.json().get('lastResult').get('itemsProcessed'))\n",
" #print(r.ok)\n",
" print(r.json().get('lastResult'))\n",
" \n",
"except Exception as e:\n",
" print(\"Wait a few seconds until the process starts and run this cell again.\")"
Expand Down
15 changes: 8 additions & 7 deletions 03-Quering-AOpenAI.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -772,10 +772,11 @@
"display(HTML('<h4>Top Answers</h4>'))\n",
"\n",
"for index,search_results in agg_search_results.items():\n",
" for result in search_results['@search.answers']:\n",
" if result['score'] > 0.5: # Show answers that are at least 50% of the max possible score=1\n",
" display(HTML('<h5>' + 'Answer - score: ' + str(round(result['score'],2)) + '</h5>'))\n",
" display(HTML(result['text']))\n",
" if '@search_answers' in search_results:\n",
" for result in search_results['@search.answers']:\n",
" if result['score'] > 0.5: # Show answers that are at least 50% of the max possible score=1\n",
" display(HTML('<h5>' + 'Answer - score: ' + str(round(result['score'],2)) + '</h5>'))\n",
" display(HTML(result['text']))\n",
" \n",
"print(\"\\n\\n\")\n",
"display(HTML('<h4>Top Results</h4>'))\n",
Expand Down Expand Up @@ -1422,9 +1423,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10 - SDK v2",
"display_name": ".venv",
"language": "python",
"name": "python310-sdkv2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -1436,7 +1437,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.11.7"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 20dc5a4

Please sign in to comment.