packages, docs: Pipeshift - Langchain integration of pipeshift (#29114)

Description: Added pipeshift integration. This integrates pipeshift LLM
and ChatModels APIs with langchain
Dependencies: none

Unit Tests & Integration tests are added

Documentation is added as well

This PR is w.r.t
[#27390](https://github.com/langchain-ai/langchain/pull/27390) and as
per request, a freshly minted `langchain-pipeshift` package is uploaded
to PYPI. Only changes to the docs & packages.yml are made in langchain
master branch

---------

Co-authored-by: Chester Curme <chester.curme@gmail.com>
Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
Sohan 2025-01-22 08:33:06 +05:30 committed by GitHub
parent e723882a49
commit de1fc4811d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 534 additions and 0 deletions

View File

@ -0,0 +1,278 @@
{
"cells": [
{
"cell_type": "raw",
"id": "afaf8039",
"metadata": {},
"source": [
"---\n",
"sidebar_label: Pipeshift\n",
"---"
]
},
{
"cell_type": "markdown",
"id": "e49f1e0d",
"metadata": {},
"source": [
"# ChatPipeshift\n",
"\n",
"This will help you getting started with Pipeshift [chat models](/docs/concepts/chat_models/). For detailed documentation of all ChatPipeshift features and configurations head to the [API reference](https://dashboard.pipeshift.com/docs).\n",
"\n",
"## Overview\n",
"### Integration details\n",
"\n",
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
"| :--- | :--- | :---: | :---: | :---: | :---: | :---: |\n",
"| [ChatPipeshift](https://dashboard.pipeshift.com/docs) | [langchain-pipeshift](https://pypi.org/project/langchain-pipeshift/) | ❌ | -| ❌ | ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain-pipeshift?style=flat-square&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain-pipeshift?style=flat-square&label=%20) |\n",
"\n",
"### Model features\n",
"| [Tool calling](/docs/how_to/tool_calling) | [Structured output](/docs/how_to/structured_output/) | JSON mode | [Image input](/docs/how_to/multimodal_inputs/) | Audio input | Video input | [Token-level streaming](/docs/how_to/chat_streaming/) | Native async | [Token usage](/docs/how_to/chat_token_usage_tracking/) | [Logprobs](/docs/how_to/logprobs/) |\n",
"| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |\n",
"| ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | - | \n",
"\n",
"## Setup\n",
"\n",
"To access Pipeshift models you'll need to create an account on Pipeshift, get an API key, and install the `langchain-pipeshift` integration package.\n",
"\n",
"### Credentials\n",
"\n",
"Head to [Pipeshift](https://dashboard.pipeshift.com) to sign up to Pipeshift and generate an API key. Once you've done this set the PIPESHIFT_API_KEY environment variable:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "433e8d2b-9519-4b49-b2c4-7ab65b046c94",
"metadata": {},
"outputs": [],
"source": [
"import getpass\n",
"import os\n",
"\n",
"if not os.getenv(\"PIPESHIFT_API_KEY\"):\n",
" os.environ[\"PIPESHIFT_API_KEY\"] = getpass.getpass(\"Enter your Pipeshift API key: \")"
]
},
{
"cell_type": "markdown",
"id": "72ee0c4b-9764-423a-9dbf-95129e185210",
"metadata": {},
"source": [
"If you want to get automated tracing of your model calls you can also set your [LangSmith](https://docs.smith.langchain.com/) API key by uncommenting below:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "a15d341e-3e26-4ca3-830b-5aab30ed66de",
"metadata": {},
"outputs": [],
"source": [
"# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
"# os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")"
]
},
{
"cell_type": "markdown",
"id": "0730d6a1-c893-4840-9817-5e5251676d5d",
"metadata": {},
"source": [
"### Installation\n",
"\n",
"The LangChain Pipeshift integration lives in the `langchain-pipeshift` package:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "652d6238-1f87-422a-b135-f5abbb8652fc",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"%pip install -qU langchain-pipeshift"
]
},
{
"cell_type": "markdown",
"id": "a38cde65-254d-4219-a441-068766c0d4b5",
"metadata": {},
"source": [
"## Instantiation\n",
"\n",
"Now we can instantiate our model object and generate chat completions:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "cb09c344-1836-4e0c-acf8-11d13ac1dbae",
"metadata": {},
"outputs": [],
"source": [
"from langchain_pipeshift import ChatPipeshift\n",
"\n",
"llm = ChatPipeshift(\n",
" model=\"meta-llama/Meta-Llama-3.1-8B-Instruct\",\n",
" temperature=0,\n",
" max_tokens=512,\n",
" # other params...\n",
")"
]
},
{
"cell_type": "markdown",
"id": "2b4f3e15",
"metadata": {},
"source": [
"## Invocation"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "62e0dbc3",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"AIMessage(content='Here is the translation:\\n\\nJe suis amoureux du programme. \\n\\nHowever, a more common translation would be:\\n\\nJ\\'aime programmer.\\n\\nNote that \"Je suis amoureux\" typically implies romantic love, whereas \"J\\'aime\" is a more casual way to express affection or enjoyment for an activity, in this case, programming.', additional_kwargs={}, response_metadata={}, id='run-5cad8e5c-d089-44a8-8dcd-22736cde7d7b-0')"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"messages = [\n",
" (\n",
" \"system\",\n",
" \"You are a helpful assistant that translates English to French. Translate the user sentence.\",\n",
" ),\n",
" (\"human\", \"I love programming.\"),\n",
"]\n",
"ai_msg = llm.invoke(messages)\n",
"ai_msg"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "d86145b3-bfef-46e8-b227-4dda5c9c2705",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Here is the translation:\n",
"\n",
"Je suis amoureux du programme. \n",
"\n",
"However, a more common translation would be:\n",
"\n",
"J'aime programmer.\n",
"\n",
"Note that \"Je suis amoureux\" typically implies romantic love, whereas \"J'aime\" is a more casual way to express affection or enjoyment for an activity, in this case, programming.\n"
]
}
],
"source": [
"print(ai_msg.content)"
]
},
{
"cell_type": "markdown",
"id": "18e2bfc0-7e78-4528-a73f-499ac150dca8",
"metadata": {},
"source": [
"## Chaining\n",
"\n",
"We can [chain](/docs/how_to/sequence/) our model with a prompt template like so:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "e197d1d7-a070-4c96-9f8a-a0e86d046e0b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"AIMessage(content=\"Das ist schön! Du liebst Programmieren! (That's great! You love programming!)\\n\\nWould you like to know the German translation of a specific programming-related term or phrase, or would you like me to help you with something else?\", additional_kwargs={}, response_metadata={}, id='run-8a4b7d56-23d9-43a7-8fb2-e05f556d94bd-0')"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from langchain_core.prompts import ChatPromptTemplate\n",
"\n",
"prompt = ChatPromptTemplate(\n",
" [\n",
" (\n",
" \"system\",\n",
" \"You are a helpful assistant that translates {input_language} to {output_language}.\",\n",
" ),\n",
" (\"human\", \"{input}\"),\n",
" ]\n",
")\n",
"\n",
"chain = prompt | llm\n",
"chain.invoke(\n",
" {\n",
" \"input_language\": \"English\",\n",
" \"output_language\": \"German\",\n",
" \"input\": \"I love programming.\",\n",
" }\n",
")"
]
},
{
"cell_type": "markdown",
"id": "3a5bb5ca-c3ae-4a58-be67-2cd18574b9a3",
"metadata": {},
"source": [
"## API reference\n",
"\n",
"For detailed documentation of all ChatPipeshift features and configurations head to the API reference: https://dashboard.pipeshift.com/docs"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -0,0 +1,201 @@
{
"cells": [
{
"cell_type": "raw",
"id": "67db2992",
"metadata": {},
"source": [
"---\n",
"sidebar_label: Pipeshift\n",
"---"
]
},
{
"cell_type": "markdown",
"id": "9597802c",
"metadata": {},
"source": [
"# Pipeshift\n",
"\n",
"This will help you get started with Pipeshift completion models (LLMs) using LangChain. For detailed documentation on `Pipeshift` features and configuration options, please refer to the [API reference](https://dashboard.pipeshift.com/docs).\n",
"\n",
"## Overview\n",
"### Integration details\n",
"\n",
"| Class | Package | Local | Serializable | [JS support](https://js.langchain.com/docs/integrations/llms/pipeshift) | Package downloads | Package latest |\n",
"| :--- | :--- | :---: | :---: | :---: | :---: | :---: |\n",
"| [Pipeshift](https://dashboard.pipeshift.com/docs) | [langchain-pipeshift](https://pypi.org/project/langchain-pipeshift/) | ❌ | - | ❌ | ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain-pipeshift?style=flat-square&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain-pipeshift?style=flat-square&label=%20) |\n",
"\n",
"## Setup\n",
"\n",
"To access Pipeshift models you'll need to create a Pipeshift account, get an API key, and install the `langchain-pipeshift` integration package.\n",
"\n",
"### Credentials\n",
"\n",
"Head to [Pipeshift](https://dashboard.pipeshift.com) to sign up to Pipeshift and generate an API key. Once you've done this set the PIPESHIFT_API_KEY environment variable:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "bc51e756",
"metadata": {},
"outputs": [],
"source": [
"import getpass\n",
"import os\n",
"\n",
"if not os.getenv(\"PIPESHIFT_API_KEY\"):\n",
" os.environ[\"PIPESHIFT_API_KEY\"] = getpass.getpass(\"Enter your Pipeshift API key: \")"
]
},
{
"cell_type": "markdown",
"id": "4b6e1ca6",
"metadata": {},
"source": [
"If you want to get automated tracing of your model calls you can also set your [LangSmith](https://docs.smith.langchain.com/) API key by uncommenting below:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "196c2b41",
"metadata": {},
"outputs": [],
"source": [
"# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
"# os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")"
]
},
{
"cell_type": "markdown",
"id": "809c6577",
"metadata": {},
"source": [
"### Installation\n",
"\n",
"The LangChain Pipeshift integration lives in the `langchain-pipeshift` package:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "59c710c4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"%pip install -qU langchain-pipeshift"
]
},
{
"cell_type": "markdown",
"id": "0a760037",
"metadata": {},
"source": [
"## Instantiation\n",
"\n",
"Now we can instantiate our model object and generate chat completions:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "a0562a13",
"metadata": {},
"outputs": [],
"source": [
"from langchain_pipeshift import Pipeshift\n",
"\n",
"llm = Pipeshift(\n",
" model=\"meta-llama/Meta-Llama-3.1-8B-Instruct\",\n",
" temperature=0,\n",
" max_tokens=512,\n",
")"
]
},
{
"cell_type": "markdown",
"id": "0ee90032",
"metadata": {},
"source": [
"## Invocation"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "035dea0f",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"'\\xa0specializes in digital transformation and innovation for industry leaders. We leverage AI and IoT technology to provide data-driven insights, predictive analysis and decision support systems to our clients.\\nAbout our company:\\nOur company is built around the passion of creating positive impact through AI innovation. Pipeshift brings together top talent in AI, data science, software engineering, and business consultancy to deliver tailored solutions that drive growth and improvement for our clients across various industries.\\nOur Mission and Values:\\nOur mission is to revolutionize industries by harnessing the power of emerging technologies, like AI and IoT, to unlock new potential and drive progress. Our values are built around collaboration, innovation, integrity, customer value, and continuous learning.\\nJob Title: Software Engineer (Mobile App Development)\\nAbout the role:\\nAs a Software Engineer (Mobile App Development) at Pipeshift, you will be at the forefront of cutting-edge mobile app development. Your responsibilities will include designing, developing, and implementing scalable and reliable mobile apps for various platforms, such as Android and iOS.\\nResponsibilities\\nDesign and develop mobile apps for various platforms using Java, Kotlin, Swift, or React Native\\nWork collaboratively with cross-functional teams to gather requirements, plan and prioritize projects\\nImplement UI/UX design principles to deliver user-friendly and visually appealing apps\\nWrite clean, maintainable, and efficient code, adhering to best coding practices and coding standards\\nTest and debug mobile apps to ensure high-quality, reliable, and stable performance\\nCollaborate with the QA team to ensure all mobile apps meet or exceed quality and performance expectations\\nStay up-to-date with industry trends, new technologies, and platform updates to enhance app development skills\\nParticipate in code reviews to ensure code quality and adherence to coding standards\\nSupport the DevOps team in continuous integration and delivery of mobile apps\\nParticipate in the design and maintenance of technical documentation, coding standards and guidelines\\nConduct peer mentoring and training to promote knowledge sharing and growth\\nExperience and requirements\\n2+ years of experience in mobile app development, or relevant technology experience with strong passion for mobile development.\\nProficient in one or more mobile app development frameworks: React Native, iOS (Swift), Android (Kotlin/Java), Flutter, etc.\\nStrong understanding of OOP (object-oriented programming) principles, design patterns, and data structures.\\nExperience with Agile methodologies, version control systems (e.g., Git), and CI/CD pipelines (e.g., Jenkins, Travis CI, CircleCI).\\nGood coding skills in languages such as Java, Kotlin, Swift,'"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"input_text = \"Pipeshift is an AI company that \"\n",
"\n",
"completion = llm.invoke(input_text)\n",
"completion"
]
},
{
"cell_type": "markdown",
"id": "add38532",
"metadata": {},
"source": [
"## Chaining\n",
"\n",
"We can also [chain](/docs/how_to/sequence/) our llm with a prompt template"
]
},
{
"cell_type": "markdown",
"id": "e9bdfcef",
"metadata": {},
"source": [
"## API reference\n",
"\n",
"For detailed documentation of all `Pipeshift` features and configurations head to the API reference: https://dashboard.pipeshift.com/docs "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -0,0 +1,51 @@
# Pipeshift
> [Pipeshift](https://pipeshift.com) is a fine-tuning and inference platform for open-source LLMs
- You bring your datasets. Fine-tune multiple LLMs. Start inferencing in one-click and watch them scale to millions.
## Installation and Setup
- Install the Pipeshift integration package.
```
pip install langchain-pipeshift
```
- Get your Pipeshift API key by signing up at [Pipeshift](https://pipeshift.com).
### Authentication
You can perform authentication using your Pipeshift API key in any of the following ways:
1. Adding API key to the environment variable as `PIPESHIFT_API_KEY`.
```python
os.environ["PIPESHIFT_API_KEY"] = "<your_api_key>"
```
2. By passing `api_key` to the pipeshift LLM module or chat module
```python
llm = Pipeshift(api_key="<your_api_key>", model="meta-llama/Meta-Llama-3.1-8B-Instruct", max_tokens=512)
OR
chat = ChatPipeshift(api_key="<your_api_key>", model="meta-llama/Meta-Llama-3.1-8B-Instruct", max_tokens=512)
```
## Chat models
See an [example](/docs/integrations/chat/pipeshift).
```python
from langchain_pipeshift import ChatPipeshift
```
## LLMs
See an [example](/docs/integrations/llms/pipeshift).
```python
from langchain_pipeshift import Pipeshift
```

View File

@ -346,3 +346,7 @@ packages:
path: .
repo: MehdiZare/langchain-fmp-data
downloads: 0
- name: langchain-pipeshift
path: .
repo: pipeshift-org/langchain-pipeshift
downloads: 115