LangFlow輕松實(shí)驗(yàn)和原型化 LangChain流水線的AI項(xiàng)目
LangFlow——一款可輕松實(shí)驗(yàn)和原型化 LangChain流水線的AI項(xiàng)目。
前言
在人工智能興起的當(dāng)下,AI正在重塑著很多行業(yè)。今天介紹的是一款近期登上github熱門(mén)的一款可輕松實(shí)驗(yàn)和原型化 LangChain[1] 流水線的AI項(xiàng)目—LangFlow。
Flowise——通過(guò)拖放界面構(gòu)建定制的LLM流程
LangFlow
一種輕松實(shí)驗(yàn)和原型化 LangChain[2] 流水線的方式 ~
體驗(yàn)地址:https://huggingface.co/spaces/Logspace/LangFlow
安裝
本地安裝
您可以通過(guò)pip安裝LangFlow:
pip install langflow
然后運(yùn)行:
python -m langflow
或者
langflow
在Google Cloud Platform上部署Langflow
請(qǐng)按照我們的逐步指南,在Google Cloud Platform (GCP) 上使用Google Cloud Shell部署Langflow。該指南可在Langflow在Google Cloud Platform上的部署[3]文檔中找到。
或者,點(diǎn)擊下面的 "在Cloud Shell中打開(kāi)"按鈕,在Google Cloud Shell中啟動(dòng),并克隆Langflow存儲(chǔ)庫(kù),然后啟動(dòng)一個(gè)交互式教程 ,引導(dǎo)您完成設(shè)置所需資源和在GCP項(xiàng)目上部署Langflow的過(guò)程。鏈接[4]
在Jina AI Cloud[5]上部署Langflow
Langflow與langchain-serve集成,提供了一鍵部署到Jina AI Cloud的功能。
首先使用以下命令安裝langchain-serve:
pip install -U langchain-serve
然后運(yùn)行:
langflow --jcloud
Langflow服務(wù)器成功部署在Jina AI Cloud上
點(diǎn)擊鏈接打開(kāi)服務(wù)器(請(qǐng)?jiān)试S服務(wù)器啟動(dòng)大約1-2分鐘):https://.wolf.jina.ai/
了解更多關(guān)于管理服務(wù)器的信息:https://github.com/jina-ai/langchain-serve
完成的示例:
API使用方法
您可以直接在瀏覽器中使用Langflow,也可以使用Jina AI Cloud上的API端點(diǎn)與服務(wù)器進(jìn)行交互。
用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!"
}
創(chuàng)建流程
使用LangFlow創(chuàng)建流程非常簡(jiǎn)單。只需將側(cè)邊欄的組件拖放到畫(huà)布上,并將它們連接在一起以創(chuàng)建您的流水線。LangFlow提供了一系列的LangChain組件[6]可供選擇,包括LLMs、提示序列化器、代理和鏈。
通過(guò)編輯提示參數(shù)、鏈接鏈?zhǔn)胶痛怼⒏櫞淼乃伎歼^(guò)程以及導(dǎo)出流程,來(lái)進(jìn)行探索。
完成后,您可以將流程導(dǎo)出為JSON文件,以與LangChain一起使用。要這樣做,請(qǐng)單擊畫(huà)布右上角的“導(dǎo)出”按鈕,然后在Python中,您可以使用以下代碼加載流程:
from langflow import load_flow_from_json
flow = load_flow_from_json("path/to/flow.json")
# 現(xiàn)在您可以像使用任何鏈?zhǔn)揭粯邮褂盟?/p>
flow("Hey, have you heard of LangFlow?")
貢獻(xiàn)
我們歡迎來(lái)自各個(gè)層次的開(kāi)發(fā)者為我們?cè)贕itHub上的開(kāi)源項(xiàng)目做出貢獻(xiàn)。如果您想要貢獻(xiàn),請(qǐng)查閱我們的貢獻(xiàn)指南[7]并幫助我們使LangFlow更加易用。
加入我們的Discord[8]服務(wù)器,提問(wèn)、提建議和展示您的項(xiàng)目!
許可證
LangFlow使用MIT許可證發(fā)布。有關(guān)詳細(xì)信息,請(qǐng)參閱LICENSE文件。
參考資料
https://github.com/logspace-ai/langflow
本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點(diǎn)和立場(chǎng)。
轉(zhuǎn)載請(qǐng)注明,如有侵權(quán),聯(lián)系刪除。