-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for observability for OpenAI models
- Loading branch information
1 parent
4e3345f
commit aae011d
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .observe import Observer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|