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-0.0.1.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-0.0.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: weave_haystack-0.0.1.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-0.0.1.tar.gz
Algorithm Hash digest
SHA256 924ce206850b2ac5f019fd6a827b0a040dfb5168245c3cab7458d50cb1ecdf30
MD5 f2f13baab2caa423cbc610ce4cb4d63f
BLAKE2b-256 329359efdb76942d94da4ac8121724e83b6269b14b24e0e1719d805772b54184

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for weave_haystack-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa79b51e66f878cfe7ff88aae20ac4c66bacdcf912014711786a5c53c880d7ae
MD5 de4c3e04b3ee6e03579603dd2da8b7fb
BLAKE2b-256 7c1d4e2c0f79b904699be240ae00a3abc5147adbed39e3ea95bf05c2229ee9f1

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