Comments (8)
Are you using a release version of the latest main branch?
In the latest main branch there's OpenAITarget
which should fit your use case (https://github.com/Azure/PyRIT/blob/main/pyrit/prompt_target/openai_chat_target.py)
from pyrit.
Based on the problem you're experiencing, the issue might be due to not having the "test" model listed in your OpenAI models, or it could be related to your OpenAI account's quota limit for accessing these models.
I recently set up a new OpenAI account with a free trial and encountered the same error when trying to access models that were not available to me.
Code calling "gpt-4" model from OpenAI
I suggest verifying that the "test" model is part of your OpenAI models collection. If it's not available, then I'd suggest taking the sample model available, such as gpt-3.5-turbo
value (if it's available) from the "Model" dropdown menu for deployment_name
.
If the above suggested solution doesn't resolve the issue, ensure that your account is correctly configured with enough credit to access these models. Access to these models is not included in the free tier.
from pyrit.
Thank you so much for your help! I was able to make it work on the basic gpt 3.5. It does seem that I had some issues setting up our model. Thank you.
from pyrit.
It seems you're utilizing AzureOpenAIChatTarget
which is meant to interact with Azure OpenAI endpoints. If your intention is to use the OpenAI chat target, I recommend the following code. Please execute this code, and don't hesitate to contact us if you face any problems.
Before executing the code, make sure to configure the necessary environment variables.
import os
from pyrit.common import default_values
from pyrit.prompt_target import OpenAIChatTarget
from pyrit.models import ChatMessage
default_values.load_default_env()
target_llm = OpenAIChatTarget(
deployment_name=os.environ.get("OPENAI_CHAT_KEY"),
endpoint=os.environ.get("OPENAI_CHAT_ENDPOINT"),
api_key=os.environ.get("OPENAI_CHAT_DEPLOYMENT"),
)
prompt = "test"
target_llm.complete_chat(messages=[ChatMessage(content=prompt, role="user")])
from pyrit.
Thank you for your prompt responses!
I tried running the code provided, and it gave me the following error:
It seems as though my PyRIT cannot find the OpenAIChatTarget function from pyrit.prompt_target.
I installed PyRIT using pip install pyrit
as instructed in doc/setup/install_pyrit.md. My current python version is Python 3.10.13
Is there an alternative installation/update method that I need to do to fix this?
Thank you for your help!
from pyrit.
The pyrit version is the one that matters. If you follow the instructions in the "bug report" issue template you'll find this:
Please provide the following information:
- OS: [e.g. Windows]
- Browser (if you're reporting a bug in jupyter): [e.g. Edge, Firefox, Chrome, Safari]
- Python version: [e.g. 3.10.11]
- PyRIT version: [e.g. 0.1.0 or installed from main branch in editable mode]
- version of Python packages: please run the following snippet and paste the output:
import pyrit pyrit.show_versions()
I suspect you're using v0.1.1 rather than 0.1.2. This is newly added there.
from pyrit.
Thank you for your response!
It does seem like my PyRIT version was outdated. I upgraded to PyRIT 0.1.2 and i think it's able to accept my OpenAI key.
However, I seem to be having trouble with specifying the correct API endpoint and deployment name. I did as follows:
import os
from pyrit.common import default_values
from pyrit.prompt_target import OpenAIChatTarget
from pyrit.models import ChatMessage
default_values.load_default_env()
target_llm = OpenAIChatTarget(
api_key=os.environ.get("OPENAI_API_KEY_NUS"),
deployment_name="test"
endpoint="https://api.openai.com/v1/chat/completions"
)
prompt = "test"
target_llm.complete_chat(messages=[ChatMessage(content=prompt, role="user")])
Which resulted in the following error:
I suspect that I'm not constructing my API endpoint in the expected format. There does not seem to be any available documentation that I could follow regarding this.
May I kindly ask for your help once again about this matter?
Thank you
from pyrit.
I think I was able to fix the endpoint part, but my deployment_name
input is still incorrect. Where do I get this information?
Thank you for your help and sorry for the noob questions!
from pyrit.
Related Issues (20)
- Using AzureMLChatTarget raises 404 and 405 errors HOT 3
- Gandalf example not working HOT 4
- bug: Azure SQL Tests Fail in MacOS M1 HOT 2
- Add adaptive jailbreaking
- Add fetch function for SecLists AI LLM Bias Testing datasets HOT 2
- Add fetch function for datasets from HarmBench
- Getting "404 Resource Not Found" HOT 3
- FEAT Metadata for datasets should allow fields as string OR list of strings
- gandalf example error (Failed to add request response to memory) HOT 3
- Got a new Jailbreak Prompt HOT 1
- FEAT add XSTest dataset
- FEAT add DecodingTrust dataset
- FEAT: Add Azure OpenAI GPT-4o target for pyrit
- Unable to get pyrit working after the change HOT 11
- [BUG] Black-pre-commit hook language-version binding causing installation issues.
- Where is the demo code? HOT 2
- Does PyRIT support to test websocket? HOT 2
- Ollama Support and Initial Run Documentation HOT 12
- FEAT Add Copilot Target
- FEAT Local Hugging Face model support HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyrit.