Quickstart
Python
The prompt engineering, prompt management, and prompt evaluation tool for Python.
Installation
Install the Prompt Foundry SDK
pip install prompt_foundry_python_sdk
Usage
The full API of this library can be found in the API Reference page by selecting Python in the interactive examples.
OpenAI Integration
Install the OpenAI SDK
pip install openai
Import the OpenAI and Prompt Foundry SDKs
import os
from prompt_foundry_python_sdk import PromptFoundry
from openai import OpenAI
# Initialize Prompt Foundry SDK with your API key
pf = PromptFoundry(
api_key=os.environ.get("PROMPT_FOUNDRY_API_KEY"),
)
# Initialize OpenAI SDK with your API key
openai = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"),
)
# Retrieve model parameters for the prompt
model_parameters = pf.prompts.get_parameters(
"667889e9a064582d050b8055",
variables={"hello": "world"},
)
# Use the retrieved parameters to create a chat completion request
chat_completion = openai.chat.completions.create(**vars(model_parameters.parameters))
# Print the response from OpenAI
print(chat_completion)
Additional Information
For more details, visit the GitHub Repo.