import os
from openpipe import OpenPipe, OpenAI
from openpipe.client import UpdateLogTagsRequestFiltersItem
# Find the config values in "Installing the SDK"
client = OpenAI()
op_client = OpenPipe(
# defaults to os.environ["OPENPIPE_API_KEY"]
api_key="YOUR_API_KEY"
)
completion = client.chat.completions.create(
model="openpipe:your-fine-tuned-model-id",
messages=[{"role": "system", "content": "count to 10"}],
metadata={"prompt_id": "counting", "tag_to_remove": "some value"},
)
resp = op_client.update_log_metadata(
filters=[
UpdateLogTagsRequestFiltersItem(
field="completionId",
equals=completion.id,
),
# completionId is the only filter necessary in this case, but let's add a couple more examples
UpdateLogTagsRequestFiltersItem(
field="model",
equals="openpipe:your-fine-tuned-model-id",
),
UpdateLogTagsRequestFiltersItem(
field="metadata.prompt_id",
equals="counting",
),
],
metadata={
"relabel": "true",
"tag_to_remove": None # this will remove the tag_to_remove tag from the request log we just created
},
)
assert resp.matched_logs == 1