Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion doc/code/targets/1_openai_chat_target.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,25 @@
"\n",
"- endpoint: The API endpoint (`OPENAI_CHAT_ENDPOINT` environment variable). For OpenAI, these are just \"https://api.openai.com/v1/chat/completions\". For Ollama, even though `/api/chat` is referenced in its official documentation, the correct endpoint to use is `/v1/chat/completions` to ensure compatibility with OpenAI's response format.\n",
"- auth: The API key for authentication (`OPENAI_CHAT_KEY` environment variable).\n",
"- model_name: The model to use (`OPENAI_CHAT_MODEL` environment variable). For OpenAI, these are any available model name and are listed here: \"https://platform.openai.com/docs/models\".\n"
"- model_name: The model to use (`OPENAI_CHAT_MODEL` environment variable). For OpenAI, these are any available model name and are listed here: \"https://platform.openai.com/docs/models\".\n",
"\n",
"## LM Studio Support\n",
"\n",
"You can also use `OpenAIChatTarget` with [LM Studio](https://lmstudio.ai), a desktop app for running local LLMs with OpenAI-like endpoints. To set it up with PyRIT:\n",
"\n",
"- Launch LM Studio, ensure a model is loaded, and verify that the API server is running (typically at `http://127.0.0.1:1234`).\n",
"- Be sure to configure your environment variables:\n",
" ```\n",
" OPENAI_CHAT_ENDPOINT=\"http://127.0.0.1:1234/v1/chat/completions\"\n",
" OPENAI_CHAT_MODEL=\"your-model-api-identifier\" # e.g., \"phi-3.1-mini-128k-instruct\"\n",
" ```\n"
]
}
],
"metadata": {
"jupytext": {
"main_language": "python"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
Expand Down
11 changes: 11 additions & 0 deletions doc/code/targets/1_openai_chat_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,14 @@
# - auth: The API key for authentication (`OPENAI_CHAT_KEY` environment variable).
# - model_name: The model to use (`OPENAI_CHAT_MODEL` environment variable). For OpenAI, these are any available model name and are listed here: "https://platform.openai.com/docs/models".
#
# ## LM Studio Support
#
# You can also use `OpenAIChatTarget` with [LM Studio](https://lmstudio.ai), a desktop app for running local LLMs with OpenAI-like endpoints. To set it up with PyRIT:
#
# - Launch LM Studio, ensure a model is loaded, and verify that the API server is running (typically at `http://127.0.0.1:1234`).
# - Be sure to configure your environment variables:
# ```
# OPENAI_CHAT_ENDPOINT="http://127.0.0.1:1234/v1/chat/completions"
# OPENAI_CHAT_MODEL="your-model-api-identifier" # e.g., "phi-3.1-mini-128k-instruct"
# ```
#