Skip to content
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

Add ingest source to openai events #961

Merged
merged 7 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions newrelic/hooks/mlmodel_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def wrap_embedding_create(wrapped, instance, args, kwargs):
response_headers, "x-ratelimit-remaining-requests", True
),
"vendor": "openAI",
"ingest_source": "Python",
}

transaction.record_ml_event("LlmEmbedding", embedding_dict)
Expand Down Expand Up @@ -208,6 +209,7 @@ def wrap_chat_completion_create(wrapped, instance, args, kwargs):
response_headers, "x-ratelimit-remaining-requests", True
),
"vendor": "openAI",
"ingest_source": "Python",
"response.number_of_messages": len(messages) + len(choices),
}

Expand Down Expand Up @@ -275,6 +277,7 @@ def create_chat_completion_message_event(
"sequence": index,
"response.model": response_model,
"vendor": "openAI",
"ingest_source": "Python",
}
transaction.record_ml_event("LlmChatCompletionMessage", chat_completion_message_dict)

Expand Down Expand Up @@ -353,6 +356,7 @@ async def wrap_embedding_acreate(wrapped, instance, args, kwargs):
response_headers, "x-ratelimit-remaining-requests", True
),
"vendor": "openAI",
"ingest_source": "Python",
}

transaction.record_ml_event("LlmEmbedding", embedding_dict)
Expand Down Expand Up @@ -449,6 +453,7 @@ async def wrap_chat_completion_acreate(wrapped, instance, args, kwargs):
response_headers, "x-ratelimit-remaining-requests", True
),
"vendor": "openAI",
"ingest_source": "Python",
}

transaction.record_ml_event("LlmChatCompletionSummary", chat_completion_summary_dict)
Expand Down
8 changes: 8 additions & 0 deletions tests/mlmodel_openai/test_chat_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"response.headers.ratelimitRemainingTokens": 39940,
"response.headers.ratelimitRemainingRequests": 199,
"vendor": "openAI",
"ingest_source": "Python",
"response.number_of_messages": 3,
},
),
Expand All @@ -83,6 +84,7 @@
"sequence": 0,
"response.model": "gpt-3.5-turbo-0613",
"vendor": "openAI",
"ingest_source": "Python",
},
),
(
Expand All @@ -101,6 +103,7 @@
"sequence": 1,
"response.model": "gpt-3.5-turbo-0613",
"vendor": "openAI",
"ingest_source": "Python",
},
),
(
Expand All @@ -119,6 +122,7 @@
"sequence": 2,
"response.model": "gpt-3.5-turbo-0613",
"vendor": "openAI",
"ingest_source": "Python",
},
),
]
Expand Down Expand Up @@ -175,6 +179,7 @@ def test_openai_chat_completion_sync_in_txn_with_convo_id(set_trace_info):
"response.headers.ratelimitRemainingTokens": 39940,
"response.headers.ratelimitRemainingRequests": 199,
"vendor": "openAI",
"ingest_source": "Python",
"response.number_of_messages": 3,
},
),
Expand All @@ -194,6 +199,7 @@ def test_openai_chat_completion_sync_in_txn_with_convo_id(set_trace_info):
"sequence": 0,
"response.model": "gpt-3.5-turbo-0613",
"vendor": "openAI",
"ingest_source": "Python",
},
),
(
Expand All @@ -212,6 +218,7 @@ def test_openai_chat_completion_sync_in_txn_with_convo_id(set_trace_info):
"sequence": 1,
"response.model": "gpt-3.5-turbo-0613",
"vendor": "openAI",
"ingest_source": "Python",
},
),
(
Expand All @@ -230,6 +237,7 @@ def test_openai_chat_completion_sync_in_txn_with_convo_id(set_trace_info):
"sequence": 2,
"response.model": "gpt-3.5-turbo-0613",
"vendor": "openAI",
"ingest_source": "Python",
},
),
]
Expand Down
1 change: 1 addition & 0 deletions tests/mlmodel_openai/test_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"response.headers.ratelimitRemainingTokens": 149994,
"response.headers.ratelimitRemainingRequests": 197,
"vendor": "openAI",
"ingest_source": "Python",
},
),
]
Expand Down
58 changes: 0 additions & 58 deletions tests/mlmodel_openai/test_error.py
TimPansino marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ deps =
framework_tornado: pycurl
framework_tornado-tornadolatest: tornado
framework_tornado-tornadomaster: https://github.com/tornadoweb/tornado/archive/master.zip
mlmodel_openai: openai[datalib]
mlmodel_openai: openai[datalib]<1.0
mlmodel_openai: protobuf
logger_loguru-logurulatest: loguru
logger_loguru-loguru06: loguru<0.7
Expand Down
Loading