Skip to content

feat(portkey): Add support for propmt template calls #1663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2025

Conversation

Aemrox
Copy link
Collaborator

@Aemrox Aemrox commented May 22, 2025

Resolves #1573

If prompt_id and prompt_variables are present in the invocation params it maps them to the span attributes prompt_id and llm.prompt_template.variables. Also wraps a the Prompt.completions function in the existing completion wrapper to ensure those spans are created.

Screenshots below
Screenshot 2025-05-22 at 1 26 58 PM
Screenshot 2025-05-22 at 1 26 52 PM

@Aemrox Aemrox requested a review from a team as a code owner May 22, 2025 18:29
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 22, 2025
Copy link
Contributor

github-actions bot commented May 22, 2025

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@Aemrox
Copy link
Collaborator Author

Aemrox commented May 22, 2025

I have read the CLA Document and I hereby sign the CLA

@harrisonchu
Copy link
Contributor

@cla-assistant check

@harrisonchu
Copy link
Contributor

recheck

Comment on lines +56 to +57
if prompt_id := invocation_params.get("prompt_id"):
yield SpanAttributes.PROMPT_ID, prompt_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should put the prompt.provider here too for clarity, just put portkey in there

@@ -53,6 +53,12 @@ def get_extra_attributes_from_request(

yield SpanAttributes.LLM_INVOCATION_PARAMETERS, safe_json_dumps(invocation_params)

if prompt_id := invocation_params.get("prompt_id"):
yield SpanAttributes.PROMPT_ID, prompt_id

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like you can produce a prompt URL pretty easily if you can: https://app.portkey.ai/prompts/ecc1de52-83dc-4846-a963-8d69f86dfee3 for example

@mikeldking
Copy link
Contributor

example prompt URL. I guess you have to parse out the URL so feel free to punt but might be nice to have a link to it.
Screenshot 2025-05-22 at 1 30 44 PM

@Aemrox Aemrox force-pushed the fix/port-key-prompt-id branch from e1b7557 to 011a9be Compare May 22, 2025 19:37
github-actions bot added a commit that referenced this pull request May 22, 2025
Adam May added 2 commits May 22, 2025 15:40
…per, but add functionality to place the prompt id and variables within the span attributes - tests included
@Aemrox Aemrox force-pushed the fix/port-key-prompt-id branch from 011a9be to 6fb030b Compare May 22, 2025 19:40
@Aemrox
Copy link
Collaborator Author

Aemrox commented May 22, 2025

I have read the CLA Document and I hereby sign the CLA

@Aemrox Aemrox merged commit c1e813e into main May 22, 2025
10 checks passed
@Aemrox Aemrox deleted the fix/port-key-prompt-id branch May 22, 2025 20:04
This was referenced May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[feature request]portkey instrumentation: prompt-template support
3 participants