Skip to content

Commit

Permalink
Adding support for observability for OpenAI models
Browse files Browse the repository at this point in the history
  • Loading branch information
taha-aiplanet authored and tarun-aiplanet committed May 23, 2024
1 parent 4e3345f commit aae011d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/beyondllm/observe/__intit__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .observe import Observer
26 changes: 26 additions & 0 deletions src/beyondllm/observe/observe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from dataclasses import dataclass
try:
import phoenix as px
from phoenix.trace.openai import OpenAIInstrumentor
except ImportError:
user_agree = input("The feature you're trying to use requires additional packages. Would you like to install them now? [y/N]: ")
if user_agree.lower() == 'y':
import subprocess
import sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "arize-phoenix[evals]"])

import phoenix as px
from phoenix.trace.openai import OpenAIInstrumentor
else:
raise ImportError("The required Phoenix packages are not installed.")



@dataclass
class Observer:
instrumentor: OpenAIInstrumentor = OpenAIInstrumentor()

def run(self):
self.instrumentor.instrument()
self.session = px.launch_app()

0 comments on commit aae011d

Please sign in to comment.