Skip to content

Commit

Permalink
FIX: used PromptRequestResponse.converted_value instead PromptRequest…
Browse files Browse the repository at this point in the history
…Response.converted_value_data_type in GPTV target (#179)

Co-authored-by: Raja Sekhar Rao Dheekonda <[email protected]>
  • Loading branch information
rdheekonda and Raja Sekhar Rao Dheekonda authored Apr 29, 2024
1 parent 989adaa commit 959101a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
22 changes: 9 additions & 13 deletions doc/code/targets/gpt_v_target.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
"None: assistant: The picture shows a chart with the title \"PyRIT Components\" at the top. The chart is divided into two columns, with \"Interface\" on the left and \"Implementation\" on the right. Underneath the columns, there are five rows, each labeled with a different component of PyRIT. \n",
"None: assistant: The picture is a table listing the components of PyRIT, which stands for \"Python Rapid Information Toolkit\". The table has two columns labeled \"Interface\" and \"Implementation\". Under the Interface column, there are five rows: Target, Datasets, Scoring Engine, Attack Strategy and Memory. Each row in the Interface column has corresponding implementations in the Implementation column.\n",
"\n",
"The first row is labeled \"Target\" and includes two types of implementation: \"Local,\" which specifies local model (e.g., ONNX), and \"Remote,\" which mentions API or web app.\n",
"\n",
"The second row is labeled \"Datasets\" and includes two types of implementation as well: \"Static,\" which specifies prompts, and \"Dynamic,\" which mentions prompt templates.\n",
"\n",
"The third row is labeled \"Scoring Engine\" and includes only one type of implementation: PyRIT itself for self-evaluation and API for existing content classifiers.\n",
"\n",
"The fourth row is labeled \"Attack Strategy\" and also has two implementations: \"Single Turn,\" which uses static prompts, and \"Multi-Turn,\" which involves multiple conversations using prompt templates.\n",
"\n",
"The last row is labeled “Memory” with “Storage” specifying JSON and database. There is also “Utils,” mentioning conversation, retrieval and storage, memory sharing, data analysis.\n"
"For the Target interface, there are two types of implementation: Local (local model e.g., ONNX) and Remote (API or web app). \n",
"For the Datasets interface, there are two types of implementation: Static prompts and Dynamic prompt templates.\n",
"For the Scoring Engine interface, there is one type of implementation: PyRIT itself with self-evaluation and API with existing content classifiers.\n",
"For the Attack Strategy interface, there are two types of implementation: Single Turn using static prompts and Multi Turn involving multiple conversations using prompt templates.\n",
"For the Memory interface, there are several types of implementation including Storage (JSON Database), Utils for conversation retrieval and storage, memory sharing and data analysis.\n"
]
}
],
Expand All @@ -126,9 +122,9 @@
"cell_metadata_filter": "-all"
},
"kernelspec": {
"display_name": "pyrit-311",
"display_name": "pyrit-dev",
"language": "python",
"name": "pyrit-311"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -140,7 +136,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ async def send_prompt_async(self, *, prompt_request: PromptRequestResponse) -> P
Returns:
PromptRequestResponse: The updated conversation entry with the response from the prompt target.
"""
self.validate_request(prompt_request=prompt_request)
request: PromptRequestPiece = prompt_request.request_pieces[0]

prompt_req_res_entries = self._memory.get_conversation(conversation_id=request.conversation_id)
Expand Down Expand Up @@ -300,7 +301,9 @@ def validate_request(self, *, prompt_request: PromptRequestResponse) -> None:
if len(prompt_request.request_pieces) > 2:
raise ValueError("This target only supports a two prompt request pieces text and image_path.")

converted_prompt_data_types = [request_piece.converted_value for request_piece in prompt_request.request_pieces]
converted_prompt_data_types = [
request_piece.converted_value_data_type for request_piece in prompt_request.request_pieces
]
for prompt_data_type in converted_prompt_data_types:
if prompt_data_type not in ["text", "image_path"]:
raise ValueError("This target only supports text and image_path.")

0 comments on commit 959101a

Please sign in to comment.