ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

10.3 FAQ智能问答系统-本地部署和云部署

10.3 FAQ智能问答系统-本地部署和云部署 邓立国Agent开发入门必读书《AI Agent智能体开发实践》1~12章试读_《ai agent 智能体开发实践》在线阅读-CSDN博客1本地部署使用FastAPI将智能体包装为API服务from fastapi import FastAPIfrom pydantic import BaseModelapp FastAPI(titleLangChain问答API)class QuestionRequest(BaseModel):question: strapp.post(/ask)def ask_question(request: QuestionRequest):response get_answer(request.question)return response#启动命令# uvicorn main:app --reload2云部署则使用Docker进行部署Dockerfile示例如下#使用Python基础镜像FROM python:3.9-slim#设置工作目录WORKDIR /app#安装依赖COPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txt#复制应用代码COPY . .#暴露端口EXPOSE 8000#启动应用CMD [uvicorn, main:app, --host, 0.0.0.0, --port, 8000]
返回列表