Skip to main content

Goodfire integration for LangChain

Project description

LangChain Goodfire Integration

This package contains the LangChain integration for the Goodfire API.

Installation

pip install langchain-goodfire

Usage

from langchain_goodfire import ChatGoodfire
from langchain_core.messages import SystemMessage, HumanMessage
import goodfire

chat = ChatGoodfire(
    model=goodfire.Variant("meta-llama/Llama-3.3-70B-Instruct"),
    goodfire_api_key="your-api-key"
)

messages = [
    SystemMessage(content="You are a helpful assistant."),
    HumanMessage(content="Hello!")
]

response = chat.invoke(messages)
print(response)

Async Environment Usage

When using this package in an environment with an existing event loop (e.g., Jupyter notebook):

  • Use the async versions of methods since an event loop is already running
  • Replace chat.invoke(messages) with await chat.ainvoke(messages)
  • Similarly, use await chat.abatch(...), await chat.astream(...), etc.

Technical Note: Synchronous methods won't work in environments with an existing event loop because the Goodfire client library uses asyncio internally. When an event loop is already running, you must use async methods to properly interface with the Goodfire client library.

Development

To install the package in development mode:

pip install -e .

Testing

Run tests using pytest:

# run unit tests without network access
poetry run pytest --disable-socket --allow-unix-socket --asyncio-mode=auto tests/unit_tests
# run integration tests
poetry run pytest --asyncio-mode=auto tests/integration_tests

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For support, please open an issue on the GitHub repository.

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

langchain_goodfire-0.2.4.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

langchain_goodfire-0.2.4-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file langchain_goodfire-0.2.4.tar.gz.

File metadata

  • Download URL: langchain_goodfire-0.2.4.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for langchain_goodfire-0.2.4.tar.gz
Algorithm Hash digest
SHA256 af8b254f47299c781a501b572b64a184d839b8a45f8aba75e1d5490b36765ab3
MD5 379d042832246b429c6444395282fe4d
BLAKE2b-256 a778359da92f0721dbdf2bcd1c26a325edac28e805a77bd7b829d64071d2403e

See more details on using hashes here.

File details

Details for the file langchain_goodfire-0.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_goodfire-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 69ae3fc4c041214d9d251242e378e5c026a681b75213fde8b63a5d52639e9022
MD5 4dd62929210e2c581aee624479e72294
BLAKE2b-256 a81633ad270b54c22a5d1edd8e47e864ebfbf850c659337a83e45fa63b69e1e2

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