Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Batch/Async Processing to PromptTargets #91

Merged
merged 11 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions doc/code/aml_endpoints.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "e24fa057",
"id": "7fe2e8a9",
"metadata": {
"lines_to_next_cell": 0
},
Expand Down Expand Up @@ -34,21 +34,21 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "0bee44b5",
"id": "9dfdb29c",
"metadata": {
"execution": {
"iopub.execute_input": "2024-03-05T02:09:57.643688Z",
"iopub.status.busy": "2024-03-05T02:09:57.643688Z",
"iopub.status.idle": "2024-03-05T02:10:20.869598Z",
"shell.execute_reply": "2024-03-05T02:10:20.869066Z"
"iopub.execute_input": "2024-03-07T19:37:57.987744Z",
"iopub.status.busy": "2024-03-07T19:37:57.987744Z",
"iopub.status.idle": "2024-03-07T19:38:26.669303Z",
"shell.execute_reply": "2024-03-07T19:38:26.669178Z"
},
"lines_to_next_cell": 2
},
"outputs": [
{
"data": {
"text/plain": [
"\"Hello! I'm here to help you with any questions you have about statistics or data analysis. Statistics is the science of extracting meaning from data, and it's a fundamental part of many fields, including business, economics, engineering, biology, psychology, and many others. I can help you understand statistical concepts, explain the results of statistical analyses, and provide guidance on how to design experiments and surveys to collect data. I can also help you learn how to use statistical software packages, such as R or SAS, to perform your own data analyses. So, what can I help you with today?\""
"\"Hello! I'm here to help you with any questions you have about art, design, or creative projects. Do you have something you'd like to work on or discuss? I'd be happy to help!\\n\\nIn the meantime, here are a few tips for getting started on a new art or design project:\\n\\n1. Define your goals: What do you want to achieve with your project? Do you want to create a finished piece of art, or are you looking to explore a particular technique or concept? Having clear goals in mind will help you stay focused and motivated as you work.\\n2. Gather inspiration: Look for examples of work that inspire you and take note of what you like about them. This can help you clarify your own goals and give you ideas for how to approach your project.\\n3. Create a plan: Outline the steps you'll need to take to complete your project. This can help you stay organized and ensure that you don't forget any important details.\\n4. Experiment and play: Don't be afraid to try new techniques or materials, and allow yourself the freedom to make mistakes. The creative process is often messy and unpredictable, but it's also an opportunity to learn and grow as an artist.\\n5. Seek feedback: Share your work with others and be open to constructive criticism. This can help you see your work from new perspectives and give you ideas for how to improve.\\n\\nI hope these tips are helpful as you begin your project! Let me know if you have any questions or if there's anything else I can do to support you.\""
]
},
"execution_count": 1,
Expand All @@ -72,7 +72,7 @@
},
{
"cell_type": "markdown",
"id": "a7dd12ba",
"id": "3eddb829",
"metadata": {},
"source": [
"\n",
Expand All @@ -82,13 +82,13 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "9711b38b",
"id": "326e2adb",
"metadata": {
"execution": {
"iopub.execute_input": "2024-03-05T02:10:20.874140Z",
"iopub.status.busy": "2024-03-05T02:10:20.873138Z",
"iopub.status.idle": "2024-03-05T02:10:27.090576Z",
"shell.execute_reply": "2024-03-05T02:10:27.089706Z"
"iopub.execute_input": "2024-03-07T19:38:26.674019Z",
"iopub.status.busy": "2024-03-07T19:38:26.673012Z",
"iopub.status.idle": "2024-03-07T19:38:27.470128Z",
"shell.execute_reply": "2024-03-07T19:38:27.468876Z"
}
},
"outputs": [],
Expand Down
26 changes: 13 additions & 13 deletions doc/code/azure_completions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "ba63f856",
"id": "89bae068",
"metadata": {},
"source": [
"## Introduction\n",
Expand All @@ -22,13 +22,13 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "1f21a46b",
"id": "57fe92b4",
"metadata": {
"execution": {
"iopub.execute_input": "2024-03-05T02:10:29.662443Z",
"iopub.status.busy": "2024-03-05T02:10:29.662443Z",
"iopub.status.idle": "2024-03-05T02:10:29.697833Z",
"shell.execute_reply": "2024-03-05T02:10:29.697833Z"
"iopub.execute_input": "2024-03-07T19:38:32.178074Z",
"iopub.status.busy": "2024-03-07T19:38:32.178074Z",
"iopub.status.idle": "2024-03-07T19:38:32.203814Z",
"shell.execute_reply": "2024-03-07T19:38:32.203814Z"
}
},
"outputs": [],
Expand All @@ -45,7 +45,7 @@
},
{
"cell_type": "markdown",
"id": "aff22344",
"id": "6b4b4aac",
"metadata": {},
"source": [
"## Azure OpenAI Completions\n",
Expand All @@ -58,21 +58,21 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "e0494286",
"id": "781baae0",
"metadata": {
"execution": {
"iopub.execute_input": "2024-03-05T02:10:29.702352Z",
"iopub.status.busy": "2024-03-05T02:10:29.701351Z",
"iopub.status.idle": "2024-03-05T02:10:31.461737Z",
"shell.execute_reply": "2024-03-05T02:10:31.460448Z"
"iopub.execute_input": "2024-03-07T19:38:32.207668Z",
"iopub.status.busy": "2024-03-07T19:38:32.207668Z",
"iopub.status.idle": "2024-03-07T19:38:33.747647Z",
"shell.execute_reply": "2024-03-07T19:38:33.746642Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"PromptResponse(completion=\" then, do speaking i'd let de多u say sh post tonight, did\", prompt='hello world!', id='cmpl-8zEYB8RZU62871cLf6edq6oykl5lT', completion_tokens=16, prompt_tokens=3, total_tokens=19, model='davinci-002', object='text_completion', created_at=0, logprobs=False, index=0, finish_reason='', api_request_time_to_complete_ns=0, metadata={})\n"
"PromptResponse(completion=\" and ... - Geoff's Blog :: Interesting things from around the net... is the\", prompt='hello world!', id='cmpl-90DrVhexmTUx3tQEir5NzFFECXL3I', completion_tokens=16, prompt_tokens=3, total_tokens=19, model='davinci-002', object='text_completion', created_at=0, logprobs=False, index=0, finish_reason='', api_request_time_to_complete_ns=0, metadata={})\n"
]
}
],
Expand Down
50 changes: 25 additions & 25 deletions doc/code/azure_embeddings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "4c42748c",
"id": "5dd1cca7",
"metadata": {},
"source": [
"## Azure OpenAI Embeddings\n",
Expand All @@ -13,13 +13,13 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "e6a804d8",
"id": "7b3f1bb7",
"metadata": {
"execution": {
"iopub.execute_input": "2024-03-05T02:10:34.122646Z",
"iopub.status.busy": "2024-03-05T02:10:34.122646Z",
"iopub.status.idle": "2024-03-05T02:10:35.458106Z",
"shell.execute_reply": "2024-03-05T02:10:35.458106Z"
"iopub.execute_input": "2024-03-07T19:38:37.718933Z",
"iopub.status.busy": "2024-03-07T19:38:37.718933Z",
"iopub.status.idle": "2024-03-07T19:38:39.164054Z",
"shell.execute_reply": "2024-03-07T19:38:39.163049Z"
}
},
"outputs": [
Expand Down Expand Up @@ -50,7 +50,7 @@
},
{
"cell_type": "markdown",
"id": "993ae38d",
"id": "09b5e11d",
"metadata": {},
"source": [
"\n",
Expand All @@ -62,7 +62,7 @@
},
{
"cell_type": "markdown",
"id": "8416b38f",
"id": "29f35a81",
"metadata": {},
"source": [
"To view the json of an embedding"
Expand All @@ -71,13 +71,13 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "a619f1a6",
"id": "7bbea889",
"metadata": {
"execution": {
"iopub.execute_input": "2024-03-05T02:10:35.464159Z",
"iopub.status.busy": "2024-03-05T02:10:35.462788Z",
"iopub.status.idle": "2024-03-05T02:10:35.481367Z",
"shell.execute_reply": "2024-03-05T02:10:35.481259Z"
"iopub.execute_input": "2024-03-07T19:38:39.166053Z",
"iopub.status.busy": "2024-03-07T19:38:39.166053Z",
"iopub.status.idle": "2024-03-07T19:38:39.179311Z",
"shell.execute_reply": "2024-03-07T19:38:39.178318Z"
}
},
"outputs": [
Expand All @@ -98,7 +98,7 @@
},
{
"cell_type": "markdown",
"id": "352871b4",
"id": "f30708f6",
"metadata": {},
"source": [
"To save an embedding to disk"
Expand All @@ -107,13 +107,13 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "31a90ab7",
"id": "88ff3169",
"metadata": {
"execution": {
"iopub.execute_input": "2024-03-05T02:10:35.485382Z",
"iopub.status.busy": "2024-03-05T02:10:35.485382Z",
"iopub.status.idle": "2024-03-05T02:10:35.496063Z",
"shell.execute_reply": "2024-03-05T02:10:35.496063Z"
"iopub.execute_input": "2024-03-07T19:38:39.180310Z",
"iopub.status.busy": "2024-03-07T19:38:39.180310Z",
"iopub.status.idle": "2024-03-07T19:38:39.196388Z",
"shell.execute_reply": "2024-03-07T19:38:39.196388Z"
}
},
"outputs": [
Expand All @@ -137,7 +137,7 @@
},
{
"cell_type": "markdown",
"id": "2ab598c4",
"id": "17acc78f",
"metadata": {
"lines_to_next_cell": 2
},
Expand All @@ -148,13 +148,13 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "6db31f3e",
"id": "02cb2fa4",
"metadata": {
"execution": {
"iopub.execute_input": "2024-03-05T02:10:35.499680Z",
"iopub.status.busy": "2024-03-05T02:10:35.499680Z",
"iopub.status.idle": "2024-03-05T02:10:35.513224Z",
"shell.execute_reply": "2024-03-05T02:10:35.512406Z"
"iopub.execute_input": "2024-03-07T19:38:39.197393Z",
"iopub.status.busy": "2024-03-07T19:38:39.197393Z",
"iopub.status.idle": "2024-03-07T19:38:39.212610Z",
"shell.execute_reply": "2024-03-07T19:38:39.212610Z"
}
},
"outputs": [
Expand Down
20 changes: 14 additions & 6 deletions doc/code/azure_openai_chat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "6278cf21",
"id": "b4f94849",
"metadata": {},
"source": [
"\n",
Expand All @@ -18,13 +18,13 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "10836222",
"id": "4dce2263",
"metadata": {
"execution": {
"iopub.execute_input": "2024-03-05T02:14:18.429571Z",
"iopub.status.busy": "2024-03-05T02:14:18.429571Z",
"iopub.status.idle": "2024-03-05T02:14:24.322225Z",
"shell.execute_reply": "2024-03-05T02:14:24.321718Z"
"iopub.execute_input": "2024-03-07T19:38:43.107748Z",
"iopub.status.busy": "2024-03-07T19:38:43.107748Z",
"iopub.status.idle": "2024-03-07T19:38:50.177544Z",
"shell.execute_reply": "2024-03-07T19:38:50.177037Z"
}
},
"outputs": [
Expand Down Expand Up @@ -52,6 +52,14 @@
"\n",
"chat_engine.complete_chat(messages=[ChatMessage(role=\"user\", content=\"Hello world!\")])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "819ee7c0",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
57 changes: 51 additions & 6 deletions doc/code/memory.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "34a32deb",
"id": "924dc277",
"metadata": {},
"source": [
"The `pyrit.memory` module provides functionality to keep track of the conversation history. In a nutshell, this can be used as follows"
Expand All @@ -11,13 +11,13 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "1f691098",
"id": "9e50ff4e",
"metadata": {
"execution": {
"iopub.execute_input": "2024-03-05T02:14:33.752113Z",
"iopub.status.busy": "2024-03-05T02:14:33.752113Z",
"iopub.status.idle": "2024-03-05T02:14:35.490072Z",
"shell.execute_reply": "2024-03-05T02:14:35.490072Z"
"iopub.execute_input": "2024-03-07T19:38:54.927385Z",
"iopub.status.busy": "2024-03-07T19:38:54.927385Z",
"iopub.status.idle": "2024-03-07T19:38:57.060134Z",
"shell.execute_reply": "2024-03-07T19:38:57.060134Z"
}
},
"outputs": [
Expand Down Expand Up @@ -59,6 +59,51 @@
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
rlundeen2 marked this conversation as resolved.
Show resolved Hide resolved
" ChatMessage(role='user', content='Hi, chat bot! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot!! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot!! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot!! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot!! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot!! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot!! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot!! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot!! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot!! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.'),\n",
" ChatMessage(role='user', content='Hi, chat bot! This is my initial prompt.'),\n",
" ChatMessage(role='assistant', content='Nice to meet you! This is my response.'),\n",
" ChatMessage(role='user', content='Wonderful! This is my second prompt to the chat bot.')]"
]
},
Expand Down
Loading
Loading