-
Notifications
You must be signed in to change notification settings - Fork 678
/
conftest.py
40 lines (30 loc) · 1.06 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import pytest
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from opentelemetry.instrumentation.openai import OpenAIInstrumentor
@pytest.fixture(scope="session")
def exporter():
exporter = InMemorySpanExporter()
processor = SimpleSpanProcessor(exporter)
provider = TracerProvider()
provider.add_span_processor(processor)
trace.set_tracer_provider(provider)
async def upload_base64_image(*args):
return "/some/url"
OpenAIInstrumentor(
enrich_assistant=True,
enrich_token_usage=True,
upload_base64_image=upload_base64_image,
).instrument()
return exporter
@pytest.fixture(autouse=True)
def clear_exporter(exporter):
exporter.clear()
@pytest.fixture(scope="module")
def vcr_config():
return {
"filter_headers": ["authorization", "api-key"],
"ignore_hosts": ["openaipublic.blob.core.windows.net"],
}