最近阿里開源了通用大模型qwen-72b,正在為怎么本地化部署發(fā)愁,轉(zhuǎn)眼看到提供了qwen-max相關(guān)接口的免費(fèi)試用(據(jù)說就是基于qwen-72b大模型),這就來體驗(yàn)一番。
1.前期準(zhǔn)備
開通阿里云靈積平臺(tái),并創(chuàng)建api-key
2.環(huán)境搭建
python:3.10+;
pydantic 2.0以上,老版本pydantic會(huì)報(bào)一個(gè)tool_schema.model_dump_json的函數(shù)錯(cuò)誤,可以通過相關(guān)命令升級(jí):
css 復(fù)制代碼
pip install --upgrade pydantic
pip install --upgrade fastapi
3.項(xiàng)目部署
拉取項(xiàng)目代碼,并安裝相關(guān)依賴
bash 復(fù)制代碼
git clone https://github.com/modelscope/modelscope-agent.git
cd modelscope-agent
pip install -r requirements.txt
將\apps\agentfabric目錄下面的所有文件復(fù)制到項(xiàng)目根目錄,并安裝相關(guān)依賴
復(fù)制代碼
pip install -r requirements.txt
發(fā)現(xiàn)有兩個(gè)文件app.py和appBot.py,先啟動(dòng)app.py(實(shí)際差不多,appBot.py沒有左邊的配置欄),打開創(chuàng)建的網(wǎng)址可以發(fā)現(xiàn)提示api_key錯(cuò)誤,我們將阿里云靈積平臺(tái)創(chuàng)建的api-key填寫到環(huán)境變量中并重啟服務(wù)。
這時(shí)候可以正常使用了,點(diǎn)擊config可以修改配置信息(根據(jù)自己需求填寫)
實(shí)際上在/config/build_config.json文件里直接填寫效果更好,刪除緩存也不怕丟失
json 復(fù)制代碼
{
"name": "學(xué)業(yè)規(guī)劃助手",
"avatar": "custom_bot_avatar.png",
"description": "一個(gè)專為學(xué)生設(shè)計(jì)的學(xué)業(yè)規(guī)劃助手,通過個(gè)性化的測試和分析幫助你找到最適合的專業(yè)和學(xué)校。",
"instruction": "1. 理解并回應(yīng)用戶的指令;2. 提供專業(yè)的學(xué)術(shù)知識(shí)和技能的簡易測試;3. 根據(jù)用戶的需求和測試結(jié)果生成個(gè)性化適配報(bào)告;4. 基于用戶需求和偏好推薦適合的專業(yè)和學(xué)校;5. 考慮用戶對(duì)地區(qū)和國家的偏好進(jìn)行更精準(zhǔn)的推薦;6.當(dāng)用戶需要完整智能評(píng)測時(shí)提供完整智能評(píng)測的網(wǎng)址;7.給出用戶日常學(xué)習(xí)和生活的建議輔導(dǎo)",
"language": "zh",
"prompt_recommend": [
"你可以幫我生成一個(gè)關(guān)于職業(yè)能力的簡易測試嗎?",
"你會(huì)推薦我學(xué)習(xí)哪個(gè)專業(yè)的課程?",
"你能分析一下我對(duì)專業(yè)的適配度嗎?",
"能否推薦一些大學(xué)給我?",
"完整智能評(píng)估"
],
"knowledge": [],
"tools": {
"get_test_url":{
"name": "完整智能評(píng)估",
"is_active": true,
"use": true
}
},
"model": "qwen-max"
}
保存重啟并體驗(yàn)一下
4.自定義工具類加載
在tool文件夾內(nèi)創(chuàng)建get_test_url.py
python 復(fù)制代碼
from .tool import Tool
class GetTestUrl(Tool):
name = "get_test_url"
description = "該工具用戶返回智能評(píng)估的網(wǎng)址。"
description += """
下面是一些對(duì)話場景:
場景1:
<用戶>: 智能評(píng)估
<助手>: 好的,正在查詢中
場景2:
<用戶>:查看智能評(píng)估的網(wǎng)站
<助手>: 好的,正在查詢中
"""
parameters = [
{
'name': 'test_url',
'description': '查詢智能評(píng)估的網(wǎng)址',
'required': False
}
]
def __call__(self, remote=False, *args, **kwargs):
if self.is_remote_tool or remote:
return self._remote_call(*args, **kwargs)
else:
return self._local_call(*args, **kwargs)
def _remote_call(self, *args, **kwargs):
pass
def _local_call(self, *args, **kwargs):
test_url = kwargs.get("test_url", "")
result = {
"test_url": 'http://www.baidu.com',
}
return {"result": result}
修改對(duì)應(yīng)的config文件/config/tool_config.json
json 復(fù)制代碼
"modelscope_text-translation-en2zh": {
"name": "英譯中",
"url": "https://api-inference.modelscope.cn/api-inference/v1/models/damo/nlp_csanmt_translation_en2zh",
"use": false,
"is_active": false,
"is_remote_tool": true
},
"modelscope_text-translation-zh2en": {
"name": "中譯英",
"url": "https://api-inference.modelscope.cn/api-inference/v1/models/damo/nlp_csanmt_translation_zh2en",
"use": false,
"is_active": false,
"is_remote_tool": true
},
"get_test_url":{
"name": "完整智能評(píng)估",
"is_active": true,
"use": true
}
修改/config/build_config.json(上文已經(jīng)添加過了,不在贅述)。
修改/tools/init.py
javascript 復(fù)制代碼
from .amap_weather import AMAPWeather
from .code_interperter import CodeInterpreter
from .code_interpreter_jupyter import CodeInterpreterJupyter
from .hf_tool import HFTool
from .image_chat_tool import ImageChatTool
from .pipeline_tool import ModelscopePipelineTool
from .plugin_tool import LangchainTool
from .qwen_vl import QWenVL
from .style_repaint import StyleRepaint
from .text_address_tool import TextAddressTool
from .text_ie_tool import TextInfoExtractTool
from .text_ner_tool import TextNerTool
from .text_to_image_tool import TextToImageTool
from .text_to_speech_tool import TexttoSpeechTool
from .text_to_video_tool import TextToVideoTool
from .tool import Tool
from .translation_en2zh_tool import TranslationEn2ZhTool
from .translation_zh2en_tool import TranslationZh2EnTool
from .web_browser import WebBrowser
from .web_search import WebSearch
from .wordart_tool import WordArtTexture
from .get_test_url import GetTestUrl
TOOL_INFO_LIST = {
'modelscope_text-translation-zh2en': 'TranslationZh2EnTool',
'modelscope_text-translation-en2zh': 'TranslationEn2ZhTool',
'modelscope_text-ie': 'TextInfoExtractTool',
'modelscope_text-ner': 'TextNerTool',
'modelscope_text-address': 'TextAddressTool',
'image_gen': 'TextToImageTool',
'modelscope_video-generation': 'TextToVideoTool',
'modelscope_image-chat': 'ImageChatTool',
'modelscope_speech-generation': 'TexttoSpeechTool',
'amap_weather': 'AMAPWeather',
'code_interpreter': 'CodeInterpreterJupyter',
'wordart_texture_generation': 'WordArtTexture',
'web_search': 'WebSearch',
'web_browser': 'WebBrowser',
'qwen_vl': 'QWenVL',
'style_repaint': 'StyleRepaint',
'get_test_url': 'GetTestUrl',
}
重啟服務(wù)看下效果
完工~
作者:suzumiyahr
鏈接:https://juejin.cn/spost/7317252368546054184
來源:稀土掘金
著作權(quán)歸作者所有。商業(yè)轉(zhuǎn)載請(qǐng)聯(lián)系作者獲得授權(quán),非商業(yè)轉(zhuǎn)載請(qǐng)注明出處。文章來源:http://www.zghlxwxcb.cn/news/detail-824026.html
不需要本地部署大模型,modelscope-agent加qwen-max免費(fèi)搭建自己的定制機(jī)器人文章來源地址http://www.zghlxwxcb.cn/news/detail-824026.html
到了這里,關(guān)于不需要本地部署大模型,modelscope-agent加qwen-max免費(fèi)搭建自己的定制機(jī)器人的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!