Metadata-Version: 2.4
Name: traceAI-portkey
Version: 0.1.3
Summary: OpenTelemetry instrumentation for Portkey AI
License: Apache-2.0
Keywords: traceai,futureagi,opentelemetry,tracing,observability,llm,portkey
Author: Future AGI
Author-email: no-reply@futureagi.com
Requires-Python: >3.9,<3.13
Classifier: Framework :: OpenTelemetry
Classifier: Framework :: OpenTelemetry :: Instrumentations
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Monitoring
Requires-Dist: fi-instrumentation-otel (>=0.1.11)
Requires-Dist: portkey-ai (>0.1.0)
Project-URL: Changelog, https://github.com/future-agi/traceAI/blob/dev/python/frameworks/portkey/CHANGELOG.md
Project-URL: Documentation, https://docs.futureagi.com/docs/integrations/traceai/portkey
Project-URL: Homepage, https://futureagi.com
Project-URL: Issues, https://github.com/future-agi/traceAI/issues
Project-URL: Repository, https://github.com/future-agi/traceAI/tree/dev/python/frameworks/portkey
Description-Content-Type: text/markdown

## TraceAI Portkey Instrumentation 

This is a simple example of how to use TraceAI's Portkey Instrumentation.

### Requirements

- `portkey_ai`
- `traceai_portkey`

```python
pip install portkey_ai traceai_portkey 
```

Register a new project with the auto instrumentor with the Portkey client.

```python
from dotenv import load_dotenv
from portkey_ai import Portkey
from traceai_portkey import PortkeyInstrumentor
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType, EvalTag, EvalTagType, EvalSpanKind, EvalName, ModelChoices

# Load API keys from .env file
load_dotenv()

# --- Configure Future AGI Tracing Once ---
tracer_provider = register(
    project_name="My-AI-App",
    eval_tags=[
        EvalTag(
            type=EvalTagType.OBSERVATION_SPAN,
            value=EvalSpanKind.LLM,
            eval_name=EvalName.CONTEXT_ADHERENCE,
            custom_eval_name="Response_Quality"
        )
    ]
)

# Instrument the Portkey client
PortkeyInstrumentor().instrument(tracer_provider=tracer_provider)


# --- Your application logic remains the same! ---
client = Portkey(virtual_key="your-portkey-virtual-key")

completion = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Write a 6-word story about a robot who discovers music."}]
)

print(completion.choices[0].message.content)
```
