微信扫码
添加专属顾问
我要投稿
LangChain是一个热门的LLM开源项目,它可以更容易地将大语言模型的功能与应用程序的逻辑结合起来。然而,如果没有用户友好的界面,设计和测试LangChain流可能是具有挑战性的。
而LangFlow是一个针对LangChain的GUI,它采用了反应流设计,提供了一种轻松的方式,通过拖放组件和聊天框来实验和原型化流程,将llm嵌入到您的应用程序中,无需代码。
LangFlow允许您探索不同的大语言模型、prompt参数、链配置和代理行为,并跟踪代理的思维过程。您还可以将流导出为JSON文件,以便与LangChain一起使用。
Langflow构建的对话应用的一些例子
• 文档:https://docs.langflow.org
• Discord:https://discord.com/invite/EqksyE2EX9
Langflow 提供了一系列LangChain 组件可供选择,包括 LLM、提示序列化器、代理和链。
创建流程的地址
https://docs.langflow.org/getting-started/creating-flows
下面是视频教程以及地址:
https://www.youtube.com/watch?v=sC9SV06gsDM
您可以直接在浏览器中使用Langflow,也可以使用Jina AI Cloud上的API端点与服务器进行交互。
用Python API的使用方式:
import requests
BASE_API_URL = "https://langflow-e3dd8820ec.wolf.jina.ai/api/v1/predict"
FLOW_ID = "864c4f98-2e59-468b-8e13-79cd8da07468"
# You can tweak the flow by adding a tweaks dictionary
# e.g {"OpenAI-XXXXX": {"model_name": "gpt-4"}}
TWEAKS = {
"ChatOpenAI-g4jEr": {},
"ConversationChain-UidfJ": {}
}
def run_flow(message: str, flow_id: str, tweaks: dict = None) -> dict:
"""
Run a flow with a given message and optional tweaks.
:param message: The message to send to the flow
:param flow_id: The ID of the flow to run
:param tweaks: Optional tweaks to customize the flow
:return: The JSON response from the flow
"""
api_url = f"{BASE_API_URL}/{flow_id}"
payload = {"message": message}
if tweaks:
payload["tweaks"] = tweaks
response = requests.post(api_url, json=payload)
return response.json()
# Setup any tweaks you want to apply to the flow
print(run_flow("Your message", flow_id=FLOW_ID, tweaks=TWEAKS))
返回结果示例:
{
"result": "Great choice! Bangalore in the 1920s was a vibrant city with a rich cultural and political scene. Here are some suggestions for things to see and do:\n\n1. Visit the Bangalore Palace - built in 1887, this stunning palace is a perfect example of Tudor-style architecture. It was home to the Maharaja of Mysore and is now open to the public.\n\n2. Attend a performance at the Ravindra Kalakshetra - this cultural center was built in the 1920s and is still a popular venue for music and dance performances.\n\n3. Explore the neighborhoods of Basavanagudi and Malleswaram - both of these areas have retained much of their old-world charm and are great places to walk around and soak up the atmosphere.\n\n4. Check out the Bangalore Club - founded in 1868, this exclusive social club was a favorite haunt of the British expat community in the 1920s.\n\n5. Attend a meeting of the Indian National Congress - founded in 1885, the INC was a major force in the Indian independence movement and held many meetings and rallies in Bangalore in the 1920s.\n\nHope you enjoy your trip to 1920s Bangalore!"
}
下面提供官方的文档介绍、相关资源、部署教程等,进一步支撑你的行动,以提升本文的帮助力。
您可以使用 pip 安装 Langflow:
# 确保您的系统上安装了 Python 3.10。
# 安装预发布版本
python -m pip install langflow --pre --force-reinstall
# 或者稳定版本
python -m pip install langflow -U
然后,运行 Langflow:
python -m langflow run
您还可以在 HuggingFace Spaces 中预览 Langflow。使用此链接克隆空间,在几分钟内创建您自己的 Langflow 工作区。
使用 Langflow 创建流程很容易。只需从侧边栏拖动组件到画布上并连接它们,即可开始构建您的应用程序。
通过编辑提示参数、将组件分组到单个高级组件中以及构建您自己的自定义组件来进行探索。
完成后,您可以将流程导出为 JSON 文件。
使用以下代码加载流程:
from langflow.load import run_flow_from_json
results = run_flow_from_json("path/to/flow.json", input_value="Hello, World!")
Langflow 提供了一个命令行界面(CLI),用于简化管理和配置。
您可以使用以下命令运行 Langflow:
langflow run [OPTIONS]
您可以使用环境变量配置许多 CLI 选项。这些可以在您的操作系统中导出,或者添加到 .env
文件中,并使用 --env-file
选项加载。
项目中包含了一个名为 .env.example
的示例 .env
文件。将此文件复制到名为 .env
的新文件中,并将示例值替换为您的实际设置。如果您同时在操作系统和 .env
文件中设置值,则 .env
设置将优先。
参考链接:
https://github.com/langflow-ai/langflow
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费场景POC验证,效果验证后签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2025-03-10
【一文看懂】大白话解释大模型的技术原理,为什么它那么聪明?
2025-03-10
【一文看懂】7B、175B,这些大模型参数是什么意思?它们是怎么算出来的?参数越多=模型越强?
2025-03-10
大模型领域常用名词解释(近100个)
2025-03-10
大模型应用联网搜索:重塑智能时代的交互与决策
2025-03-10
MCP:为 AI Agent 打造开放与互操作性的“超级接口”
2025-03-10
QwQ-32B,支持Function Call的推理模型,深度思考Agent的时代来了!
2025-03-10
国产自强!实在Agent+DeepSeek+华为昇腾一体机重磅发布!
2025-03-10
1次搭建完胜1亿次编码,MCP硅谷疯传!Anthropic协议解锁智能体「万能手」
2024-08-13
2024-06-13
2024-09-23
2024-08-21
2024-05-28
2024-07-31
2024-08-04
2024-04-26
2024-07-09
2024-09-17
2025-03-10
2025-03-10
2025-03-10
2025-03-10
2025-03-08
2025-03-08
2025-03-07
2025-03-07