Skip to content

Commit

Permalink
Merge pull request #18924 from umaannamalai/python-agent-10.1.0-release
Browse files Browse the repository at this point in the history
Python agent 10.1.0 release
  • Loading branch information
akristen authored Oct 10, 2024
2 parents e43a629 + b811689 commit 951459f
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ In many cases, the endpoint for AI messages are recorded in different places fro
</tbody>
</table>

## Return values [#return-valuess]
## Return values [#return-values]

None.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
title: WithLlmCustomAttributes (Python agent API)
type: apiDoc
shortDescription: Add custom attributes to LLM events
tags:
- Agents
- Python agent
- Python agent API
metaDescription: 'Python API: This API adds custom attributes to a Large Language Model (LLM) events generated in AI applications.'
redirects:
- /docs/agents/python-agent/python-agent-api/withllmcustomattributes-python-agent-api
- /docs/agents/python-agent/python-agent-api/withllmcustomattributes
freshnessValidatedDate: never
---

## Syntax [#syntax]

```py
with newrelic.agent.WithLlmCustomAttributes(custom_attribute_map):
```

Context manager API that adds user-specified attributes to Large Language Model (LLM) events generated by LLM calls in application code.

## Requirements [#requirements]

Python agent version 10.1.0 or higher.

## Description [#description]

This context manager API adds custom user-specified attributes to each LLM event generated within its context based on calls made to LLMs.
The agent will automatically add an `llm.` prefix to each custom attribute key name specified in the passed in dictionary argument.
This API must be called within the context of an active transaction.

These custom attributes can be viewed on LLM events and queried for in the New Relic UI. For more information on AI Monitoring, see our [AI docs](https://docs.newrelic.com/docs/ai-monitoring/intro-to-ai-monitoring/).


## Parameters [#parameters]

<table>
<thead>
<tr>
<th width="25%">
Parameter
</th>

<th>
Description
</th>
</tr>
</thead>

<tbody>
<tr>
<td>
`custom_attribute_map`

_dictionary_
</td>

<td>
Required. A non-empty dictionary where each key-value pair indicates the custom attribute name and its respective value.
</td>
</tr>
</tbody>
</table>

## Return values [#return-values]

None.

## Examples [#examples]

### Add custom attributes to an OpenAI chat completion call


````py
import newrelic.agent

from openai import OpenAI

client = OpenAI()

with newrelic.agent.WithLlmCustomAttributes({"custom": "attr", "custom1": "attr1"}):
response = client.chat.completions.create(
messages=[{
"role": "user",
"content": "Say this is a test",
}],
model="gpt-4o-mini",
)
````
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
subject: 'Python agent'
releaseDate: '2024-10-10'
version: 10.1.0
downloadLink: 'https://pypi.python.org/pypi/newrelic'
features: ['Add support for Python 3.13', 'Add new LLM custom attribute context manager API', 'Add support for reporting of Amazon ECS Fargate Docker IDs', 'Add instrumentation for `SQLiteVec` vectorstore in Langchain']
bugs: []
security: []
---

## Notes

This release of the Python agent adds support for Python 3.13, adds a new Large Language Model (LLM) API, supports Docker ID parsing in Amazon ECS Fargate environments, and instruments a new Langchain vectorstore.


Install the agent using `easy_install/pip/distribute` via the [Python Package Index](https://pypi.python.org/pypi/newrelic) or download it directly from the [New Relic download site](https://download.newrelic.com/python_agent/release).


## New features

* Add support for Python 3.13

* The agent now supports applications running in Python 3.13.

* Add new LLM custom attribute context manager API

* The agent now includes a new context manager API that adds custom attributes to LLM events generated from calls to LLMs in application code. For more information on usage, please see our [API documentation](/docs/apm/agents/python-agent/python-agent-api/withllmcustomattributes-python-agent-api).

* Add support for reporting of [Amazon ECS Fargate](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html) Docker IDs

* The agent now reports Docker IDs for containers running in ECS Fargate environments.

* Add instrumentation for `SQLiteVec` vectorstore in Langchain

* The agent now instruments `similarity_search` for the `SQLiteVec` vectorstore.


## Support statement

We recommend updating to the latest agent version as soon as it's available. If you can't upgrade to the latest version, update your agents to a version no more than 90 days old. Read [more](/docs/new-relic-solutions/new-relic-one/install-configure/update-new-relic-agent/) about keeping agents up to date.

See the New Relic Python agent [EOL policy](/docs/apm/agents/python-agent/getting-started/python-agent-eol-policy/) for information about agent releases and support dates.

0 comments on commit 951459f

Please sign in to comment.