Git Product home page Git Product logo

Comments (8)

romanlutz avatar romanlutz commented on September 2, 2024 2

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.

rdheekonda avatar rdheekonda commented on September 2, 2024 1

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
image

No "gpt-4" model available.
image

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.
image

from pyrit.

reinbugnot avatar reinbugnot commented on September 2, 2024 1

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.

rdheekonda avatar rdheekonda commented on September 2, 2024

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.

reinbugnot avatar reinbugnot commented on September 2, 2024

Thank you for your prompt responses!

I tried running the code provided, and it gave me the following error:

image

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.

romanlutz avatar romanlutz commented on September 2, 2024

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.

reinbugnot avatar reinbugnot commented on September 2, 2024

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:
image

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.

reinbugnot avatar reinbugnot commented on September 2, 2024

I think I was able to fix the endpoint part, but my deployment_name input is still incorrect. Where do I get this information?

image

Thank you for your help and sorry for the noob questions!

from pyrit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.