2023-07-08 11:37:54 +03:00
# LangChain gpt4free
LangChain gpt4free is an open-source project that assists in building applications using LLM (Large Language Models) and provides free access to GPT4/3.5.
## Installation
To install langchain_g4f, run the following command:
```shell
pip install git+https://github.com/MIDORIBIN/langchain-gpt4free.git
```
2023-10-24 19:26:43 +03:00
or
```shell
2023-10-24 19:49:44 +03:00
pip install langchain-g4f
2023-10-24 19:26:43 +03:00
```
2023-07-08 11:37:54 +03:00
This command will install langchain_g4f.
## Usage
Here is an example of how to use langchain_g4f
```python
2023-08-13 06:44:15 +03:00
from g4f import Provider, models
2023-07-08 11:37:54 +03:00
from langchain.llms.base import LLM
from langchain_g4f import G4FLLM
def main():
llm: LLM = G4FLLM(
2023-08-13 06:44:15 +03:00
model=models.gpt_35_turbo,
2023-07-08 11:37:54 +03:00
provider=Provider.Aichat,
)
2023-08-13 06:44:15 +03:00
res = llm("hello")
2023-07-08 11:37:54 +03:00
print(res) # Hello! How can I assist you today?
2023-08-13 06:44:15 +03:00
if __name__ == "__main__":
2023-07-08 11:37:54 +03:00
main()
```
The above sample code demonstrates the basic usage of langchain_g4f. Choose the appropriate model and provider, initialize the LLM, and then pass input text to the LLM object to obtain the result.
2023-07-23 04:20:03 +03:00
For other samples, please refer to the following [sample directory ](./sample/ ).
2023-07-08 11:37:54 +03:00
## Support and Bug Reports
For support and bug reports, please use the GitHub Issues page.
Access the GitHub Issues page and create a new issue. Select the appropriate label and provide detailed information.
## Contributing
To contribute to langchain_g4f, follow these steps to submit a pull request:
1. Fork the project repository.
2. Clone the forked repository to your local machine.
3. Make the necessary changes.
4. Commit the changes and push to your forked repository.
5. Create a pull request towards the original project repository.