Commit Graph

8742 Commits (7997f3b7f8f9577af9f733828211c8a7dc095932)
 

Author SHA1 Message Date
Bagatur d2f4153fe6
docs: tool call nits (#20356) 5 months ago
Bagatur eafd8c580b
docs: tool agent nit (#20353) 5 months ago
Erick Friis ec0273fc92
chroma: release 0.1.0 (#20355) 5 months ago
Bagatur a889cd14f3
docs: use vertexai in chat model tabs (#20352) 5 months ago
Bagatur 9d302c1b57
docs: update anthropic tool call (#20344) 5 months ago
Erick Friis da707d0755
chroma: remove relevance score int test (#20346)
deprecating feature in #20302
5 months ago
Eugene Yurtsev de938a4451
docs: Update chat model providers include package information (#20336)
Include package information
5 months ago
Bagatur 56fe4ab382
docs: update tool-calling table (#20338) 5 months ago
Bagatur 43a98592c1
docs: tool agent nit (#20337) 5 months ago
Bagatur 562b546bcc
docs: update chat openai (#20331) 5 months ago
Bagatur 2c4741b5ed
docs: add tool-calling agent (#20328) 5 months ago
ccurme f02e55aaf7
docs: add component page for tool calls (#20282)
Note: includes links to API reference pages for ToolCall and other
objects that currently don't exist (e.g.,
https://api.python.langchain.com/en/latest/messages/langchain_core.messages.tool.ToolCall.html#langchain_core.messages.tool.ToolCall).
5 months ago
Bagatur 6608089030
langchain[patch]: Release 0.1.16 (#20335) 5 months ago
Eugene Yurtsev 0e74fb4ec1
docs: Update list of chat models tool calling providers (#20330)
Will follow up with a few missing providers
5 months ago
Eugene Yurtsev 653489a1a9
docs: Update documentation for custom LLMs (#19972)
Update documentation for customizing LLMs
5 months ago
Bagatur 799714c629
release anthropic, fireworks, openai, groq, mistral (#20333) 5 months ago
Bagatur e72330aacc
core[patch]: Release 0.1.42 (#20332) 5 months ago
ccurme 795c728f71
mistral[patch]: add IDs to tool calls (#20299)
Mistral gives us one ID per response, no individual IDs for tool calls.

```python
from langchain.agents import AgentExecutor, create_tool_calling_agent, tool
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_mistralai import ChatMistralAI


prompt = ChatPromptTemplate.from_messages(
    [
        ("system", "You are a helpful assistant"),
        ("human", "{input}"),
        MessagesPlaceholder("agent_scratchpad"),
    ]
)
model = ChatMistralAI(model="mistral-large-latest", temperature=0)

@tool
def magic_function(input: int) -> int:
    """Applies a magic function to an input."""
    return input + 2

tools = [magic_function]

agent = create_tool_calling_agent(model, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

agent_executor.invoke({"input": "what is the value of magic_function(3)?"})
```

---------

Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
5 months ago
Eugene Yurtsev 22fd844e8a
community[patch]: Add deprecation warnings to postgres implementation (#20222)
Add deprecation warnings to postgres implementation that are in langchain-postgres.
5 months ago
Eugene Yurtsev f02f708f52
core[patch]: For now remove user warning (#20321)
Remove warning since it creates a lot of noise.
5 months ago
Mayank Solanki f709ab4cdf
docs: added backtick on RunnablePassthrough (#20310)
added backtick on RunnablePassthrough
Isuue: #20094
5 months ago
Bagatur c706689413
openai[patch]: use tool_calls in request (#20272) 5 months ago
Bagatur e936fba428
langchain[patch]: agents check prompt partial vars (#20303) 5 months ago
Bagatur cb25fa0d55
core[patch]: fix ChatGeneration.text with content blocks (#20294) 5 months ago
Bagatur 03b247cca1
core[patch]: include tool_calls in ai msg chunk serialization (#20291) 5 months ago
Erick Friis 0fa551c278
chroma: bump rc, keep optional (#20298) 5 months ago
Erick Friis 16f8fff14f
chroma: add required fastapi dep to restrict to <1 (#20297) 5 months ago
Erick Friis 991fd82532
chroma: add optional fastapi dep to restrict to <1 (#20295) 5 months ago
killind-dev f8a54d1d73
chroma: Add chroma partner package (#19292)
**Description:** Adds chroma to the partners package. Tests & code
mirror those in the community package.
**Dependencies:** None
**Twitter handle:** @akiradev0x

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
5 months ago
Yuki Watanabe eef19954f3
core[patch]: fix duplicated kwargs in `_load_sql_databse_chain` (#19908)
`kwargs` is specified twice in [this
line](3218463f6a/libs/langchain/langchain/chains/loading.py (L386)),
causing runtime error when passing any keyword arguments.
5 months ago
ccurme 39471a9c87
docs: update tool calling cookbook (#20290)
Co-authored-by: Erick Friis <erick@langchain.dev>
5 months ago
Nuno Campos 15271ac832
core: mustache prompt templates (#19980)
Co-authored-by: Erick Friis <erick@langchain.dev>
5 months ago
Leonid Ganeline 4cb5f4c353
community[patch]: import flattening fix (#20110)
This PR should make it easier for linters to do type checking and for IDEs to jump to definition of code.

See #20050 as a template for this PR.
- As a byproduct: Added 3 missed `test_imports`.
- Added missed `SolarChat` in to __init___.py Added it into test_import
ut.
- Added `# type: ignore` to fix linting. It is not clear, why linting
errors appear after ^ changes.

---------

Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
5 months ago
Yuki Oshima 12190ad728
openai[patch]: Fix langchain-openai unknown parameter error with gpt-4-turbo (#20271)
**Description:** 

I fixed langchain-openai unknown parameter error with gpt-4-turbo.

It seems that the behavior of the Chat Completions API implicitly
changed when using the latest gpt-4-turbo model, differing from previous
models. It now appears to reject parameters that are not listed in the
[API
Reference](https://platform.openai.com/docs/api-reference/chat/create).
So I found some errors and fixed them.

**Issue:** https://github.com/langchain-ai/langchain/issues/20264

**Dependencies:** none

**Twitter handle:** https://twitter.com/oshima_123
5 months ago
ccurme 21c1ce0bc1
update agents to use tool call messages (#20074)
```python
from langchain.agents import AgentExecutor, create_tool_calling_agent, tool
from langchain_anthropic import ChatAnthropic
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder

prompt = ChatPromptTemplate.from_messages(
    [
        ("system", "You are a helpful assistant"),
        MessagesPlaceholder("chat_history", optional=True),
        ("human", "{input}"),
        MessagesPlaceholder("agent_scratchpad"),
    ]
)
model = ChatAnthropic(model="claude-3-opus-20240229")

@tool
def magic_function(input: int) -> int:
    """Applies a magic function to an input."""
    return input + 2

tools = [magic_function]

agent = create_tool_calling_agent(model, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

agent_executor.invoke({"input": "what is the value of magic_function(3)?"})
```
```
> Entering new AgentExecutor chain...

Invoking: `magic_function` with `{'input': 3}`
responded: [{'text': '<thinking>\nThe user has asked for the value of magic_function applied to the input 3. Looking at the available tools, magic_function is the relevant one to use here, as it takes an integer input and returns an integer output.\n\nThe magic_function has one required parameter:\n- input (integer)\n\nThe user has directly provided the value 3 for the input parameter. Since the required parameter is present, we can proceed with calling the function.\n</thinking>', 'type': 'text'}, {'id': 'toolu_01HsTheJPA5mcipuFDBbJ1CW', 'input': {'input': 3}, 'name': 'magic_function', 'type': 'tool_use'}]

5
Therefore, the value of magic_function(3) is 5.

> Finished chain.
{'input': 'what is the value of magic_function(3)?',
 'output': 'Therefore, the value of magic_function(3) is 5.'}
```

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
5 months ago
Erick Friis 9eb6f538f0
infra, multiple: rc release versions (#20252) 5 months ago
Bagatur 0d0458d1a7
mistralai[patch]: Pre-release 0.1.2-rc.1 (#20251) 5 months ago
Bagatur e4046939d0
anthropic[patch]: Pre-release 0.1.8-rc.1 (#20250) 5 months ago
Bagatur a8eb0f5b1b
openai[patch]: pre-release 0.1.3-rc.1 (#20249) 5 months ago
Bagatur a43b9e4f33
core[patch]: Pre-release 0.1.42-rc.1 (#20248) 5 months ago
Bagatur 9514bc4d67
core[minor], ...: add tool calls message (#18947)
core[minor], langchain[patch], openai[minor], anthropic[minor], fireworks[minor], groq[minor], mistralai[minor]

```python
class ToolCall(TypedDict):
    name: str
    args: Dict[str, Any]
    id: Optional[str]

class InvalidToolCall(TypedDict):
    name: Optional[str]
    args: Optional[str]
    id: Optional[str]
    error: Optional[str]

class ToolCallChunk(TypedDict):
    name: Optional[str]
    args: Optional[str]
    id: Optional[str]
    index: Optional[int]


class AIMessage(BaseMessage):
    ...
    tool_calls: List[ToolCall] = []
    invalid_tool_calls: List[InvalidToolCall] = []
    ...


class AIMessageChunk(AIMessage, BaseMessageChunk):
    ...
    tool_call_chunks: Optional[List[ToolCallChunk]] = None
    ...
```
Important considerations:
- Parsing logic occurs within different providers;
- ~Changing output type is a breaking change for anyone doing explicit
type checking;~
- ~Langsmith rendering will need to be updated:
https://github.com/langchain-ai/langchainplus/pull/3561~
- ~Langserve will need to be updated~
- Adding chunks:
- ~AIMessage + ToolCallsMessage = ToolCallsMessage if either has
non-null .tool_calls.~
- Tool call chunks are appended, merging when having equal values of
`index`.
  - additional_kwargs accumulate the normal way.
- During streaming:
- ~Messages can change types (e.g., from AIMessageChunk to
AIToolCallsMessageChunk)~
- Output parsers parse additional_kwargs (during .invoke they read off
tool calls).

Packages outside of `partners/`:
- https://github.com/langchain-ai/langchain-cohere/pull/7
- https://github.com/langchain-ai/langchain-google/pull/123/files

---------

Co-authored-by: Chester Curme <chester.curme@gmail.com>
5 months ago
Erick Friis 00552918ac
groq: xfail tool_choice tests (#20247) 5 months ago
Bagatur 2d83505be9
experimental[patch]: Release 0.0.57 (#20243) 5 months ago
Bagatur f06cb59ab9
groq[patch]: Release 0.1.1 (#20242) 5 months ago
Erick Friis ad3f1a9e85
docs: fix external repo partner docs (#20238) 5 months ago
Bagatur 0b2f0307d7
openai[patch]: Release 0.1.2 (#20241) 5 months ago
Bagatur 4b84c9b28c
anthropic[patch]: Release 0.1.7 (#20240) 5 months ago
Bagatur 74d04a4e80
mistralai[patch]: Release 0.1.1 (#20239) 5 months ago
Bagatur e5913c8758
langchain[patch]: Release 0.1.15 (#20237) 5 months ago
Bagatur e39fdfddf1
community[patch]: Release 0.0.32 (#20236) 5 months ago