Skip to content

Commit 52e60ba

Browse files
Copilotslister1001
andcommitted
Conform red team user agent to Azure AI Evaluation SDK format
- Updated user agent to use format: azure-ai-evaluation/1.9.0 (type=redteam; subtype=RedTeam) - Leverages existing add_useragent_product infrastructure - Maintains backward compatibility with existing evaluator patterns - Removes separate red team user agent string in favor of standard SDK format Co-authored-by: slister1001 <[email protected]>
1 parent fa2d637 commit 52e60ba

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_user_agent.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99

1010
class UserAgentSingleton:
1111
__BASE_USER_AGENT: str = "{}/{}".format("azure-ai-evaluation", VERSION)
12-
__REDTEAM_USER_AGENT: str = "{}-redteam/{}".format("azure-ai-evaluation", VERSION)
13-
__is_redteam_context: bool = False
1412

1513
@property
1614
def value(self):
1715
"""Get the user-agent"""
18-
return self.__REDTEAM_USER_AGENT if self.__is_redteam_context else self.__BASE_USER_AGENT
16+
return self.__BASE_USER_AGENT
1917

2018
def __str__(self) -> str:
2119
return self.value
@@ -43,12 +41,8 @@ def add_useragent_product(cls, *product: str) -> Iterator[None]:
4341
def redteam_context(cls) -> Iterator[None]:
4442
"""Context manager to use red team user agent for RAI service calls
4543
46-
This context manager temporarily sets the user agent to "azure-ai-evaluation-redteam"
44+
This context manager temporarily sets the user agent to include red team context
4745
for all calls within the context.
4846
"""
49-
old_context = cls.__is_redteam_context
50-
cls.__is_redteam_context = True
51-
52-
yield
53-
54-
cls.__is_redteam_context = old_context
47+
with cls.add_useragent_product("(type=redteam; subtype=RedTeam)"):
48+
yield

0 commit comments

Comments
 (0)