Git Product home page Git Product logo

openinference's Introduction

OpenInfence

OpenInference is a set of conventions and plugins that is complimentary to OpenTelemetry to enable tracing of AI applications. OpenInference is natively supported by arize-phoenix, but can be used with any OpenTelemetry-compatible backend as well.

Specification

The OpenInference specification is edited in markdown files found in the spec directory. It's designed to provide insight into the invocation of LLMs and the surrounding application context such as retrieval from vector stores and the usage of external tools such as search engines or APIs. The specification is transport and file-format agnostic, and is intended to be used in conjunction with other specifications such as JSON, ProtoBuf, and DataFrames.

Instrumentation

OpenInference provides a set of instrumentations for popular machine learning SDKs and frameworks in a variety of languages.

Python

Libraries

Package Description Version
openinference-semantic-conventions Semantic conventions for tracing of LLM Apps. PyPI Version
openinference-instrumentation-openai OpenInference Instrumentation for OpenAI SDK. PyPI Version
openinference-instrumentation-llama-index OpenInference Instrumentation for LlamaIndex. PyPI Version
openinference-instrumentation-dspy OpenInference Instrumentation for DSPy. PyPI Version
openinference-instrumentation-bedrock OpenInference Instrumentation for AWS Bedrock. PyPI Version
openinference-instrumentation-langchain OpenInference Instrumentation for LangChain. PyPI Version
openinference-instrumentation-mistralai OpenInference Instrumentation for MistralAI. PyPI Version
openinference-instrumentation-guardrails OpenInference Instrumentation for Guardrails. PyPI Version
openinference-instrumentation-vertexai OpenInference Instrumentation for VertexAI. PyPI Version
openinference-instrumentation-crewai OpenInference Instrumentation for CrewAI. PyPI Version
openinference-instrumentation-haystack OpenInference Instrumentation for Haystack. PyPI Version
openinference-instrumentation-litellm OpenInference Instrumentation for liteLLM. PyPI Version
openinference-instrumentation-groq OpenInference Instrumentation for Groq. PyPI Version
openinference-instrumentation-instructor OpenInference Instrumentation for Instructor. PyPI Version

Examples

Name Description Complexity Level
OpenAI SDK OpenAI Python SDK, including chat completions and embeddings Beginner
MistralAI SDK MistraAI Python SDK Beginner
VertexAI SDK VertexAI Python SDK Beginner
LlamaIndex LlamaIndex query engines Beginner
DSPy DSPy primitives and custom RAG modules Beginner
Boto3 Bedrock Client Boto3 Bedrock client Beginner
LangChain LangChain primitives and simple chains Beginner
LiteLLM A lightweight LiteLLM framework Beginner
Groq Groq and AsyncGroq chat completions Beginner
LlamaIndex + Next.js Chatbot A fully functional chatbot using Next.js and a LlamaIndex FastAPI backend Intermediate
LangServe A LangChain application deployed with LangServe using custom metadata on a per-request basis Intermediate
DSPy A DSPy RAG application using FastAPI, Weaviate, and Cohere Intermediate
Haystack A Haystack QA RAG application Intermediate

JavaScript

Libraries

Package Description Version
@arizeai/openinference-semantic-conventions Semantic conventions for tracing of LLM Apps. NPM Version
@arizeai/openinference-instrumentation-openai OpenInference Instrumentation for OpenAI SDK. NPM Version
@arizeai/openinference-instrumentation/langchain OpenInference Instrumentation for LangChain.js. NPM Version

Examples

Name Description Complexity Level
OpenAI SDK OpenAI Node.js client Beginner
LlamaIndex Express App A fully functional LlamaIndex chatbot with a Next.js frontend and a LlamaIndex Express backend, instrumented using openinference-instrumentation-openai Intermediate
LangChain OpenAI A simple script to call OpenAI via LangChain, instrumented using openinference-instrumentation-langchain Beginner
LangChain RAG Express App A fully functional LangChain chatbot that uses RAG to answer user questions. It has a Next.js frontend and a LangChain Express backend, instrumented using openinference-instrumentation-langchain Intermediate
Next.js + OpenAI A Next.js 13 project bootstrapped with create-next-app that uses OpenAI to generate text Beginner

Supported Destinations

OpenInference supports the following destinations as span collectors.

Community

Join our community to connect with thousands of machine learning practitioners and LLM observability enthusiasts!

  • 🌍 Join our Slack community.
  • 💡 Ask questions and provide feedback in the #phoenix-support channel.
  • 🌟 Leave a star on our GitHub.
  • 🐞 Report bugs with GitHub Issues.
  • 𝕏 Follow us on X.
  • 🗺️ Check out our roadmap to see where we're heading next.

