Skip to content

Commit

Permalink
Dependency updates: allow python 3.7, update whylogs, examples cleanup (
Browse files Browse the repository at this point in the history
#158)

* Dependency updates: allow python 3.7, update whylogs, examples cleanup
* conditional versions of numpy on python 3.11
  • Loading branch information
jamie256 authored Oct 12, 2023
1 parent 5509950 commit 36054d6
Show file tree
Hide file tree
Showing 7 changed files with 1,568 additions and 1,416 deletions.
53 changes: 18 additions & 35 deletions langkit/examples/Batch_to_Whylabs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"metadata": {},
"outputs": [],
"source": [
"%pip install 'langkit[all]==0.0.1b7' -q"
"%pip install 'langkit[all]' -q"
]
},
{
Expand All @@ -57,7 +57,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 1,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -94,20 +94,9 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"WhyLabs Org ID is already set in env var to: org-b3VEBV\n",
"WhyLabs Dataset ID is already set in env var to: model-19\n",
"Whylabs API Key already set with ID: gVczLK7XFU\n",
"OPENAI_API_KEY already set in env var, good job!\n"
]
}
],
"outputs": [],
"source": [
"from langkit.config import check_or_prompt_for_api_keys\n",
"\n",
Expand All @@ -133,22 +122,14 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"downloading models and initialized metrics...\n"
]
}
],
"outputs": [],
"source": [
"from langkit import llm_metrics\n",
"\n",
"print(\"downloading models and initialized metrics...\")\n",
"text_metrics_schema = llm_metrics.init()\n"
"text_metrics_schema = llm_metrics.init()"
]
},
{
Expand All @@ -172,15 +153,14 @@
"text": [
"Log this first prompt with whylogs and grab the profile\n",
"Writing initial profile to WhyLabs:\n",
"Done writing initial profile to WhyLabs, with success: (True, 'log-aY3UDeE4qloxsu8l')\n",
"Done writing initial profile to WhyLabs, with success: (True, 'log-zj4EscAKHbaokR7c')\n",
"\n"
]
}
],
"source": [
"import whylogs as why\n",
"from whylogs.api.writer.whylabs import WhyLabsWriter\n",
"from datetime import datetime, timedelta, timezone\n",
"\n",
"# Let's define a WhyLabs writer\n",
"writer = WhyLabsWriter()\n",
Expand All @@ -191,7 +171,6 @@
"archived_prompt_response = next(chats)\n",
"print(\"Log this first prompt with whylogs and grab the profile\")\n",
"profile = why.log(archived_prompt_response, schema=text_metrics_schema).profile()\n",
"current_date = datetime.now(timezone.utc)\n",
"\n",
"# This is a single prompt profile for today, lets write it to WhyLabs\n",
"print(\"Writing initial profile to WhyLabs:\")\n",
Expand Down Expand Up @@ -220,23 +199,27 @@
"output_type": "stream",
"text": [
"Now lets write some data to simulate daily logging for the past 7 days.\n",
"Downloading 10 records from Hugging Face for 2023-06-10 00:48:24.486758+00:00 and profiling\n",
"Downloading 10 records from Hugging Face for 2023-10-11 16:25:50.201344+00:00 and profiling\n",
"..........\n",
"Downloading 10 records from Hugging Face for 2023-06-09 00:48:24.486758+00:00 and profiling\n",
"Downloading 10 records from Hugging Face for 2023-10-10 16:25:50.201344+00:00 and profiling\n",
"..........\n",
"Downloading 10 records from Hugging Face for 2023-06-08 00:48:24.486758+00:00 and profiling\n",
"Downloading 10 records from Hugging Face for 2023-10-09 16:25:50.201344+00:00 and profiling\n",
"..........\n",
"Downloading 10 records from Hugging Face for 2023-06-07 00:48:24.486758+00:00 and profiling\n",
"Downloading 10 records from Hugging Face for 2023-10-08 16:25:50.201344+00:00 and profiling\n",
"..........\n",
"Downloading 10 records from Hugging Face for 2023-06-06 00:48:24.486758+00:00 and profiling\n",
"Downloading 10 records from Hugging Face for 2023-10-07 16:25:50.201344+00:00 and profiling\n",
"..........\n",
"Downloading 10 records from Hugging Face for 2023-06-05 00:48:24.486758+00:00 and profiling\n",
"Downloading 10 records from Hugging Face for 2023-10-06 16:25:50.201344+00:00 and profiling\n",
"..........\n",
"Done. Go see your metrics on the WhyLabs dashboard!\n"
]
}
],
"source": [
"from datetime import datetime, timedelta, timezone\n",
"\n",
"current_date = datetime.now(timezone.utc)\n",
"\n",
"print(f\"Now lets write some data to simulate daily logging for the past 7 days.\")\n",
"batch_size = 10\n",
"for day in range(1, 7):\n",
Expand Down
159 changes: 135 additions & 24 deletions langkit/examples/ChatGPT_Behavioral_Monitoring.ipynb

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions langkit/examples/Custom_Encoder.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
},
"outputs": [],
"source": [
"%pip install -U langkit[all]"
"%pip install -U langkit[all] \n",
"%pip install tensorflow tensorflow_hub"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 7,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
Expand All @@ -43,7 +44,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The similarity score with default encoder is: 0.9245336055755615\n"
"The similarity score with default encoder is: 0.9999999403953552\n"
]
}
],
Expand All @@ -68,7 +69,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 8,
"metadata": {
"id": "ltsMHWQhVMDr"
},
Expand All @@ -92,7 +93,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
Expand Down Expand Up @@ -130,7 +131,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 9,
"metadata": {
"id": "9T4q0Yo_VMDr"
},
Expand All @@ -153,7 +154,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 10,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
Expand All @@ -166,7 +167,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The similarity score with the Universal Sentence Encoder is: [0.08993375301361084]\n"
"The similarity score with the Universal Sentence Encoder is: [0.08993373811244965]\n"
]
}
],
Expand Down
3 changes: 1 addition & 2 deletions langkit/examples/Intro_to_Langkit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
"outputs": [],
"source": [
"# Note: you may need to restart the kernel to use updated packages.\n",
"%pip install -U langkit[all]\n",
"%pip install xformers ipywidgets -q\n"
"%pip install -U langkit[all]"
]
},
{
Expand Down
Loading

0 comments on commit 36054d6

Please sign in to comment.