# langchain_example **Repository Path**: dunsk/langchain_example ## Basic Information - **Project Name**: langchain_example - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-06-15 - **Last Updated**: 2025-06-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # langchain的常用案例代码 ## 概述   本项目主要运行langchain的官网案例代码,并做了适当的改造。比如将基于内存的文档库改为本地存储的。另外部分案例将使用外部的LLM接口,改为了调用本地的ollama接口,但有些案例本地模型返回效果不佳时,才改为调用外部的LLM的API接口。 ## 使用方法 本示例使用的langchain版本为0.3.25,langchain2.x跟langchain3.x使用上还是有一些变化的,建议不要混合使用它们。 由于 python3.9和3.10的异步任务,不支持context参数,可能会导致langchain一些未能预知的错误,建议python版本使用3.11以上。 官方解释如下: > In Python 3.9 and 3.10, asyncio's tasks did not accept a context parameter. > Due to this limitation, LangChain cannot automatically propagate the RunnableConfig down the call chain in certain scenarios. 1. 下载代码 git clone https://gitee.com/dunsk/langchain_example.git 2. 环境安装 ```bash pip install uv uv sync ``` 3. 运行代码 ```bash # 需要注意的是,本示例中的大模型有些是调用的openAI接口, # 有些调用的是ollama本地部署的llama3.2模型 # 如果使用的是openAi接口,需要注册openAI的账号,并配置OPANAI_API_KEY的环境变量, # 另外,使用openai时,需要使用科学上网的方法,安装一款vpn外网工具。 # 如果是本地的ollama模型,只需要很把模型运行在本地的ollama中就可以了, # 并不需要别的特殊配置 python prompt_example.py ```