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:

pytest 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.3.tar.gz (7.1 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.3-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for langchain_goodfire-0.2.3.tar.gz
Algorithm Hash digest
SHA256 6b493bc06d1c13f74522d4a9e763972d7a545f461317f9385409455cdecd9cf2
MD5 92e13be4b682d8ccfec94d16f4da4772
BLAKE2b-256 9dad427e47f8f38f28cce0aca46ed9c306df6568352795a8fe8ed90e6d525aed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_goodfire-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d424b29489df99e5b3c820251b9d50e76945ca80e84c5e7861328d4cbbf98260
MD5 09cec96e66cdfb8a94f02da5883a0245
BLAKE2b-256 cb7393f713ea716ff9b5b720c42fc060ba1800a1627e0ec2033945b8c665b593

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