Skip to content

langchain: wrap ChatMistralAI #469

@codefromthecrypt

Description

@codefromthecrypt

If I run the following with EDOT python+Langtrace, I get only an HTTP span, but nothing from Langtrace.

Image
from langchain_mistralai.chat_models import ChatMistralAI

# ChatMistralAI is implemented directly in Langchain using httpx, so install
# the Langchain instrumentation.
from langtrace_python_sdk.instrumentation import LangchainInstrumentation

LangchainInstrumentation().instrument()


def main():
    llm = ChatMistralAI(model_name="open-mistral-nemo", 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()

If we had instrumentation here, we would get gen_ai spans for Mistral when used in Langchain.

Notes

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