-
Notifications
You must be signed in to change notification settings - Fork 16.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
2,492 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
# langchain-community | ||
# 🦜️🧑🤝🧑 LangChain Community | ||
|
||
[![Downloads](https://static.pepy.tech/badge/langchain_community/month)](https://pepy.tech/project/langchain_community) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
|
||
## Quick Install | ||
|
||
```bash | ||
pip install langchain-community | ||
``` | ||
|
||
## What is it? | ||
|
||
LangChain Community contains third-party integrations that implement the base interfaces defined in LangChain Core, making them ready-to-use in any LangChain application. | ||
|
||
For full documentation see the [API reference](https://api.python.langchain.com/en/stable/community_api_reference.html). | ||
|
||
![LangChain Stack](../../docs/static/img/langchain_stack.png) | ||
|
||
## 📕 Releases & Versioning | ||
|
||
`langchain-community` is currently on version `0.0.x` | ||
|
||
All changes will be accompanied by a patch version increase. | ||
|
||
## 💁 Contributing | ||
|
||
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation. | ||
|
||
For detailed information on how to contribute, see [here](../../.github/CONTRIBUTING.md). |
40 changes: 37 additions & 3 deletions
40
libs/community/langchain_community/tools/convert_to_openai.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,38 @@ | ||
from langchain_community.tools.render import format_tool_to_openai_function | ||
from langchain_core.tools import BaseTool | ||
|
||
# For backwards compatibility | ||
__all__ = ["format_tool_to_openai_function"] | ||
from langchain_community.utils.openai_functions import ( | ||
FunctionDescription, | ||
ToolDescription, | ||
convert_pydantic_to_openai_function, | ||
) | ||
|
||
|
||
def format_tool_to_openai_function(tool: BaseTool) -> FunctionDescription: | ||
"""Format tool into the OpenAI function API.""" | ||
if tool.args_schema: | ||
return convert_pydantic_to_openai_function( | ||
tool.args_schema, name=tool.name, description=tool.description | ||
) | ||
else: | ||
return { | ||
"name": tool.name, | ||
"description": tool.description, | ||
"parameters": { | ||
# This is a hack to get around the fact that some tools | ||
# do not expose an args_schema, and expect an argument | ||
# which is a string. | ||
# And Open AI does not support an array type for the | ||
# parameters. | ||
"properties": { | ||
"__arg1": {"title": "__arg1", "type": "string"}, | ||
}, | ||
"required": ["__arg1"], | ||
"type": "object", | ||
}, | ||
} | ||
|
||
|
||
def format_tool_to_openai_tool(tool: BaseTool) -> ToolDescription: | ||
"""Format tool into the OpenAI function API.""" | ||
function = format_tool_to_openai_function(tool) | ||
return {"type": "function", "function": function} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,58 @@ | ||
# langchain-core | ||
# 🦜🍎️ LangChain Core | ||
|
||
[![Downloads](https://static.pepy.tech/badge/langchain_core/month)](https://pepy.tech/project/langchain_core) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
|
||
## Quick Install | ||
|
||
```bash | ||
pip install langchain-core | ||
``` | ||
|
||
## What is it? | ||
|
||
LangChain Core contains the base abstractions that power the rest of the LangChain ecosystem. | ||
These abstractions are designed to be as modular and simple as possible. | ||
Examples of these abstractions include those for language models, document loaders, embedding models, vectorstores, retrievers, and more. | ||
The benefit of having these abstractions is that any provider can implement the required interface and then easily be used in the rest of the LangChain ecosystem. | ||
|
||
For full documentation see the [API reference](https://api.python.langchain.com/en/stable/core_api_reference.html). | ||
|
||
## What is LangChain Expression Language? | ||
|
||
LangChain Core also contains LangChain Expression Language, or LCEL, a runtime that allows users to compose arbitrary sequences together and get several benefits that are important when building LLM applications. | ||
We call these sequences “runnables”. | ||
|
||
All runnables expose the same interface with single-invocation, batch, streaming and async methods. | ||
This design is useful because it is not enough to have a single sync interface when building an LLM application. | ||
Batch is needed for efficient processing of many inputs. | ||
Streaming (and streaming of intermediate steps) is needed to show the user that progress is being made. | ||
Async interfaces are nice when moving into production. | ||
Rather than having to write multiple implementations for all of those, LCEL allows you to write a runnable once and invoke it in many different ways. | ||
|
||
For more check out the [LCEL docs](https://python.langchain.com/docs/expression_language/). | ||
|
||
![LangChain Stack](../../docs/static/img/langchain_stack.png) | ||
|
||
## 📕 Releases & Versioning | ||
|
||
`langchain-core` is currently on version `0.1.x`. | ||
|
||
As `langchain-core` contains the base abstractions and runtime for the whole LangChain ecosystem, we will communicate any breaking changes with advance notice and version bumps. The exception for this is anything in `langchain_core.beta`. The reason for `langchain_core.beta` is that given the rate of change of the field, being able to move quickly is still a priority, and this module is our attempt to do so. | ||
|
||
Minor version increases will occur for: | ||
|
||
- Breaking changes for any public interfaces NOT in `langchain_core.beta` | ||
|
||
Patch version increases will occur for: | ||
|
||
- Bug fixes | ||
- New features | ||
- Any changes to private interfaces | ||
- Any changes to `langchain_core.beta` | ||
|
||
## 💁 Contributing | ||
|
||
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation. | ||
|
||
For detailed information on how to contribute, see [here](../../.github/CONTRIBUTING.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.