Skip to main content

An integration of Weights & Biases Weave tracer with Haystack

Project description

weave-haystack

PyPI - Version PyPI - Python Version

Installation

pip install weave-haystack

Weave by Weights & Biases

Example

You need to have a Weave account to use this feature. You can sign up for free at https://wandb.ai/site.

You then need to set the WANDB_API_KEY: environment variable with your Weights & Biases API key. You should find your API key in https://wandb.ai/home when you are logged in.

You should then head to https://wandb.ai/<user_name>/projects and see the complete trace for your pipeline under the pipeline name you specified, when creating the WeaveConnector.

You also need to have the HAYSTACK_CONTENT_TRACING_ENABLED environment variable set to true.

To use this connector simply add it to your pipeline without any connections, and it will automatically start sending traces to Weights & Biases.

import os

from haystack import Pipeline
from haystack.components.builders import ChatPromptBuilder
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage

from haystack_integrations.components.connectors import WeaveConnector

os.environ["HAYSTACK_CONTENT_TRACING_ENABLED"] = "true"

pipe = Pipeline()
pipe.add_component("prompt_builder", ChatPromptBuilder())
pipe.add_component("llm", OpenAIChatGenerator(model="gpt-3.5-turbo"))
pipe.connect("prompt_builder.prompt", "llm.messages")

connector = WeaveConnector(pipeline_name="test_pipeline")
pipe.add_component("weave", connector)

messages = [
    ChatMessage.from_system(
        "Always respond in German even if some input data is in other languages."
    ),
    ChatMessage.from_user("Tell me about {{location}}"),
]

response = pipe.run(
    data={
        "prompt_builder": {
            "template_variables": {"location": "Berlin"},
            "template": messages,
        }
    }
)
print(response["llm"]["replies"][0])

License

weave-haystack is distributed under the terms of the Apache-2.0 license.

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

weave_haystack-1.0.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

weave_haystack-1.0.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file weave_haystack-1.0.0.tar.gz.

File metadata

  • Download URL: weave_haystack-1.0.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for weave_haystack-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e81b3ba3f843ec638ef0744a438150765473a82fe5ce075b856e408b6bfba97b
MD5 5e255944658c856e940aa13989b33542
BLAKE2b-256 464785ba1ecbc79a3946dddb6d2c9a8848c8392d2f8876b43d09806c82512c56

See more details on using hashes here.

File details

Details for the file weave_haystack-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for weave_haystack-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 011a3db1fe6ab2a8564bc1c61f6b230a88db811d3eb74bb91f04203cc3f51a58
MD5 9a246f4e518eaa87ff4341e759f66b83
BLAKE2b-256 bd7525e0a7ef11ad5a7256f64642e32676417f084dda19cc659bec9c85079cef

See more details on using hashes here.

Supported by

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