Im triying to do a basic PyRIT project but im not able to use the AzureOpenAI with PyRIT.
I have this code woking, but not with PyRIT:
from openai import AzureOpenAI
client = AzureOpenAI(
api_key="myApiKey",
azure_endpoint="myEndpoint"
)
try:
response = client.chat.completions.create(
model="myModel",
messages=[
{"role": "system", "content": "You're a helpful assistant."},
{"role": "user", "content": "Hello, how are you?"}
],
temperature=0.0
)
print(response.choices[0].message.content)
except Exception as e:
print(f"Error: {e}")
This code works, but now i want to use PyRIT.
This is my PyRIT code:
from pyrit.common import IN_MEMORY, initialize_pyrit
from pyrit.orchestrator import PromptSendingOrchestrator
from pyrit.prompt_target import OpenAIChatTarget
initialize_pyrit(memory_db_type=IN_MEMORY)
prompt = "Hello, how are you?"
target = OpenAIChatTarget(
endpoint="myEndpoint",
api_key="myApiKey"
)
orchestrator = PromptSendingOrchestrator(target)
response = await orchestrator.send_prompts_async(prompt_list=[prompt]) # type: ignore
await orchestrator.print_conversations_async() # type: ignore
This code always return this Exception: Error sending prompt with conversation ID: "anyConversationIDThere."
I tried different ways to connect with the API but always fails the code.
Any idea?

api-version=2023-03-15-preview.