OpenAI Endpoint¶
trulens_eval.feedback.provider.endpoint.openai
¶
Dev Notes¶
This class makes use of langchain's cost tracking for openai models. Changes to the involved classes will need to be adapted here. The important classes are:
langchain.schema.LLMResult
langchain.callbacks.openai_info.OpenAICallbackHandler
Changes for openai 1.0¶
-
Previously we instrumented classes
openai.*
and their methodscreate
andacreate
. Now we instrument classesopenai.resources.*
and theircreate
methods. We also instrumentopenai.resources.chat.*
and theircreate
. To be determined is the instrumentation of the other classes/modules underopenai.resources
. -
openai methods produce structured data instead of dicts now. langchain expects dicts so we convert them to dicts.
Classes¶
OpenAIClient
¶
Bases: SerialModel
A wrapper for openai clients.
This class allows wrapped clients to be serialized into json. Does not
serialize API key though. You can access openai.OpenAI under the client
attribute. Any attributes not defined by this wrapper are looked up from the
wrapped client
so you should be able to use this instance as if it were an
openai.OpenAI
instance.
OpenAIEndpoint
¶
Bases: Endpoint
OpenAI endpoint. Instruments "create" methods in openai client.
PARAMETER | DESCRIPTION |
---|---|
client |
openai client to use. If not provided, a new client will be created using the provided kwargs.
TYPE:
|
**kwargs |
arguments to constructor of a new OpenAI client if
TYPE:
|