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.2.tar.gz (6.9 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.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_goodfire-0.2.2.tar.gz
  • Upload date:
  • Size: 6.9 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.2.tar.gz
Algorithm Hash digest
SHA256 15dd7da30e630136c78df8744681d4e8baf2a83294d5add6dbfd9880b11494e2
MD5 eb1c19597286933b045c1bd515b9a60e
BLAKE2b-256 11cbb31f783c65c53cdb218a04e24258be075128fd36415e149a22cf89782d7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_goodfire-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a92aea9c268be1378c145417fcf70a2ff78d4da143e522ee819deffc1f897de5
MD5 837d81536eae92f3d980dc442e8e4a30
BLAKE2b-256 20082f7700ada680fdb15096130c5717d1b822f2dbabcd14613e815e42fb0817

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