Skip to main content

加入开发

依赖管理:Poetry与env/dependency管理方法

这个项目使用 Poetry 来管理依赖。

注意:在安装Poetry之前,如果您使用Conda,请创建并激活一个新的Conda env(例如,conda create-n chatchat python=3.9

Install Poetry: documentation on how to install it.

注意: 如果您使用 Conda 或 Pyenv 作为您的环境/包管理器,在安装Poetry之后, 使用如下命令使Poetry使用virtualenv python environment (poetry config virtualenvs.prefer-active-python true)

本地开发环境安装

  • 选择主项目目录
cd model-providers
  • 安装model-providers依赖(for running model-providers lint\tests):
poetry install --with lint,test

格式化和代码检查

在提交PR之前,请在本地运行以下命令;CI系统也会进行检查。

代码格式化

本项目使用ruff进行代码格式化。

要对某个库进行格式化,请在相应的库目录下运行相同的命令:

cd {model-providers|chatchat|chatchat-server|chatchat-frontend}
make format

此外,你可以使用format_diff命令仅对当前分支中与主分支相比已修改的文件进行格式化:

 
make format_diff

当你对项目的一部分进行了更改,并希望确保更改的部分格式正确,而不影响代码库的其他部分时,这个命令特别有用。

开始使用

当项目安装完成,配置这个model_providers.yaml文件,即可完成平台加载

注意: 在您配置平台之前,请确认平台依赖完整,例如智谱平台,您需要安装智谱sdk pip install zhipuai

model_providers包含了不同平台提供的 全局配置provider_credential,和模型配置model_credential 不同平台所加载的配置有所不同,关于如何配置这个文件

请查看包model_providers.core.model_runtime.model_providers下方的平台 yaml文件 例如zhipuai.yaml,这里给出了provider_credential_schema,其中包含了一个变量api_key

要加载智谱平台,操作如下

  • 安装sdk
$ pip install zhipuai
  • 编辑model_providers.yaml
zhipuai:

  provider_credential:
    api_key: 'd4fa0690b6dfa205204cae2e12aa6fb6.2'
  • model-providers可以运行pytest 测试
  poetry run pytest tests/server_unit_test/test_init_server.py

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

model_providers-0.3.0.20240506.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

model_providers-0.3.0.20240506-py3-none-any.whl (1.7 MB view details)

Uploaded Python 3

File details

Details for the file model_providers-0.3.0.20240506.tar.gz.

File metadata

  • Download URL: model_providers-0.3.0.20240506.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.13 Linux/6.8.7-arch1-1

File hashes

Hashes for model_providers-0.3.0.20240506.tar.gz
Algorithm Hash digest
SHA256 4c5763c9b927a183cdf9ed947ba28810a71e89781b2cce65ce7d3013b2fe4337
MD5 a6d8a1794584285132593168b554c610
BLAKE2b-256 7fb4880811dc0da8477f08874e22c7f4d6c3b1a7a1b16d27e75d40e68010cdbf

See more details on using hashes here.

File details

Details for the file model_providers-0.3.0.20240506-py3-none-any.whl.

File metadata

File hashes

Hashes for model_providers-0.3.0.20240506-py3-none-any.whl
Algorithm Hash digest
SHA256 18439ad5015d1fac852e927aa97207f97c022e767f3fa7ed52913dab548a6b43
MD5 9e9ced153548f58d71d69689b9810d74
BLAKE2b-256 c65a39019187e26d09d755f7c41395be40fa4f3ddc3ed57c2c624694fa2eb56f

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.1

2 files

0.3.0.20240621

2 files

0.3.0.20240619

2 files

0.3.0.20240618

2 files

0.3.0.20240616

2 files

0.3.0.20240612

2 files

0.3.0.20240610

2 files

This release

0.3.0.20240506 This release

2 files

0.3.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page