Skip to main content

Experimental wrappers that also log to LangSmith.

Project description

LangSmith API Wrappers

Some functionality to wrap common apis (e.g., openai) with LangSmith instrumentation.

Example:

from langsmith.wrappers.openai import openai

result = openai.ChatCompletion.create(
    model="gpt-3.5-turbo",
    messages=[
        {
            "role": "user",
            "content": "What's the weather like in san francisco right now?",
        }
    ],
    functions=[
        {
            "name": "get_current_weather",
            "description": "Get the current weather in a given location",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "The city and state, e.g. San Francisco, CA",
                    },
                    "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
                },
                "required": ["location"],
            },
        }
    ],
)
print(result)

You can try wrapping your own library. Function calls will be mapped as "chain" runs.

Example:

from langsmith.wrappers.base import ModuleWrapper
import transformers as transformers_base
transformers = ModuleWrapper(transformers_base)

pipe = transformers.pipeline("text2text-generation", model="google/t5-efficient-tiny")
result = pipe("This is a test")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langsmith_wrappers-0.0.1.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

langsmith_wrappers-0.0.1-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page