当前位置: 首页 > news >正文

电脑制作网站的软件免费发布信息平台网

电脑制作网站的软件,免费发布信息平台网,wordpress需要的插件吗,郴州建设网站人工智能-LangGraphChatUIDeepSeek API搭建本地智能助手 0 环境说明1 LangGraph2 Agent Chat UI 0 环境说明 环境项环境说明操作系统Windows11 专业版硬件信息联想拯救者Y9000PcondaAnancondaPython版本3.12NodeJs18.20.0 # 使用conda创建python环境 conda create -n langgra…

人工智能-LangGraph+ChatUI+DeepSeek API搭建本地智能助手

    • 0 环境说明
    • 1 LangGraph
    • 2 Agent Chat UI

0 环境说明

环境项环境说明
操作系统Windows11 专业版
硬件信息联想拯救者Y9000P
condaAnanconda
Python版本3.12
NodeJs18.20.0
# 使用conda创建python环境
conda create -n langgraph python=3.12# 激活环境
conda activate langgraph# 下载依赖
pip install langchain-core langgraph -i https://pypi.tuna.tsinghua.edu.cn/simplepip install "langgraph-cli[inmem]" --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple

1 LangGraph

下载一个LangGraph Template项目

git clone https://github.com/langchain-ai/new-langgraph-project.git

修改配置文件

cd new-langgraph-project
cp .env.example .env

因为我使用的是DeepSeek API,所以需要配置 DEEPSEEK_API_KEY(上一步创建的DeepSeek API Key)

# To separate your traces from other application
LANGSMITH_PROJECT=new-agent# The following depend on your selected configuration## LLM choice:
# ANTHROPIC_API_KEY=....
# FIREWORKS_API_KEY=...
# OPENAI_API_KEY=...DEEPSEEK_API_KEY=your-deepseek-api-key

修改代码
src/agent/state.py

from __future__ import annotationsfrom typing_extensions import TypedDictfrom dataclasses import dataclass
from langchain_core.messages import AnyMessage
from langgraph.graph.message import add_messages
from typing import Annotated@dataclass
class State(TypedDict):messages: Annotated[list[AnyMessage], add_messages]

src/agent/configuration.py

"""Define the configurable parameters for the agent."""from __future__ import annotationsfrom dataclasses import dataclass, fields
from typing import Optionalfrom langchain_core.runnables import RunnableConfig@dataclass(kw_only=True)
class Configuration:model_name: str = "deepseek-chat"@classmethoddef from_runnable_config(cls, config: Optional[RunnableConfig] = None) -> Configuration:"""Create a Configuration instance from a RunnableConfig object."""configurable = (config.get("configurable") or {}) if config else {}_fields = {f.name for f in fields(cls) if f.init}return cls(**{k: v for k, v in configurable.items() if k in _fields})

src/agent/graph.py

from typing import Any, Dictfrom langchain_core.runnables import RunnableConfig
from langgraph.graph import StateGraph
from langchain_deepseek import ChatDeepSeek
from agent.configuration import Configuration
from agent.state import Statemodel = ChatDeepSeek(model="deepseek-chat",temperature=0,max_tokens=None,timeout=None,max_retries=2,
)def call_model(state, config):response = model.invoke(state["messages"])# We return a list, because this will get added to the existing listreturn {"messages": [response]}# Define a new graph
workflow = StateGraph(State, config_schema=Configuration)# Add the node to the graph
workflow.add_node("call_model", call_model)# Set the entrypoint as `call_model`
workflow.add_edge("__start__", "call_model")# Compile the workflow into an executable graph
graph = workflow.compile()
graph.name = "New Graph"  # This defines the custom name in LangSmith

接下来就可以启动项目了:

# 安装依赖
pip install -qU langchain-deepseek -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple# 启动项目
langgraph dev

启动的运行日志如下图:
在这里插入图片描述
启动完毕后,会自动弹出浏览器打开langsmith跟踪页面,如下图:
在这里插入图片描述

API文档地址(http://127.0.0.1:2024/docs)访问如下图:
在这里插入图片描述

2 Agent Chat UI

前端项目基于NodeJS。

  • NodeJs版本 ≥ 18.12 我用的版本是 18.20.0

下载agent-chat-ui项目

git clone https://github.com/langchain-ai/agent-chat-ui.gitcd agent-chat-ui# 先安装pnpm
npm install -g pnpm# 安装项目依赖
pnpm install# 启动项目
pnpm dev

安装项目依赖过程如下图:
在这里插入图片描述
在这里插入图片描述

项目启动日志如下:
在这里插入图片描述
启动后可以通过浏览器输入: http://localhost:5173访问,如下图:
在这里插入图片描述

点击 Continue 进入对话界面,如下图:
在这里插入图片描述
在这里插入图片描述

http://www.dtcms.com/a/545990.html

相关文章:

  • 西宁网站seo价格永康企业网站建设公司
  • 做视频特技的网站网站字体排版技巧
  • Rust 的零成本抽象:深入理解 Option 与 Result 的设计哲学
  • rust:什么是所有权
  • 模版网站好吗搜索引擎最新排名
  • 【js逆向案例二】瑞数6 深圳大学某医院
  • 网站编辑怎么样东莞网站建设网站推广价钱
  • TypeScript声明合并详解一
  • 网站后台登录域名注册公司需要注册资金吗
  • 蓝牙钥匙技术详解:从基础原理到未来趋势 大纲
  • 基于SVM与HOG特征的交通标志检测与识别
  • 如何做能上传视频网站网页设计教程
  • 做网盟的网站必须备案wordpress发表的文章点不开
  • nextjs路由[[...slug]]与[...slug]的区别
  • 全国药品招标、投标常用数据渠道及数据库<很全>
  • 附录:glibc-2.4 pthread 源码简要(了解)
  • 网站注册费用济南网站优化哪里做的好
  • 晋中住房与城乡建设厅网站湖南手机版建站系统哪家好
  • 记类成员变量 vs 方法中的变量
  • 企业网站模板建站建网站浩森宇特
  • 项目(四)
  • 徐州 商城网站设计wordpress变为中文
  • Rust Feature Flags:编译期配置的艺术与工程实践
  • 贵金属网站建设阿里云域名备案查询
  • Java后台面试 常见问题
  • 如何自己建站网站制作深圳公司网站推广
  • 【RAG架构】RAG架构概要
  • 6.5 大数据方法论与实践指南-安全合规-账号体系
  • Vue 系列之:Vue2 双端 Diff 算法原理
  • 网站建设与维护案列领优惠券的网站怎么做