openinference's People

Contributors

21shisodeparth avatar anticorrelator avatar axiomofjoy avatar cjunkin avatar fjcasti1 avatar github-actions[bot] avatar harrisonchu avatar krzysztofspalinski avatar mikeldking avatar nate-mar avatar parker-stafford avatar pbadhe avatar rogerhyang avatar shreyabsridhar avatar shreyar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

openinference's Issues

[bug] Python CI failing on openAI integration

=================================== FAILURES ===================================
__________________ test_chat_completions[200-True-True-False] __________________

is_async = False, is_raw = True, is_stream = True, status_code = 200
respx_mock = <respx.router.MockRouter object at 0x7fc85cad3eb0>
in_memory_span_exporter = <opentelemetry.sdk.trace.export.in_memory_span_exporter.InMemorySpanExporter object at 0x7fc85054dd00>
completion_usage = {'completion_tokens': 588, 'prompt_tokens': 813, 'total_tokens': 1401}
model_name = '0.8219540423197268'
chat_completion_mock_stream = ([b'data: {"choices": [{"delta": {"role": "assistant"}, "index": 0}]}\n\n', b'data: {"choices": [{"delta": {"tool_call...', 'type': 'function'}]}, {'content': '{"location": "San Francisco, CA", "unit": "fahrenheit"}', 'role': 'assistant'}])

    @pytest.mark.parametrize("is_async", [False, True])
    @pytest.mark.parametrize("is_raw", [False, True])
    @pytest.mark.parametrize("is_stream", [False, True])
    @pytest.mark.parametrize("status_code", [200, 400])
    def test_chat_completions(
        is_async: bool,
        is_raw: bool,
        is_stream: bool,
        status_code: int,
        respx_mock: MockRouter,
        in_memory_span_exporter: InMemorySpanExporter,
        completion_usage: Dict[str, Any],
        model_name: str,
        chat_completion_mock_stream: Tuple[List[bytes], List[Dict[str, Any]]],
    ) -> None:
        input_messages: List[Dict[str, Any]] = get_messages()
        output_messages: List[Dict[str, Any]] = (
            chat_completion_mock_stream[1] if is_stream else get_messages()
        )
        invocation_parameters = {
            "stream": is_stream,
            "model": randstr(),
            "temperature": random.random(),
            "n": len(output_messages),
        }
        url = "https://api.openai.com/v1/chat/completions"
        respx_kwargs: Dict[str, Any] = {
            **(
                {"stream": MockAsyncByteStream(chat_completion_mock_stream[0])}
                if is_stream
                else {
                    "json": {
                        "choices": [
                            {"index": i, "message": message, "finish_reason": "stop"}
                            for i, message in enumerate(output_messages)
                        ],
                        "model": model_name,
                        "usage": completion_usage,
                    }
                }
            ),
        }
        respx_mock.post(url).mock(return_value=Response(status_code=status_code, **respx_kwargs))
        create_kwargs = {"messages": input_messages, **invocation_parameters}
        openai = import_module("openai")
        completions = (
            openai.AsyncOpenAI(api_key="sk-").chat.completions
            if is_async
            else openai.OpenAI(api_key="sk-").chat.completions
        )
        create = completions.with_raw_response.create if is_raw else completions.create
        with suppress(openai.BadRequestError):
            if is_async:
    
                async def task() -> None:
                    response = await create(**create_kwargs)
                    response = response.parse() if is_raw else response
                    if is_stream:
                        async for _ in response:
                            pass
    
                asyncio.run(task())
            else:
                response = create(**create_kwargs)
                response = response.parse() if is_raw else response
                if is_stream:
                    for _ in response:
                        pass
        spans = in_memory_span_exporter.get_finished_spans()
        assert len(spans) == 2  # first span should be from the httpx instrumentor
        span: ReadableSpan = spans[1]
        if status_code == 200:
            assert span.status.is_ok
        elif status_code == 400:
            assert not span.status.is_ok and not span.status.is_unset
            assert len(span.events) == 1
            event = span.events[0]
            assert event.name == "exception"
        attributes = dict(cast(Mapping[str, AttributeValue], span.attributes))
        assert attributes.pop(OPENINFERENCE_SPAN_KIND, None) == OpenInferenceSpanKindValues.LLM.value
        assert isinstance(attributes.pop(INPUT_VALUE, None), str)
        assert (
            OpenInferenceMimeTypeValues(attributes.pop(INPUT_MIME_TYPE, None))
            == OpenInferenceMimeTypeValues.JSON
        )
        assert (
            json.loads(cast(str, attributes.pop(LLM_INVOCATION_PARAMETERS, None)))
            == invocation_parameters
        )
        for prefix, messages in (
            (LLM_INPUT_MESSAGES, input_messages),
            *(((LLM_OUTPUT_MESSAGES, output_messages),) if status_code == 200 else ()),
        ):
            for i, message in enumerate(messages):
