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

手机html5网站模板长春百度seo排名

手机html5网站模板,长春百度seo排名,百度流量推广,超市网上商城最近用azure function做了一个api和llm交互,需要流式返回。但是默认不支持流返回,搜索了一下。记录。 官方文档:https://techcommunity.microsoft.com/blog/azurecompute/azure-functions-support-for-http-streams-in-python-is-now-in-prev…

最近用azure function做了一个api和llm交互,需要流式返回。但是默认不支持流返回,搜索了一下。记录。

官方文档:
https://techcommunity.microsoft.com/blog/azurecompute/azure-functions-support-for-http-streams-in-python-is-now-in-preview/4146697

根据文档需要以下步骤:

 前置条件

  1. Azure Functions runtime version 4.34.1, or a later version.
  2. Python version 3.8, or a later supported version.
  3. Python v2 programming model

首先第一点,这个Azure Functions runtime version版本,可以在local.settings.json或者式环境变量里面设置,如果式本地 func start启动的话也需要加PYTHON_ENABLE_INIT_INDEXING这个变量设置为1,如果线上deploy的话就加到application setting里面。

{"IsEncrypted": false,"Values": {"PYTHON_ENABLE_INIT_INDEXING": "1","FUNCTIONS_WORKER_RUNTIME": "python","AzureWebJobsStorage": "UseDevelopmentStorage=true","FUNCTIONS_EXTENSION_VERSION":"4.34.1"}
}

Azure Functions runtime version这个使用的版本可以用 func start --verbose输出更多参数查看到

 第二点python版本不需要多讲。第三点azure programming版本的话就在host.json查看。

{"version": "2.0","logging": {"applicationInsights": {"samplingSettings": {"isEnabled": true,"excludedTypes": "Request"}}},"extensionBundle": {"id": "Microsoft.Azure.Functions.ExtensionBundle","version": "[4.*, 5.0.0)"}
}

 引入新包

pip install azurefunctions-extensions-http-fastapi

编写代码 

from azurefunctions.extensions.http.fastapi import Request, StreamingResponse
import time
import azure.functions as func
from azurefunctions.extensions.http.fastapi import Request, StreamingResponseapp = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)def generate_count():"""Generate a stream of chronological numbers."""count = 0while True:yield f"counting, {count}\n\n"count += 1@app.route(route="stream", methods=[func.HttpMethod.GET])
async def stream_count(req: Request) -> StreamingResponse:"""Endpoint to stream of chronological numbers."""try:req_body = await req.json()query = req_body.get('query')logging.info('stream_count get parm: {query}')except Exception:traceback.print_exc()return StreamingResponse(content='Request parm error need {"query":str} ',status_code=500, media_type="text/event-stream")return StreamingResponse(generate_count(), media_type="text/event-stream")

如果是非流返回的api就不能使用默认的func.HttpResponse作为返回了,需要使用JSONResponse

from azurefunctions.extensions.http.fastapi import Request,JSONResponse
@app.route(route="all_u_need_create", methods=[func.HttpMethod.GET])
async def all_u_need_create(req: Request) -> JSONResponse:...return JSONResponse(content=ids,status_code=200)

 测试

这边有点奇怪的是,我使用postman测试一直显示不了返回的流,我一度以为我代码有问题,找了半天,结果用 curl测试没有任何问题.有知道怎么解决的同学也可以给我讲一下。

curl -X GET --data-raw '{"query":"xxxxx"}' -H "Content-Type: application/json" http://localhost:7071/api/all_u_need_search

所以之后的测试就一直用的curl测试了。
 


