日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

在线问诊 Python、FastAPI、Neo4j — 提供咨询接口服务

發布時間:2023/10/11 综合教程 99 老码农
生活随笔 收集整理的這篇文章主要介紹了 在线问诊 Python、FastAPI、Neo4j — 提供咨询接口服务 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

采用 Fast API 搭建服務接口: https://www.cnblogs.com/vipsoft/p/17684079.html

Fast API 文檔:https://fastapi.tiangolo.com/zh/

構建服務層

qa_service.py

from service.question_classifier import *
from service.question_parser import *
from service.answer_search import * class QAService:
def __init__(self):
self.classifier = QuestionClassifier()
self.parser = QuestionPaser()
self.searcher = AnswerSearcher() def chat_main(self, sent):
answer = '您的問題,我還沒有學習到。祝您身體健康!'
res_classify = self.classifier.classify(sent)
if not res_classify:
return answer
res_sql = self.parser.parser_main(res_classify)
final_answers = self.searcher.search_main(res_sql)
if not final_answers:
return answer
else:
return '\n'.join(final_answers)

同時將 answer_search.pyquestion_classifier.pyquestion_parser.py 從test 目錄中,移到 service 包中

QuestionClassifier 中的 路徑獲取方式進行修改 ../dic/xxxx 替換為 dic/xxx

接口路由層

FastAPI 請求體:https://fastapi.tiangolo.com/zh/tutorial/body/

創建路由接口文件

qa_router.py

#!/usr/bin/python3

import logging
from fastapi import APIRouter, status
from fastapi.responses import JSONResponse
from pydantic import BaseModel
from service.qa_service import QAService
import json router = APIRouter()
qa = QAService() #實類化 QAService 服務 class Item(BaseModel):
name: str = None
question: str @router.post("/consult")
async def get_search(param: Item):
answer = qa.chat_main(param.question)
return JSONResponse(content=answer, status_code=status.HTTP_200_OK)

PostMan 調用

URL: http://127.0.0.1:8000/api/qa/consult

{"question": "請問最近看東西有時候清楚有時候不清楚是怎么回事"}

返回值:

"可能是:干眼"



源代:https://gitee.com/VipSoft/VipQA

參考:https://github.com/liuhuanyong/QASystemOnMedicalKG

總結

以上是生活随笔為你收集整理的在线问诊 Python、FastAPI、Neo4j — 提供咨询接口服务的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。