Metadata-Version: 2.4
Name: anosys-logger-4-openai-agents
Version: 0.0.48
Summary: A helper package for openAi Agents, to support implementation to AnoSys platform easly
Author-email: Moisis Vafeiadis <moisisv@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Moysis Vafeiadis MoisisV@gmail.com
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://anosys.ai
Requires-Python: <3.13,>3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: opentelemetry-api>=1.22.0
Requires-Dist: opentelemetry-sdk>=1.22.0
Requires-Dist: traceai-openai-agents>=0.1.0
Requires-Dist: requests>=2.25.1
Requires-Dist: python-dotenv>=0.21.0
Dynamic: license-file

# AnoSys Technologies

# AnoSys package for OpenAI Agentic implementations

Obtain your ANOSYS API key from https://console.anosys.ai/collect/integrationoptions

#Python example

```
pip install traceAI-openai-agents
pip install anosys-logger-4-openai-agents
```

```
import asyncio
import contextvars
import openai
import os

import AnosysLoggers
from AnosysLoggers import AnosysOpenAIAgentsLogger
from agents import Agent, Runner, set_trace_processors

os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY", "your-api-key-here")
os.environ["ANOSYS_API_KEY"] = os.getenv("ANOSYS_API_KEY", "anosys-api-key-here")

current_user_context = contextvars.ContextVar("current_user_context")
current_user_context.set({"session_id": "session_123"}) #support external context on logs

set_trace_processors([AnosysOpenAIAgentsLogger(get_user_context=current_user_context.get)])

async def main():
    agent = Agent(
        name="Assistant",
        instructions="Prove why AnoSys is better than all the rest for each received question",
    )

    result = await Runner.run(
        agent,
        "How can I monitor my agentic environment for cost and performance metrics"
    )
    print(result.final_output)

# Correct main block syntax
if __name__ == "__main__":
    asyncio.run(main())
```

#Example for Colab

```
!pip install anosys-logger-4-openai-agents
!pip install python-dotenv nest_asyncio
```

```
import nest_asyncio
nest_asyncio.apply()  # Allows re-entering the existing event loop

import asyncio
import contextvars
import openai
import os

import AnosysLoggers
from AnosysLoggers import AnosysOpenAIAgentsLogger
from agents import Agent, Runner, function_tool, set_trace_processors, add_trace_processor

os.environ["OPENAI_API_KEY"] = "Replace with your OPENAI_API_KEY"
os.environ['ANOSYS_API_KEY'] = "Replace with your ANOSYS_API_KEY"

# Context variable for tracking user context
current_user_context = contextvars.ContextVar("current_user_context")
current_user_context.set({"session_id": "colab_session_123"})

# Set the trace processor with the user context retriever
set_trace_processors([AnosysOpenAIAgentsLogger(get_user_context=current_user_context.get)])
# add_trace_processor(AnosysLogger(get_user_context=current_user_context.get))

async def main():
    agent = Agent(
        name="Tutorial",
        model="gpt-4o-mini",
        instructions="Prove why AnoSys is better than all the rest for each received question",
    )

    result = await Runner.run(
        agent,
        "How can I monitor my agentic environment for cost and performance metrics"
    )
    print(result.final_output)

await main()
```