>               assert attributes.pop(message_role(prefix, i), None) == message.get("role")
E               assert None == 'assistant'
E                +  where None = <built-in method pop of dict object at 0x7fc8597fcb80>('llm.output_messages.0.message.role', None)
E                +    where <built-in method pop of dict object at 0x7fc8597fcb80> = {'output.value': '<openai.Stream object at 0x7fc8597b1580>'}.pop
E                +    and   'llm.output_messages.0.message.role' = message_role('llm.output_messages', 0)
E                +  and   'assistant' = <built-in method get of dict object at 0x7fc859791700>('role')
E                +    where <built-in method get of dict object at 0x7fc859791700> = {'content': '{"location": "Boston, MA", "unit": "fahrenheit"}', 'role': 'assistant', 'tool_calls': [{'function': {'arg...", "unit": "fahrenheit"}', 'name': 'get_current_weather'}, 'id': 'call_6QTP4mLSYYzZwt3ZWj77vfZf', 'type': 'function'}]}.get

tests/openinference/instrumentation/openai/test_instrumentor.py:146: AssertionError
__________________ test_chat_completions[200-True-True-True] ___________________

is_async = True, is_raw = True, is_stream = True, status_code = 200
respx_mock = <respx.router.MockRouter object at 0x7fc85cad3eb0>
in_memory_span_exporter = <opentelemetry.sdk.trace.export.in_memory_span_exporter.InMemorySpanExporter object at 0x7fc85054dd00>
completion_usage = {'completion_tokens': 971, 'prompt_tokens': 332, 'total_tokens': 1303}
model_name = '0.[150](https://github.com/Arize-ai/openinference/actions/runs/7789499135/job/21241260367#step:5:151)84917392450192'
chat_completion_mock_stream = ([b'data: {"choices": [{"delta": {"role": "assistant"}, "index": 0}]}\n\n', b'data: {"choices": [{"delta": {"tool_call...', 'type': 'function'}]}, {'content': '{"location": "San Francisco, CA", "unit": "fahrenheit"}', 'role': 'assistant'}])

    @pytest.mark.parametrize("is_async", [False, True])
    @pytest.mark.parametrize("is_raw", [False, True])
    @pytest.mark.parametrize("is_stream", [False, True])
    @pytest.mark.parametrize("status_code", [200, 400])
    def test_chat_completions(
        is_async: bool,
        is_raw: bool,
        is_stream: bool,
        status_code: int,
        respx_mock: MockRouter,
        in_memory_span_exporter: InMemorySpanExporter,
        completion_usage: Dict[str, Any],
        model_name: str,
        chat_completion_mock_stream: Tuple[List[bytes], List[Dict[str, Any]]],
    ) -> None:
        input_messages: List[Dict[str, Any]] = get_messages()
        output_messages: List[Dict[str, Any]] = (
            chat_completion_mock_stream[1] if is_stream else get_messages()
        )
        invocation_parameters = {
            "stream": is_stream,
            "model": randstr(),
            "temperature": random.random(),
            "n": len(output_messages),
        }
        url = "https://api.openai.com/v1/chat/completions"
        respx_kwargs: Dict[str, Any] = {
            **(
                {"stream": MockAsyncByteStream(chat_completion_mock_stream[0])}
                if is_stream
                else {
                    "json": {
                        "choices": [
                            {"index": i, "message": message, "finish_reason": "stop"}
                            for i, message in enumerate(output_messages)
                        ],
                        "model": model_name,
                        "usage": completion_usage,
                    }
                }
            ),
        }
        respx_mock.post(url).mock(return_value=Response(status_code=status_code, **respx_kwargs))
        create_kwargs = {"messages": input_messages, **invocation_parameters}
        openai = import_module("openai")
        completions = (
            openai.AsyncOpenAI(api_key="sk-").chat.completions
            if is_async
            else openai.OpenAI(api_key="sk-").chat.completions
        )
        create = completions.with_raw_response.create if is_raw else completions.create
        with suppress(openai.BadRequestError):
            if is_async:
    
                async def task() -> None:
                    response = await create(**create_kwargs)
                    response = response.parse() if is_raw else response
                    if is_stream:
                        async for _ in response:
                            pass
    
                asyncio.run(task())
            else:
                response = create(**create_kwargs)
                response = response.parse() if is_raw else response
                if is_stream:
                    for _ in response:
                        pass
        spans = in_memory_span_exporter.get_finished_spans()
        assert len(spans) == 2  # first span should be from the httpx instrumentor
        span: ReadableSpan = spans[1]
        if status_code == [200](https://github.com/Arize-ai/openinference/actions/runs/7789499135/job/21241260367#step:5:201):
            assert span.status.is_ok
        elif status_code == 400:
            assert not span.status.is_ok and not span.status.is_unset
            assert len(span.events) == 1
            event = span.events[0]
            assert event.name == "exception"
        attributes = dict(cast(Mapping[str, AttributeValue], span.attributes))
        assert attributes.pop(OPENINFERENCE_SPAN_KIND, None) == OpenInferenceSpanKindValues.LLM.value
        assert isinstance(attributes.pop(INPUT_VALUE, None), str)
        assert (
            OpenInferenceMimeTypeValues(attributes.pop(INPUT_MIME_TYPE, None))
            == OpenInferenceMimeTypeValues.JSON
        )
        assert (
            json.loads(cast(str, attributes.pop(LLM_INVOCATION_PARAMETERS, None)))
            == invocation_parameters
        )
        for prefix, messages in (
            (LLM_INPUT_MESSAGES, input_messages),
            *(((LLM_OUTPUT_MESSAGES, output_messages),) if status_code == 200 else ()),
        ):
            for i, message in enumerate(messages):
>               assert attributes.pop(message_role(prefix, i), None) == message.get("role")
E               assert None == 'assistant'
E                +  where None = <built-in method pop of dict object at 0x7fc85979[238](https://github.com/Arize-ai/openinference/actions/runs/7789499135/job/21241260367#step:5:239)0>('llm.output_messages.0.message.role', None)
E                +    where <built-in method pop of dict object at 0x7fc859792380> = {'output.value': '<openai.AsyncStream object at 0x7fc8597d59a0>'}.pop
E                +    and   'llm.output_messages.0.message.role' = message_role('llm.output_messages', 0)
E                +  and   'assistant' = <built-in method get of dict object at 0x7fc8596b4580>('role')
E                +    where <built-in method get of dict object at 0x7fc8596b4580> = {'content': '{"location": "Boston, MA", "unit": "fahrenheit"}', 'role': 'assistant', 'tool_calls': [{'function': {'arg...", "unit": "fahrenheit"}', 'name': 'get_current_weather'}, 'id': 'call_6QTP4mLSYYzZwt3ZWj77vfZf', 'type': 'function'}]}.get

tests/openinference/instrumentation/openai/test_instrumentor.py:146: AssertionError

[bug] python CI failing on async langchain-latest

failing on stuff document chain parent id

assert (sd_span := spans_by_name.pop("StuffDocumentsChain")) is not None
        assert sd_span.parent is not None
>       assert sd_span.parent.span_id == rqa_span.context.span_id
E       assert 1585446675937841368 == 3960482443532127989

☔ [Python] AWS bedrock Instrumentation

  • [Python] Initial OpenInference Boto Instrumentation for bedrock
  • #93
  • #139
  • #140
  • #141

Add a complimentary library to AWS boto instrumentation that adds LLM spans for bedrock calls:

AWS boto open telemetry: https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/boto/boto.html
TraceLoop Example: https://github.com/traceloop/openllmetry/blob/4f5ce8f73341954eb14ef71d17818d72d94f095d/packages/opentelemetry-instrumentation-bedrock/opentelemetry/instrumentation/bedrock/__init__.py#L169

[bug] docker-compose of llama-index requires you to pre-build index. The image should build the index in the image

llama-index-backend-1   | INFO:     192.168.65.1:37060 - "POST /api/chat HTTP/1.1" 500 Internal Server Error
llama-index-backend-1   | ERROR:    Exception in ASGI application
llama-index-backend-1   | Traceback (most recent call last):
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
llama-index-backend-1   |     result = await app(  # type: ignore[func-returns-value]
llama-index-backend-1   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
llama-index-backend-1   |     return await self.app(scope, receive, send)
llama-index-backend-1   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/fastapi/applications.py", line 1106, in __call__
llama-index-backend-1   |     await super().__call__(scope, receive, send)
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/starlette/applications.py", line 122, in __call__
llama-index-backend-1   |     await self.middleware_stack(scope, receive, send)
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
llama-index-backend-1   |     raise exc
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
llama-index-backend-1   |     await self.app(scope, receive, _send)
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 91, in __call__
llama-index-backend-1   |     await self.simple_response(scope, receive, send, request_headers=headers)
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 146, in simple_response
llama-index-backend-1   |     await self.app(scope, receive, send)
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
llama-index-backend-1   |     raise exc
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
llama-index-backend-1   |     await self.app(scope, receive, sender)
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
llama-index-backend-1   |     raise e
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
llama-index-backend-1   |     await self.app(scope, receive, send)
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
llama-index-backend-1   |     await route.handle(scope, receive, send)
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
llama-index-backend-1   |     await self.app(scope, receive, send)
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
llama-index-backend-1   |     response = await func(request)
llama-index-backend-1   |                ^^^^^^^^^^^^^^^^^^^
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 264, in app
llama-index-backend-1   |     solved_result = await solve_dependencies(
llama-index-backend-1   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/fastapi/dependencies/utils.py", line 594, in solve_dependencies
llama-index-backend-1   |     solved = await run_in_threadpool(call, **sub_values)
llama-index-backend-1   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
llama-index-backend-1   |     return await anyio.to_thread.run_sync(func, *args)
llama-index-backend-1   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/anyio/to_thread.py", line 33, in run_sync
llama-index-backend-1   |     return await get_asynclib().run_sync_in_worker_thread(
llama-index-backend-1   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
llama-index-backend-1   |     return await future
llama-index-backend-1   |            ^^^^^^^^^^^^
llama-index-backend-1   |   File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 807, in run
llama-index-backend-1   |     result = context.run(func, *args)
llama-index-backend-1   |              ^^^^^^^^^^^^^^^^^^^^^^^^
llama-index-backend-1   |   File "/app/app/engine/index.py", line 17, in get_chat_engine
llama-index-backend-1   |     raise Exception(
llama-index-backend-1   | Exception: StorageContext is empty - call 'python app/engine/generate.py' to generate the storage first

the docker file should build the index in it so nothing has to be performed.

☔ [JS] LlamaIndex.TS instrumentation

Add LlamaIndex.TS instrumentation

Spike

  • [JS][LlamaIndex][spike] use callbacks to create spans and see if they stack with OpenAI spans
  • [JS][LlamaIndex][spike] investigate LlamaIndex stream primitives and see if they have controllers and tries
  • [JS][LlamaIndex] Spans for top level span types
    • #615
    • #616
    • #617
    • [JS][LlamaIndex] support reranker span kind
    • [JS][LlamaIndex] support agent span kind
    • #618
  • [JS][LlamaIndex] support streaming responses
  • #613
  • #614
  • [JS][LlamaIndex] bump to the latest version of llamaindex and pin in instrumentation
  • [JS][LlamaIndex] add more unit tests

Setup

Open Questions

  • Should we use the callback system? Does it provide enough visibility to map to OpenInference
  • How do we handle async generators?

[feature request] add support for message names

As noted in the OpenAI documentation, name can be provided to disambiguate participants in mesages.

An optional name for the participant. Provides the model information to

  • differentiate between participants of the same role.

[bug] cannot instrument openai in colab unless colab session is restarted after pip install

openai instrumentation fails in a fresh session of colab.

It only works after the session is restarted after pip install.

Workaround

Use skip_dep_check=True

OpenAIInstrumentor().instrument(skip_dep_check=True)

Screenshot

Screenshot 2024-01-11 at 12 27 41 PM

Code

%pip install -qqq openinference-instrumentation-openai opentelemetry-instrumentation-httpx opentelemetry-sdk opentelemetry-exporter-otlp arize-phoenix openai
from openinference.instrumentation.openai import OpenAIInstrumentor
from opentelemetry import trace as trace_api
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
from opentelemetry.sdk import trace as trace_sdk
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace.export import SimpleSpanProcessor

resource = Resource(attributes={})
tracer_provider = trace_sdk.TracerProvider(resource=resource)
span_exporter = OTLPSpanExporter(endpoint="http://127.0.0.1:6006/v1/traces")
span_processor = SimpleSpanProcessor(span_exporter=span_exporter)
tracer_provider.add_span_processor(span_processor=span_processor)
trace_api.set_tracer_provider(tracer_provider=tracer_provider)

HTTPXClientInstrumentor().instrument()
OpenAIInstrumentor().instrument()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.