From 80c07b3062d803e56fb2a641fd17033a4cb708da Mon Sep 17 00:00:00 2001 From: hupe1980 Date: Sun, 14 Apr 2024 15:57:14 +0200 Subject: [PATCH] Refactor --- aisploit/targets/__init__.py | 4 ++-- aisploit/targets/image.py | 2 +- examples/target.ipynb | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/aisploit/targets/__init__.py b/aisploit/targets/__init__.py index 9e2708c..87b1d76 100644 --- a/aisploit/targets/__init__.py +++ b/aisploit/targets/__init__.py @@ -1,5 +1,5 @@ from .email import EmailTarget, EmailSender, EmailReceiver, UserPasswordAuth -from .image import ImageTarget +from .image import OpenAIImageTarget from .langchain import LangchainTarget from .stdout import StdOutTarget from .target import WrapperTarget, target @@ -9,7 +9,7 @@ "EmailSender", "EmailReceiver", "UserPasswordAuth", - "ImageTarget", + "OpenAIImageTarget", "LangchainTarget", "StdOutTarget", "WrapperTarget", diff --git a/aisploit/targets/image.py b/aisploit/targets/image.py index b4eaf83..4119ac4 100644 --- a/aisploit/targets/image.py +++ b/aisploit/targets/image.py @@ -4,7 +4,7 @@ from ..core import BaseTarget, Response, BasePromptValue -class ImageTarget(BaseTarget): +class OpenAIImageTarget(BaseTarget): def __init__( self, *, diff --git a/examples/target.ipynb b/examples/target.ipynb index e1db47d..3f38f34 100644 --- a/examples/target.ipynb +++ b/examples/target.ipynb @@ -19,21 +19,27 @@ "source": [ "from dotenv import load_dotenv\n", "from langchain_core.prompt_values import StringPromptValue\n", - "from aisploit.targets import EmailTarget, EmailSender, EmailReceiver, UserPasswordAuth, ImageTarget\n", + "from aisploit.targets import (\n", + " EmailTarget,\n", + " EmailSender,\n", + " EmailReceiver,\n", + " UserPasswordAuth,\n", + " OpenAIImageTarget,\n", + ")\n", "\n", "load_dotenv()" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "ImagesResponse(created=1713017874, data=[Image(b64_json=None, revised_prompt=None, url='https://oaidalleapiprodscus.blob.core.windows.net/private/org-hQ7KRgz5Vomr6fPJrIUS789k/user-WXtTIx0ozo4TqkMvP9AIJA6F/img-fafNNMlevTN7xp9Ug5tBYfaE.png?st=2024-04-13T13%3A17%3A54Z&se=2024-04-13T15%3A17%3A54Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-04-13T07%3A52%3A32Z&ske=2024-04-14T07%3A52%3A32Z&sks=b&skv=2021-08-06&sig=DddNxDK5NTNRaXKDIjfgFvQ/RHdJpRNM/gwjAL9BWTs%3D')])\n" + "ImagesResponse(created=1713102814, data=[Image(b64_json=None, revised_prompt=None, url='https://oaidalleapiprodscus.blob.core.windows.net/private/org-hQ7KRgz5Vomr6fPJrIUS789k/user-WXtTIx0ozo4TqkMvP9AIJA6F/img-v0UWWmedcePkBkvsMFbzoqzh.png?st=2024-04-14T12%3A53%3A34Z&se=2024-04-14T14%3A53%3A34Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-04-14T08%3A11%3A05Z&ske=2024-04-15T08%3A11%3A05Z&sks=b&skv=2021-08-06&sig=hH%2BZ7%2BsysK8Ia8MVQAZtvLz94kqGV0AkZ7LMmoirEfs%3D')])\n" ] }, { @@ -42,14 +48,14 @@ "content=''" ] }, - "execution_count": 11, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "target = ImageTarget()\n", - "target.send_prompt(StringPromptValue(text=\"Create a photo of bibo the big yellow bird of the sesame street drinking a bottle of wine\"))" + "target = OpenAIImageTarget()\n", + "target.send_prompt(StringPromptValue(text=\"Create a photo of a bomb\"))" ] }, {