Skip to content

Commit

Permalink
Merge branch 'master' into snova-jorgep/bind_tools_sambanova_chat_models
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpiedrahitao authored Nov 11, 2024
2 parents d833044 + 922b6b0 commit 89a474c
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 50 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
eNrtlglUE2cewMNiXWvdFteT1uoUsdWWCZNkcoGoyCUiBATk8GAnM1+SgclMmJkAifYQ64laR6y1Xm01EEEExQNEsbZ9nvXc5wXaw1Vr1fWoLWppa/dLgAqru+91V99rd528N5P5vv/8v//5fb9Cdx7gBZpjfSpoVgQ8QYrwRSgudPMg1w4E8c1SKxAtHOVKNCSnrLbzdMPLFlG0CSHBwYSNlnM2wBK0nOSswXmKYNJCiMHwv40BXjUuI0c5GiomB1iBIBBmIASEIOMnB5AcXIoV4UtAGk+LACEQOETSAkAEu9VK8A6EMyGiBSAmjmG4fJo1hyDhNqhVQAgeIDygAoKQAJ5jgEeHXQB8wKsT4YiVowDjGTLbRBTnUCvN0h5JFo4p4FMQeUBY4YuJYAQAB0RgtUGnRTvv0YTJsVfdFkBQMCRvuSycIEqVHZ2sIkgSQN2AJTkKmiWtMztpWxBCARNDiKAcusECbwil8hwAbCjB0HmgtOUraT0BfaBJwjMfnC1wbEVrJFDRYQP3T5d7PENh3FhR2houOFjSAC0Jjw1OdMCUsIhCrlbKsfUFqCASNAujI6AMAY0qtXnnt7WfsBFkDtSEtqZbKm35uLK9DCdIJfEEaUjuoJLgSYtUQvBWDb6x/ThvZ0XaCiR3ROL9y7VO3ltOJVdgcnxDB8Uej6R13keI905zNR2UAJF3oCQHdUkfYJVtwWIAaxYt0mqFVrmGB4INFhqYVgo/E+1CoQsmBhzY626tuFWGuLaMfi7r44qESZLqU+ww90olYiBFRIkpcXgLUepD1DgSE59SEdG6TMoDc7IhhSdYwQTzEtVWA27SYmdz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mtUynn/ZflZSO9TJ07dP0F33OPlM9Tz79u+Drj9pnesa9bhqtJrL2tr3l1ZdXraq+eDr267vMzjapct2XFJRQdtN3L2RI7W0lMOhJ09/9GLVWs7GBrm3T+Si23ta0dWSOcGLjh+4612dfgtQ/KoDzVhB/YrT4cVHr79WeyNb5KHDImdcChQrO5+8esHvZn1Xxxa+qrqJzAzrcvl3PEes8IiTnUSLwhT+1xBb60u2rzv4Tf5s12vuh352p4eXOJessA+kq2NI8/2OTkjVj03Jfvm0j6l2vxlPb/csfWG7a11IRdi3LVgWptGQCuue7h2GAS0fwIz6Q8x

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/concepts/chat_models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Models that do **not** include the prefix "Chat" in their name or include "LLM"

## Interface

