mlflow-openai - v0.1.1
    正在准备搜索索引...

    mlflow-openai - v0.1.1

    MLflow Typescript SDK - OpenAI

    无缝集成 MLflow Tracing 和 OpenAI,以自动追踪您的 OpenAI API 调用。

    软件包 NPM 描述
    mlflow-openai npm package OpenAI 的自动检测集成。
    npm install mlflow-openai
    

    该包包含 mlflow-tracing 包和 openai 包作为对等依赖项。根据您的包管理器,您可能需要单独安装这两个包。

    启动 MLflow Tracking Server。如果您有本地 Python 环境,可以运行以下命令

    pip install mlflow
    mlflow server --backend-store-uri sqlite:///mlruns.db --port 5000

    如果您本地没有 Python 环境,MLflow 也支持 Docker 部署或托管服务。请参阅 自托管指南 以开始。

    在您的应用程序中实例化 MLflow SDK

    import * as mlflow from 'mlflow-tracing';

    mlflow.init({
    trackingUri: 'https://:5000',
    experimentId: '<experiment-id>'
    });

    创建追踪

    import { OpenAI } from 'openai';
    import { tracedOpenAI } from 'mlflow-openai';

    // Wrap the OpenAI client with the tracedOpenAI function
    const client = tracedOpenAI(new OpenAI());

    // Invoke the client as usual
    const response = await client.chat.completions.create({
    model: 'o4-mini',
    messages: [
    { role: 'system', content: 'You are a helpful weather assistant.' },
    { role: 'user', content: "What's the weather like in Seattle?" }
    ]
    });

    在 MLflow UI 中查看追踪

    MLflow Tracing UI

    MLflow Typescript SDK 的官方文档可以在 此处找到。

    本项目根据 Apache License 2.0 获得许可。