# Langchain-Cerebras
This package contains the LangChain integration with Cerebras.
At Cerebras, we've developed the world's largest and fastest AI processor, the Wafer-Scale Engine-3 (WSE-3). The Cerebras CS-3 system, powered by the WSE-3, represents a new class of AI supercomputer that sets the standard for generative AI training and inference with unparalleled performance and scalability.
With Cerebras as your inference provider, you can:
- Achieve unprecedented speed for AI inference workloads
- Build commercially with high throughput
- Effortlessly scale your AI workloads with our seamless clustering technology
Our CS-3 systems can be quickly and easily clustered to create the largest AI supercomputers in the world, making it simple to place and run the largest models. Leading corporations, research institutions, and governments are already using Cerebras solutions to develop proprietary models and train popular open-source models.
Want to experience the power of Cerebras? Check out our [website](https://cerebras.ai) for more resources and explore options for accessing our technology through the Cerebras Cloud or on-premise deployments!
For more information about Cerebras Cloud, visit [cloud.cerebras.ai](https://cloud.cerebras.ai/). Our API reference is available at [inference-docs.cerebras.ai](https://inference-docs.cerebras.ai/).
## Installation
```bash
pip install langchain-cerebras
```
## API Key
Get an API Key from [cloud.cerebras.ai](https://cloud.cerebras.ai/) and add it to your environment variables:
```
export CEREBRAS_API_KEY="your-api-key-here"
```
## Chat model
### More examples
See more examples [here](http://python.langchain.com/docs/integrations/chat/cerebras).
### Example
```python
from langchain_core.prompts import ChatPromptTemplate
from langchain_cerebras import ChatCerebras
chat = ChatCerebras(
model="llama-3.3-70b",
)
system = "You are an expert on animals who must answer questions in a manner that a 5 year old can understand."
human = "I want to learn more about this animal: {text}"
prompt = ChatPromptTemplate.from_messages(
[
("system", system),
("human", human)
]
)
chain = prompt | chat
chain.invoke({"text": "Lion"})
```
Result content:
```
OH BOY! Let me tell you all about LIONS!
Lions are the kings of the jungle! They're really big and have beautiful, fluffy manes around their necks. The mane is like a big, golden crown!
Lions live in groups called prides. A pride is like a big family, and the lionesses (that's what we call the female lions) take care of the babies. The lionesses are like the mommies, and they teach the babies how to hunt and play.
Lions are very good at hunting. They work together to catch their food, like zebras and antelopes. They're super fast and can run really, really fast!
But lions are also very sleepy. They like to take long naps in the sun, and they can sleep for up to 20 hours a day! Can you imagine sleeping that much?
Lions are also very loud. They roar really loudly to talk to each other. It's like they're saying, "ROAR! I'm the king of the jungle!"
And guess what? Lions are very social. They like to play and cuddle with each other. They're like big, furry teddy bears!
So, that's lions! Aren't they just the coolest?
```
## Development + Contributing
For more information, visit [LangChain's contribution guide](https://python.langchain.com/v0.1/docs/contributing/code/).
### Install Dependencies
```
poetry install --with test,lint,codespell
```
### Build
```
poetry build
```
### Unit Test
Unit tests are completely offline and do not require an API key.
```
make test
```
### Integration Test
Integration tests require the environment variable `CEREBRAS_API_KEY` to be set to a valid API key along with a connection to the Cerebras Cloud servers.
```
make integration_test
```
### Linting and Formatting
```
make lint spell_check check_imports
```
Raw data
{
"_id": null,
"home_page": "https://github.com/langchain-ai/langchain-cerebras",
"name": "langchain-cerebras",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/42/61/9a4cb075d2c400690fc7738fa936193461f9d0b92dea2d5e27fd44244546/langchain_cerebras-0.5.0.tar.gz",
"platform": null,
"description": "# Langchain-Cerebras\n\nThis package contains the LangChain integration with Cerebras.\n\nAt Cerebras, we've developed the world's largest and fastest AI processor, the Wafer-Scale Engine-3 (WSE-3). The Cerebras CS-3 system, powered by the WSE-3, represents a new class of AI supercomputer that sets the standard for generative AI training and inference with unparalleled performance and scalability.\n\nWith Cerebras as your inference provider, you can:\n- Achieve unprecedented speed for AI inference workloads\n- Build commercially with high throughput\n- Effortlessly scale your AI workloads with our seamless clustering technology\n\nOur CS-3 systems can be quickly and easily clustered to create the largest AI supercomputers in the world, making it simple to place and run the largest models. Leading corporations, research institutions, and governments are already using Cerebras solutions to develop proprietary models and train popular open-source models.\n\nWant to experience the power of Cerebras? Check out our [website](https://cerebras.ai) for more resources and explore options for accessing our technology through the Cerebras Cloud or on-premise deployments!\n\nFor more information about Cerebras Cloud, visit [cloud.cerebras.ai](https://cloud.cerebras.ai/). Our API reference is available at [inference-docs.cerebras.ai](https://inference-docs.cerebras.ai/).\n\n## Installation\n\n```bash\npip install langchain-cerebras\n```\n\n## API Key\nGet an API Key from [cloud.cerebras.ai](https://cloud.cerebras.ai/) and add it to your environment variables:\n```\nexport CEREBRAS_API_KEY=\"your-api-key-here\"\n```\n\n## Chat model\n\n### More examples\nSee more examples [here](http://python.langchain.com/docs/integrations/chat/cerebras).\n\n### Example\n\n```python\nfrom langchain_core.prompts import ChatPromptTemplate\nfrom langchain_cerebras import ChatCerebras\n\nchat = ChatCerebras(\n model=\"llama-3.3-70b\",\n)\n\nsystem = \"You are an expert on animals who must answer questions in a manner that a 5 year old can understand.\"\nhuman = \"I want to learn more about this animal: {text}\"\nprompt = ChatPromptTemplate.from_messages(\n [\n (\"system\", system),\n (\"human\", human)\n ]\n)\n\nchain = prompt | chat\nchain.invoke({\"text\": \"Lion\"})\n```\n\nResult content:\n```\nOH BOY! Let me tell you all about LIONS!\n\nLions are the kings of the jungle! They're really big and have beautiful, fluffy manes around their necks. The mane is like a big, golden crown!\n\nLions live in groups called prides. A pride is like a big family, and the lionesses (that's what we call the female lions) take care of the babies. The lionesses are like the mommies, and they teach the babies how to hunt and play.\n\nLions are very good at hunting. They work together to catch their food, like zebras and antelopes. They're super fast and can run really, really fast!\n\nBut lions are also very sleepy. They like to take long naps in the sun, and they can sleep for up to 20 hours a day! Can you imagine sleeping that much?\n\nLions are also very loud. They roar really loudly to talk to each other. It's like they're saying, \"ROAR! I'm the king of the jungle!\"\n\nAnd guess what? Lions are very social. They like to play and cuddle with each other. They're like big, furry teddy bears!\n\nSo, that's lions! Aren't they just the coolest?\n```\n\n## Development + Contributing\n\nFor more information, visit [LangChain's contribution guide](https://python.langchain.com/v0.1/docs/contributing/code/).\n\n### Install Dependencies\n```\npoetry install --with test,lint,codespell\n```\n\n### Build\n```\npoetry build\n```\n\n### Unit Test\nUnit tests are completely offline and do not require an API key.\n```\nmake test\n```\n\n### Integration Test\nIntegration tests require the environment variable `CEREBRAS_API_KEY` to be set to a valid API key along with a connection to the Cerebras Cloud servers.\n\n```\nmake integration_test\n```\n\n### Linting and Formatting\n```\nmake lint spell_check check_imports\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An integration package connecting Cerebras and LangChain",
"version": "0.5.0",
"project_urls": {
"Homepage": "https://github.com/langchain-ai/langchain-cerebras",
"Release Notes": "https://github.com/langchain-ai/langchain-cerebras/releases",
"Repository": "https://github.com/langchain-ai/langchain-cerebras",
"Source Code": "https://github.com/langchain-ai/langchain-cerebras/tree/master/libs/cerebras"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bf781dacd83bd324c5c64b88367facb86ad9e5e5d89dfd0dceaed3d444c42df6",
"md5": "8fa71833d568b0455c860d6c7cab0335",
"sha256": "f129df699d6eb71d8e2602d7abe9ae75c289168b2e52d33cdefe5d4982e027b9"
},
"downloads": -1,
"filename": "langchain_cerebras-0.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8fa71833d568b0455c860d6c7cab0335",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 7839,
"upload_time": "2025-01-10T17:45:33",
"upload_time_iso_8601": "2025-01-10T17:45:33.945383Z",
"url": "https://files.pythonhosted.org/packages/bf/78/1dacd83bd324c5c64b88367facb86ad9e5e5d89dfd0dceaed3d444c42df6/langchain_cerebras-0.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "42619a4cb075d2c400690fc7738fa936193461f9d0b92dea2d5e27fd44244546",
"md5": "640986a04108e577e01330decd3d4581",
"sha256": "24cfe76358cd8c779f33c77708df08cc5fec81ed13797830396be0f52abdd80a"
},
"downloads": -1,
"filename": "langchain_cerebras-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "640986a04108e577e01330decd3d4581",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 7402,
"upload_time": "2025-01-10T17:45:36",
"upload_time_iso_8601": "2025-01-10T17:45:36.022284Z",
"url": "https://files.pythonhosted.org/packages/42/61/9a4cb075d2c400690fc7738fa936193461f9d0b92dea2d5e27fd44244546/langchain_cerebras-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-10 17:45:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "langchain-ai",
"github_project": "langchain-cerebras",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "langchain-cerebras"
}