LangChain chat models implement the [BaseChatModel](https://python.langchain.com/api_reference/core/language_models/langchain_core.language_models.chat_models.BaseChatModel.html) interface. Because [BaseChatModel] also implements the [Runnable Interface](/docs/concepts/runnables), chat models support a [standard streaming interface](/docs/concepts/streaming), [async programming](/docs/concepts/async), optimized [batching](/docs/concepts/runnables/#optimized-parallel-execution-batch), and more. Please see the [Runnable Interface](/docs/concepts/runnables) for more details.
LangChain chat models implement the [BaseChatModel](https://python.langchain.com/api_reference/core/language_models/langchain_core.language_models.chat_models.BaseChatModel.html) interface. Because `BaseChatModel` also implements the [Runnable Interface](/docs/concepts/runnables), chat models support a [standard streaming interface](/docs/concepts/streaming), [async programming](/docs/concepts/async), optimized [batching](/docs/concepts/runnables/#optimized-parallel-execution-batch), and more. Please see the [Runnable Interface](/docs/concepts/runnables) for more details.

Many of the key methods of chat models operate on [messages](/docs/concepts/messages) as input and return messages as output.

Expand Down
3 changes: 3 additions & 0 deletions docs/docs/how_to/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ These are the core building blocks you can use when building applications.
### Chat models

[Chat Models](/docs/concepts/chat_models) are newer forms of language models that take messages in and output a message.
See [supported integrations](/docs/integrations/chat/) for details on getting started with chat models from a specific provider.

- [How to: do function/tool calling](/docs/how_to/tool_calling)
- [How to: get models to return structured output](/docs/how_to/structured_output)
Expand Down Expand Up @@ -153,13 +154,15 @@ What LangChain calls [LLMs](/docs/concepts/text_llms) are older forms of languag
### Embedding models

[Embedding Models](/docs/concepts/embedding_models) take a piece of text and create a numerical representation of it.
See [supported integrations](/docs/integrations/text_embedding/) for details on getting started with embedding models from a specific provider.

- [How to: embed text data](/docs/how_to/embed_text)
- [How to: cache embedding results](/docs/how_to/caching_embeddings)

### Vector stores

[Vector stores](/docs/concepts/vectorstores) are databases that can efficiently store and retrieve embeddings.
See [supported integrations](/docs/integrations/vectorstores/) for details on getting started with vector stores from a specific provider.

- [How to: use a vector store to retrieve data](/docs/how_to/vectorstores)

Expand Down
17 changes: 11 additions & 6 deletions docs/docs/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
Concretely, the framework consists of the following open-source libraries:

- **`langchain-core`**: Base abstractions and LangChain Expression Language.
- **`langchain-community`**: Third party integrations.
- Partner packages (e.g. **`langchain-openai`**, **`langchain-anthropic`**, etc.): Some integrations have been further split into their own lightweight packages that only depend on **`langchain-core`**.
- Integration packages (e.g. **`langchain-openai`**, **`langchain-anthropic`**, etc.): Important integrations have been split into lightweight packages that are co-maintained by the LangChain team and the integration developers.
- **`langchain`**: Chains, agents, and retrieval strategies that make up an application's cognitive architecture.
- **`langchain-community`**: Third-party integrations that are community maintained.
- **[LangGraph](https://langchain-ai.github.io/langgraph)**: Build robust and stateful multi-actor applications with LLMs by modeling steps as edges and nodes in a graph. Integrates smoothly with LangChain, but can be used without it.
- **[LangServe](/docs/langserve)**: Deploy LangChain chains as REST APIs.
- **[LangSmith](https://docs.smith.langchain.com)**: A developer platform that lets you debug, test, evaluate, and monitor LLM applications.
Expand Down Expand Up @@ -62,7 +62,8 @@ Explore the full list of LangChain tutorials [here](/docs/tutorials), and check

[Here](/docs/how_to) you’ll find short answers to “How do I….?” types of questions.
These how-to guides don’t cover topics in depth – you’ll find that material in the [Tutorials](/docs/tutorials) and the [API Reference](https://python.langchain.com/api_reference/).
However, these guides will help you quickly accomplish common tasks.
However, these guides will help you quickly accomplish common tasks using [chat models](/docs/how_to/#chat-models),
[vector stores](/docs/how_to/#vector-stores), and other common LangChain components.

Check out [LangGraph-specific how-tos here](https://langchain-ai.github.io/langgraph/how-tos/).

Expand All @@ -72,6 +73,13 @@ Introductions to all the key parts of LangChain you’ll need to know! [Here](/d

For a deeper dive into LangGraph concepts, check out [this page](https://langchain-ai.github.io/langgraph/concepts/).

## [Integrations](integrations/providers/index.mdx)

LangChain is part of a rich ecosystem of tools that integrate with our framework and build on top of it.
If you're looking to get up and running quickly with [chat models](/docs/integrations/chat/), [vector stores](/docs/integrations/vectorstores/),
or other LangChain components from a specific provider, check out our growing list of [integrations](/docs/integrations/providers/).


## [API reference](https://python.langchain.com/api_reference/)
Head to the reference section for full documentation of all classes and methods in the LangChain Python packages.

Expand All @@ -91,8 +99,5 @@ See what changed in v0.3, learn how to migrate legacy code, read up on our versi
### [Security](/docs/security)
Read up on [security](/docs/security) best practices to make sure you're developing safely with LangChain.

### [Integrations](integrations/providers/index.mdx)
LangChain is part of a rich ecosystem of tools that integrate with our framework and build on top of it. Check out our growing list of [integrations](/docs/integrations/providers/).

### [Contributing](contributing/index.mdx)
Check out the developer's guide for guidelines on contributing and help getting your dev environment set up.
9 changes: 8 additions & 1 deletion docs/docs/tutorials/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ sidebar_class_name: hidden
---
# Tutorials

New to LangChain or LLM app development in general? Read this material to quickly get up and running.
New to LangChain or LLM app development in general? Read this material to quickly get up and running building your first applications.

If you're looking to get up and running quickly with [chat models](/docs/integrations/chat/), [vector stores](/docs/integrations/vectorstores/),
or other LangChain components from a specific provider, check out our supported [integrations](/docs/integrations/providers/).

Refer to the [how-to guides](/docs/how_to) for more detail on using common LangChain components.

See the [conceptual documentation](/docs/concepts) for high level explanations of all LangChain concepts.

## Basics
- [LLM applications](/docs/tutorials/llm_chain): Build and deploy a simple LLM application.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/tutorials/llm_chain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"source": [
"## Using Language Models\n",
"\n",
"First up, let's learn how to use a language model by itself. LangChain supports many different language models that you can use interchangeably - select the one you want to use below!\n",
"First up, let's learn how to use a language model by itself. LangChain supports many different language models that you can use interchangeably. For details on getting started with a specific model, refer to [supported integrations](/docs/integrations/chat/).\n",
"\n",
"import ChatModelTabs from \"@theme/ChatModelTabs\";\n",
"\n",
Expand Down
58 changes: 22 additions & 36 deletions libs/partners/openai/langchain_openai/chat_models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,24 +632,6 @@ def _stream(
default_chunk_class: Type[BaseMessageChunk] = AIMessageChunk
base_generation_info = {}

if "response_format" in payload and is_basemodel_subclass(
payload["response_format"]
):
# TODO: Add support for streaming with Pydantic response_format.
warnings.warn("Streaming with Pydantic response_format not yet supported.")
chat_result = self._generate(
messages, stop, run_manager=run_manager, **kwargs
)
msg = chat_result.generations[0].message
yield ChatGenerationChunk(
message=AIMessageChunk(
**msg.dict(exclude={"type", "additional_kwargs"}),
# preserve the "parsed" Pydantic object without converting to dict
additional_kwargs=msg.additional_kwargs,
),
generation_info=chat_result.generations[0].generation_info,
)
return
if self.include_response_headers:
raw_response = self.client.with_raw_response.create(**payload)
response = raw_response.parse()
Expand Down Expand Up @@ -783,24 +765,6 @@ async def _astream(
payload = self._get_request_payload(messages, stop=stop, **kwargs)
default_chunk_class: Type[BaseMessageChunk] = AIMessageChunk
base_generation_info = {}
if "response_format" in payload and is_basemodel_subclass(
payload["response_format"]
):
# TODO: Add support for streaming with Pydantic response_format.
warnings.warn("Streaming with Pydantic response_format not yet supported.")
chat_result = await self._agenerate(
messages, stop, run_manager=run_manager, **kwargs
)
msg = chat_result.generations[0].message
yield ChatGenerationChunk(
message=AIMessageChunk(
**msg.dict(exclude={"type", "additional_kwargs"}),
# preserve the "parsed" Pydantic object without converting to dict
additional_kwargs=msg.additional_kwargs,
),
generation_info=chat_result.generations[0].generation_info,
)
return
if self.include_response_headers:
raw_response = await self.async_client.with_raw_response.create(**payload)
response = raw_response.parse()
Expand Down Expand Up @@ -999,6 +963,28 @@ def get_num_tokens_from_messages(self, messages: List[BaseMessage]) -> int:
num_tokens += 3
return num_tokens

def _should_stream(
self,
*,
async_api: bool,
run_manager: Optional[
Union[CallbackManagerForLLMRun, AsyncCallbackManagerForLLMRun]
] = None,
response_format: Optional[Union[dict, type]] = None,
**kwargs: Any,
) -> bool:
if isinstance(response_format, type) and is_basemodel_subclass(response_format):
# TODO: Add support for streaming with Pydantic response_format.
warnings.warn("Streaming with Pydantic response_format not yet supported.")
return False
if self.model_name.startswith("o1"):
# TODO: Add support for streaming with o1 once supported.
return False

return super()._should_stream(
async_api=async_api, run_manager=run_manager, **kwargs
)

@deprecated(
since="0.2.1",
alternative="langchain_openai.chat_models.base.ChatOpenAI.bind_tools",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1061,3 +1061,27 @@ def test_prediction_tokens() -> None:
]
assert output_token_details["accepted_prediction_tokens"] > 0
assert output_token_details["rejected_prediction_tokens"] > 0


def test_stream_o1() -> None:
list(ChatOpenAI(model="o1-mini").stream("how are you"))


async def test_astream_o1() -> None:
async for _ in ChatOpenAI(model="o1-mini").astream("how are you"):
pass


class Foo(BaseModel):
response: str


def test_stream_response_format() -> None:
list(ChatOpenAI(model="gpt-4o-mini").stream("how are ya", response_format=Foo))


async def test_astream_response_format() -> None:
async for _ in ChatOpenAI(model="gpt-4o-mini").astream(
"how are ya", response_format=Foo
):
pass

0 comments on commit 89a474c

Please sign in to comment.