Skip to content

Commit

Permalink
fix format|lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangzhijie committed Nov 20, 2024
1 parent 1563a8f commit 387ccce
Show file tree
Hide file tree
Showing 14 changed files with 1,272 additions and 1,296 deletions.
58 changes: 28 additions & 30 deletions docs/docs/integrations/chat/lindorm_chat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,34 @@
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2024-07-24T02:05:51.857436Z",
"start_time": "2024-07-24T02:05:51.762532Z"
}
},
"cell_type": "code",
"outputs": [],
"source": [
"from lindormai.model_manager import ModelManager\n",
"import environs\n",
"from lindormai.model_manager import ModelManager\n",
"\n",
"env = environs.Env()\n",
"env.read_env(\".env\")\n",
"\n",
"\n",
"class Config:\n",
"\n",
" AI_CHAT_LLM_ENDPOINT = env.str(\"AI_CHAT_LLM_ENDPOINT\", '<CHAT_ENDPOINT>')\n",
" AI_CHAT_USERNAME = env.str(\"AI_CHAT_USERNAME\", 'root')\n",
" AI_CHAT_PWD = env.str(\"AI_CHAT_PWD\", '<PASSWORD>')\n",
" AI_CHAT_LLM_ENDPOINT = env.str(\"AI_CHAT_LLM_ENDPOINT\", \"<CHAT_ENDPOINT>\")\n",
" AI_CHAT_USERNAME = env.str(\"AI_CHAT_USERNAME\", \"root\")\n",
" AI_CHAT_PWD = env.str(\"AI_CHAT_PWD\", \"<PASSWORD>\")\n",
" AI_DEFAULT_CHAT_MODEL = \"qa_model_qwen_72b_chat\"\n",
"\n",
"\n",
"\n",
"LDAI_CHAT_LLM_ENDPOINT=Config.AI_CHAT_LLM_ENDPOINT\n",
"LDAI_CHAT_USERNAME=Config.AI_CHAT_USERNAME\n",
"LDAI_CHAT_PWD=Config.AI_CHAT_PWD"
],
"execution_count": 1,
"outputs": []
"LDAI_CHAT_LLM_ENDPOINT = Config.AI_CHAT_LLM_ENDPOINT\n",
"LDAI_CHAT_USERNAME = Config.AI_CHAT_USERNAME\n",
"LDAI_CHAT_PWD = Config.AI_CHAT_PWD"
]
},
{
"cell_type": "markdown",
Expand All @@ -48,27 +46,28 @@
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2024-07-24T02:05:54.600274Z",
"start_time": "2024-07-24T02:05:54.596897Z"
}
},
"outputs": [],
"source": [
"def check_model_exist(model_mgr, model_name):\n",
" model_list = model_mgr.list()\n",
" for model in model_list:\n",
" if model_name == model['name'] and 'READY' == model['status']:\n",
" if model_name == model[\"name\"] and \"READY\" == model[\"status\"]:\n",
" return True\n",
" return False\n",
"\n",
"\n",
"def create_llm_model(model_mgr, model_name, path, algo):\n",
" task = \"QUESTION_ANSWERING\"\n",
" result = model_mgr.create(name=model_name, task=task, path=path, algo=algo)\n",
" return result"
],
"execution_count": 2,
"outputs": []
]
},
{
"cell_type": "markdown",
Expand All @@ -79,28 +78,27 @@
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"ExecuteTime": {
"end_time": "2024-07-24T02:06:56.370737Z",
"start_time": "2024-07-24T02:06:55.945422Z"
}
},
"outputs": [],
"source": [
"\n",
"ldai_model_mgr = ModelManager(LDAI_CHAT_LLM_ENDPOINT, LDAI_CHAT_USERNAME, LDAI_CHAT_PWD)\n",
"\n",
"llm_model_name = 'qa_model_qwen_72b_chat'\n",
"llm_model_name = \"qa_model_qwen_72b_chat\"\n",
"llm_model_path = \"modelscope://qwen/qwen-72b-chat-int4\"\n",
"llm_model_algo = \"QWEN_72B_CHAT_INT4\"\n",
"\n",
"\n",
"if not check_model_exist(ldai_model_mgr, llm_model_name):\n",
" create_llm_model(ldai_model_mgr, llm_model_name, llm_model_path, llm_model_algo)\n",
"else:\n",
" print(f'model {llm_model_name} exist!')"
],
"execution_count": 4,
"outputs": []
" print(f\"model {llm_model_name} exist!\")"
]
},
{
"cell_type": "markdown",
Expand All @@ -111,40 +109,40 @@
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2024-07-24T02:07:02.025370Z",
"start_time": "2024-07-24T02:07:02.015903Z"
}
},
"outputs": [],
"source": [
"from langchain_community.chat_models.lindormai import ChatLindormAI\n",
"\n",
"ldai_chat = ChatLindormAI(\n",
" endpoint=LDAI_CHAT_LLM_ENDPOINT,\n",
" username=LDAI_CHAT_USERNAME,\n",
" password=LDAI_CHAT_PWD,\n",
" model_name=llm_model_name\n",
" model_name=llm_model_name,\n",
")"
],
"execution_count": 5,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"ExecuteTime": {
"end_time": "2024-07-24T02:07:11.773551Z",
"start_time": "2024-07-24T02:07:10.357496Z"
}
},
"outputs": [],
"source": [
"question = \"hello? who are you?\"\n",
"\n",
"print(ldai_chat.invoke(question))"
],
"execution_count": 6,
"outputs": []
]
}
],
"metadata": {
Expand Down
Loading

0 comments on commit 387ccce

Please sign in to comment.