Skip to content

vertexai: wrap PredictionServiceClient.stream_generate_content #468

@codefromthecrypt

Description

@codefromthecrypt

If I run the following with EDOT python+Langtrace, I get several spans, but nothing from Langtrace

Image
from langchain_google_vertexai import ChatVertexAI

from langtrace_python_sdk.instrumentation import VertexAIInstrumentation

VertexAIInstrumentation().instrument()


def main():
    llm = ChatVertexAI(model_name="gemini-1.5-flash-002", streaming=True)

    response_stream = llm.stream("Write a short poem on OpenTelemetry.")
    for chunk in response_stream:
        print(chunk.content, end="")


if __name__ == "__main__":
    main()

I suspect it is due to PredictionServiceClient.stream_generate_content not yet being in the wrapped functions here: https://github.com/Scale3-Labs/langtrace-python-sdk/blob/main/src/langtrace_python_sdk/constants/instrumentation/vertexai.py

Once this is complete, likely this PR can be used to verify it elastic/elasticsearch-labs#386

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions