Skip to content

Commit

Permalink
Merge branch 'master' into patch-6
Browse files Browse the repository at this point in the history
  • Loading branch information
efriis authored Nov 4, 2024
2 parents 24d9e44 + dfa8353 commit 144158f
Show file tree
Hide file tree
Showing 15 changed files with 1,779 additions and 1,650 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,31 @@ jobs:
PKG_NAME: ${{ needs.build.outputs.pkg-name }}
VERSION: ${{ needs.build.outputs.version }}
run: |
REGEX="^$PKG_NAME==\\d+\\.\\d+\\.\\d+\$"
echo $REGEX
PREV_TAG=$(git tag --sort=-creatordate | grep -P $REGEX || true | head -1)
PREV_TAG="${curr_version%.*}.$(( ${curr_version##*.} - 1 ))"; [[ "${curr_version##*.}" -eq 0 ]] && PREV_TAG=""
# backup case if releasing e.g. 0.3.0, looks up last release
# note if last release (chronologically) was e.g. 0.1.47 it will get
# that instead of the last 0.2 release
if [ -z "$PREV_TAG" ]; then
REGEX="^$PKG_NAME==\\d+\\.\\d+\\.\\d+\$"
echo $REGEX
PREV_TAG=$(git tag --sort=-creatordate | grep -P $REGEX || true | head -1)
fi
# confirm prev-tag actually exists in git repo with git tag
if [ -z git tag -l "$PREV_TAG" ]; then
echo "Previous tag $PREV_TAG not found in git repo"
exit 1
fi
TAG="${PKG_NAME}==${VERSION}"
if [ "$TAG" == "$PREV_TAG" ]; then
echo "No new version to release"
exit 1
fi
echo tag="$TAG" >> $GITHUB_OUTPUT
echo prev-tag="$PREV_TAG" >> $GITHUB_OUTPUT
echo prev-tag="$PKG_NAME==$last_version" >> $GITHUB_OUTPUT
- name: Generate release body
id: generate-release-body
working-directory: langchain
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/how_to/document_loader_csv.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
" temp_file_path = temp_file.name\n",
"\n",
"loader = CSVLoader(file_path=temp_file_path)\n",
"loader.load()\n",
"data = loader.load()\n",
"for record in data[:2]:\n",
" print(record)"
]
Expand Down
12 changes: 12 additions & 0 deletions docs/src/theme/FeatureTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ const FEATURE_TABLES = {
package: "langchain-google_vertexai",
apiLink: "https://python.langchain.com/api_reference/google_vertexai/llms/langchain_google_vertexai.llms.VertexAI.html"
},
{
name: "NVIDIA",
link: "NVIDIA",
package: "langchain-nvidia",
apiLink: "https://python.langchain.com/api_reference/nvidia_ai_endpoints/llm/langchain_nvidia_ai_endpoints.llm.NVIDIA.html"
},
],
},
text_embedding: {
Expand Down Expand Up @@ -387,6 +393,12 @@ const FEATURE_TABLES = {
package: "langchain-ibm",
apiLink: "https://python.langchain.com/api_reference/ibm/embeddings/langchain_ibm.embeddings.WatsonxEmbeddings.html"
},
{
name: "NVIDIA",
link: "NVIDIAEmbeddings",
package: "langchain-nvidia",
apiLink: "https://python.langchain.com/api_reference/nvidia_ai_endpoints/embeddings/langchain_nvidia_ai_endpoints.embeddings.NVIDIAEmbeddings.html"
},
]
},
document_retrievers: {
Expand Down
2 changes: 1 addition & 1 deletion docs/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"destination": "/docs/integrations/providers/:path*"
},
{
"source": "/docs/troubleshooting/errors/:path((?:GRAPH_RECURSION_LIMIT|INVALID_CONCURRENT_GRAPH_UPDATE|INVALID_GRAPH_NODE_RETURN_VALUE|MULTIPLE_SUBGRAPHS)/?)*",
"source": "/docs/troubleshooting/errors/:path((?:GRAPH_RECURSION_LIMIT|INVALID_CONCURRENT_GRAPH_UPDATE|INVALID_GRAPH_NODE_RETURN_VALUE|MULTIPLE_SUBGRAPHS|INVALID_CHAT_HISTORY)/?)*",
"destination": "https://langchain-ai.github.io/langgraph/troubleshooting/errors/:path*"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PowerBIToolkit(BaseToolkit):
examples: Optional. The examples for the prompt. Default is None.
max_iterations: Optional. The maximum iterations to run. Default is 5.
callback_manager: Optional. The callback manager. Default is None.
output_token_limit: Optional. The output token limit. Default is None.
output_token_limit: The output token limit. Default is 4000.
tiktoken_model_name: Optional. The TikToken model name. Default is None.
"""

Expand All @@ -60,7 +60,7 @@ class PowerBIToolkit(BaseToolkit):
examples: Optional[str] = None
max_iterations: int = 5
callback_manager: Optional[BaseCallbackManager] = None
output_token_limit: Optional[int] = None
output_token_limit: int = 4000
tiktoken_model_name: Optional[str] = None

model_config = ConfigDict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ def convert_message_to_dict(message: BaseMessage) -> dict:
message_dict = {"role": "assistant", "content": message.content}
if "function_call" in message.additional_kwargs:
message_dict["function_call"] = message.additional_kwargs["function_call"]
# If function call only, content is None not empty string
if message_dict["content"] == "":
message_dict["content"] = None
elif len(message.tool_calls) != 0:
tool_call = message.tool_calls[0]
message_dict["function_call"] = {
"name": tool_call["name"],
"args": tool_call["args"],
}

# If function call only, content is None not empty string
if "function_call" in message_dict and message_dict["content"] == "":
message_dict["content"] = None
elif isinstance(message, (FunctionMessage, ToolMessage)):
message_dict = {
"role": "function",
Expand Down
11 changes: 10 additions & 1 deletion libs/core/langchain_core/output_parsers/list.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import annotations

import csv
import re
from abc import abstractmethod
from collections import deque
from collections.abc import AsyncIterator, Iterator
from io import StringIO
from typing import Optional as Optional
from typing import TypeVar, Union

Expand Down Expand Up @@ -162,7 +164,14 @@ def parse(self, text: str) -> list[str]:
Returns:
A list of strings.
"""
return [part.strip() for part in text.split(",")]
try:
reader = csv.reader(
StringIO(text), quotechar='"', delimiter=",", skipinitialspace=True
)
return [item for sublist in reader for item in sublist]
except csv.Error:
# keep old logic for backup
return [part.strip() for part in text.split(",")]

@property
def _type(self) -> str:
Expand Down
19 changes: 19 additions & 0 deletions libs/core/tests/unit_tests/output_parsers/test_list_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,25 @@ def test_multiple_items() -> None:
assert list(parser.transform(iter([text]))) == [[a] for a in expected]


def test_multiple_items_with_comma() -> None:
"""Test that a string with multiple comma-separated items with 1 item containing a
comma is parsed to a list."""
parser = CommaSeparatedListOutputParser()
text = '"foo, foo2",bar,baz'
expected = ["foo, foo2", "bar", "baz"]

assert parser.parse(text) == expected
assert add(parser.transform(t for t in text)) == expected
assert list(parser.transform(t for t in text)) == [[a] for a in expected]
assert list(parser.transform(t for t in text.splitlines(keepends=True))) == [
[a] for a in expected
]
assert list(
parser.transform(" " + t if i > 0 else t for i, t in enumerate(text.split(" ")))
) == [[a] for a in expected]
assert list(parser.transform(iter([text]))) == [[a] for a in expected]


def test_numbered_list() -> None:
parser = NumberedListOutputParser()
text1 = (
Expand Down
Loading

0 comments on commit 144158f

Please sign in to comment.