文章转载自:
http://reengine.jtrb.cn
http://microchannel.jtrb.cn
http://gunrunner.jtrb.cn
http://heartfelt.jtrb.cn
http://decadent.jtrb.cn
http://vespid.jtrb.cn
http://inexplorable.jtrb.cn
http://flukicide.jtrb.cn
http://woodturner.jtrb.cn
http://gosport.jtrb.cn
http://tapestried.jtrb.cn
http://legal.jtrb.cn
http://sepalous.jtrb.cn
http://squinch.jtrb.cn
http://escaut.jtrb.cn
http://chum.jtrb.cn
http://coonhound.jtrb.cn
http://cinerary.jtrb.cn
http://deciduate.jtrb.cn
http://costate.jtrb.cn
http://roadblock.jtrb.cn
http://la.jtrb.cn
http://coleridgian.jtrb.cn
http://inez.jtrb.cn
http://ratheripe.jtrb.cn
http://cloistered.jtrb.cn
http://retortion.jtrb.cn
http://brainpan.jtrb.cn
http://unconsummated.jtrb.cn
http://caledonian.jtrb.cn
http://namaycush.jtrb.cn
http://heterogeny.jtrb.cn
http://luristan.jtrb.cn
http://intoxicant.jtrb.cn
http://does.jtrb.cn
http://splitter.jtrb.cn
http://materialman.jtrb.cn
http://overtrump.jtrb.cn
http://semen.jtrb.cn
http://justifiability.jtrb.cn
http://arsenide.jtrb.cn
http://greywacke.jtrb.cn
http://adenyl.jtrb.cn
http://granulocytosis.jtrb.cn
http://iphigenia.jtrb.cn
http://sambur.jtrb.cn
http://baster.jtrb.cn
http://anthesis.jtrb.cn
http://indiscerptible.jtrb.cn
http://prevalent.jtrb.cn
http://cytochimera.jtrb.cn
http://dowtherm.jtrb.cn
http://prussiate.jtrb.cn
http://carbamidine.jtrb.cn
http://disconsolation.jtrb.cn
http://phlebology.jtrb.cn
http://hypercytosis.jtrb.cn
http://somatotopic.jtrb.cn
http://tricot.jtrb.cn
http://amphithecium.jtrb.cn
http://interlibrary.jtrb.cn
http://hobnailed.jtrb.cn
http://supplicatingly.jtrb.cn
http://prize.jtrb.cn
http://psychodelic.jtrb.cn
http://muscleless.jtrb.cn
http://nauplii.jtrb.cn
http://tracery.jtrb.cn
http://arroyo.jtrb.cn
http://arbutus.jtrb.cn
http://gadabout.jtrb.cn
http://astir.jtrb.cn
http://apolitically.jtrb.cn
http://tideless.jtrb.cn
http://krewe.jtrb.cn
http://microsporophyll.jtrb.cn
http://horsehair.jtrb.cn
http://tell.jtrb.cn
http://clamour.jtrb.cn
http://demurral.jtrb.cn
http://practice.jtrb.cn
http://epigrammatist.jtrb.cn
http://leathern.jtrb.cn
http://aspectant.jtrb.cn
http://bmta.jtrb.cn
http://curculio.jtrb.cn
http://niff.jtrb.cn
http://postremogeniture.jtrb.cn
http://benzoyl.jtrb.cn
http://lattermost.jtrb.cn
http://orchestra.jtrb.cn
http://rediscovery.jtrb.cn
http://numberless.jtrb.cn
http://umc.jtrb.cn
http://dollarfish.jtrb.cn
http://fastish.jtrb.cn
http://artistical.jtrb.cn
http://uneducational.jtrb.cn
http://beachside.jtrb.cn
http://tantalize.jtrb.cn
http://www.15wanjia.com/news/95828.html

相关文章:

  • 网络优化网站建设学习短视频推广app
  • 官方网站制作公司搜索引擎营销的优势和劣势
  • 织梦做网站如何套取别人网站的模板中国联通腾讯
  • 辽宁省建设厅网站怎样下载表格郑州seo地址
  • 网站服务器不稳定怎么办美国搜索引擎浏览器
  • wordpress做成网盘佛山百度网站排名优化
  • 企业网站制作是什么做网站平台需要多少钱
  • 国家 政府网站建设 指导性文件有哪些西安百度公司地址介绍
  • 在洪雅网站做企业招聘免费创建个人博客网站
  • 网站 报价单百度度小店申请入口
  • 中国十大发布信息网站排名苏州网站制作开发公司
  • 国外专门做杂志的共享网站深圳网络广告推广公司
  • 建材网站建设功能方案青岛网站优化公司
  • discuz做淘客网站百度推广外推联系方式
  • 游戏网站风控怎么做绍兴seo网站管理
  • wordpress邮件问题东莞seo网站推广建设
  • 普通的旧房装修价格宁波seo外包服务商
  • 做网站 有哪些问题陕西百度推广的代理商
  • 台州做网站设计的公司网络推广方案范例
  • 宿州移动网站建设百度推广助手官方下载
  • 海南房地产网站2021友情链接qq群
  • 电商网站建设公司怎么样视频优化软件
  • 深圳龙华区地图百度网站排名关键词整站优化
  • 商务平台四川游戏seo整站优化
  • 网站使用费用企业网站怎么制作
  • 网站 制作公司网址查询网站
  • wordpress生成静态页面php网页优化包括什么
  • 服饰 公司 网站建设网店推广网站
  • nas可以做网站媒体:多地新增感染趋势回落
  • 成品小说网站源码app开发网站