Skip to content

Commit

Permalink
upstage: init package (#20574)
Browse files Browse the repository at this point in the history
Co-authored-by: Sean Cho <[email protected]>
Co-authored-by: JuHyung-Son <[email protected]>
  • Loading branch information
3 people authored Apr 17, 2024
1 parent 11c9ed3 commit f09bd0b
Show file tree
Hide file tree
Showing 38 changed files with 2,947 additions and 2,423 deletions.
1 change: 1 addition & 0 deletions .github/workflows/_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
MONGODB_ATLAS_URI: ${{ secrets.MONGODB_ATLAS_URI }}
VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }}
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
UPSTAGE_API_KEY: ${{ secrets.UPSTAGE_API_KEY }}
run: |
make integration_tests
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # for airbyte
MONGODB_ATLAS_URI: ${{ secrets.MONGODB_ATLAS_URI }}
VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }}
UPSTAGE_API_KEY: ${{ secrets.UPSTAGE_API_KEY }}
run: make integration_tests
working-directory: ${{ inputs.working-directory }}

Expand Down
80 changes: 0 additions & 80 deletions docs/docs/integrations/chat/solar.ipynb

This file was deleted.

157 changes: 157 additions & 0 deletions docs/docs/integrations/chat/upstage.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
{
"cells": [
{
"cell_type": "raw",
"id": "910f5772b6af13c9",
"metadata": {
"collapsed": false
},
"source": [
"---\n",
"sidebar_label: Upstage\n",
"---"
]
},
{
"cell_type": "markdown",
"id": "433f5422ad8e1efa",
"metadata": {
"collapsed": false
},
"source": [
"# ChatUpstage\n",
"\n",
"This notebook covers how to get started with Upstage chat models.\n",
"\n",
"## Installation\n",
"\n",
"Install `langchain-upstage` package.\n",
"\n",
"```bash\n",
"pip install -U langchain-upstage\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "b3c5c4627fe95eae",
"metadata": {
"collapsed": false
},
"source": [
"## Environment Setup\n",
"\n",
"Make sure to set the following environment variables:\n",
"\n",
"- `UPSTAGE_API_KEY`: Your Upstage API key from [Upstage console](https://console.upstage.ai/).\n",
"\n",
"## Usage"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "20a0067b",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"os.environ[\"UPSTAGE_API_KEY\"] = \"YOUR_API_KEY\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8a4d650d76a33494",
"metadata": {
"collapsed": false,
"is_executing": true
},
"outputs": [],
"source": [
"from langchain_core.prompts import ChatPromptTemplate\n",
"from langchain_upstage import ChatUpstage\n",
"\n",
"chat = ChatUpstage()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a1679b5cafaf88b9",
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# using chat invoke\n",
"chat.invoke(\"Hello, how are you?\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "698a788a63b5c3e5",
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# using chat stream\n",
"for m in chat.stream(\"Hello, how are you?\"):\n",
" print(m)"
]
},
{
"cell_type": "markdown",
"id": "36f8a703",
"metadata": {},
"source": [
"## Chaining"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "efa06617e5d4f6b2",
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# using chain\n",
"prompt = ChatPromptTemplate.from_messages(\n",
" [\n",
" (\"system\", \"You are a helpful assistant that translates English to French.\"),\n",
" (\"human\", \"Translate this sentence from English to French. {english_text}.\"),\n",
" ]\n",
")\n",
"chain = prompt | chat\n",
"\n",
"chain.invoke({\"english_text\": \"Hello, how are you?\"})"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
95 changes: 17 additions & 78 deletions docs/docs/integrations/llms/solar.ipynb
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Solar\n",
"\n",
"*This community integration is deprecated. You should use [`ChatUpstage`](../../chat/upstage) instead to access Solar LLM via the chat model connector.*"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "2ff00e23-1a90-4a39-b220-83ebfffd96d6",
"metadata": {
"execution": {
"iopub.execute_input": "2024-03-06T17:10:57.375714Z",
"iopub.status.busy": "2024-03-06T17:10:57.375261Z",
"iopub.status.idle": "2024-03-06T17:11:03.473978Z",
"shell.execute_reply": "2024-03-06T17:11:03.472875Z",
"shell.execute_reply.started": "2024-03-06T17:10:57.375670Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"\"Once upon a time, in a far-off land, there was a young girl named Lily. Lily was a kind and curious girl who loved to explore the world around her. One day, while wandering through the forest, she came across a small, shimmering pond.\\n\\nAs she approached the pond, she saw a beautiful, glowing flower floating on the water's surface. Lily reached out to touch the flower, and as she did, she felt a strange tingling sensation. Suddenly, the flower began to glow even brighter, and Lily was transported to a magical world filled with talking animals and enchanted forests.\\n\\nIn this world, Lily met a wise old owl named Winston who told her that the flower she had touched was a magical one that could grant her any wish she desired. Lily was overjoyed and asked Winston to show her around the magical world.\\n\\nTogether, they explored the enchanted forests, met friendly animals, and discovered hidden treasures. Lily was having the time of her life, but she knew that she couldn't stay in this magical world forever. Eventually, she had to return home.\\n\\nAs she said goodbye to Winston and the magical world, Lily realized that she had learned an important lesson. She had discovered that sometimes, the most magical things in life are the ones that are right in front of us, if we only take the time to look.\\n\\nFrom that day on, Lily always kept her eyes open for the magic in the world around her, and she never forgot the adventure she had in the enchanted forest.\""
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
Expand All @@ -37,37 +26,9 @@
},
{
"cell_type": "code",
"execution_count": 2,
"id": "67fa1711-f08f-43fa-a3bd-75ae5bc6b988",
"metadata": {
"execution": {
"iopub.execute_input": "2024-03-06T17:11:11.359924Z",
"iopub.status.busy": "2024-03-06T17:11:11.358357Z",
"iopub.status.idle": "2024-03-06T17:11:16.692138Z",
"shell.execute_reply": "2024-03-06T17:11:16.686492Z",
"shell.execute_reply.started": "2024-03-06T17:11:11.359835Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/ary/dev/llm/langchain/libs/core/langchain_core/_api/deprecation.py:117: LangChainDeprecationWarning: The function `run` was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use invoke instead.\n",
" warn_deprecated(\n"
]
},
{
"data": {
"text/plain": [
"'Step 1: Determine the year Justin Bieber was born.\\nJustin Bieber was born on March 1, 1994.\\n\\nStep 2: Determine the Super Bowl held in 1994.\\nSuper Bowl XXVIII was held in 1994.\\n\\nStep 3: Determine the winning team of Super Bowl XXVIII.\\nThe Dallas Cowboys won Super Bowl XXVIII in 1994.\\n\\nFinal Answer: The Dallas Cowboys won the Super Bowl in the year Justin Bieber was born (1994).'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from langchain.chains import LLMChain\n",
"from langchain.prompts import PromptTemplate\n",
Expand All @@ -86,35 +47,13 @@
"\n",
"llm_chain.run(question)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "91961983-d0d5-4901-b854-531e158c0416",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.9.0"
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
"nbformat_minor": 2
}
1 change: 1 addition & 0 deletions docs/docs/integrations/platforms/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ These providers have standalone `langchain-{provider}` packages for improved ver
- [Pinecone](/docs/integrations/providers/pinecone)
- [Robocorp](/docs/integrations/providers/robocorp)
- [Together AI](/docs/integrations/providers/together)
- [Upstage](/docs/integrations/providers/upstage)
- [Voyage AI](/docs/integrations/providers/voyageai)


Expand Down
Loading

0 comments on commit f09bd0b

Please sign in to comment.