A Python toolkit for advanced data processing and API interactions
Project description
descartkit
LLM
Three steps to use models
Step1, llm_config.yaml
matter that needs attention
- custom_model_name used for models.get_model_instance()
- custom_model_name.name should specify the name of the model supported by the current company
models:
openai:
custom_model_name:
name: "gpt-4o"
short_name: "OIG4"
company: "openai"
max_input_token: 8100
max_output_token: 2048
top_p: 0.5
top_k: 1
temperature: 0.5
input_token_fee_pm: 30.0
output_token_fee_pm: 60.0
train_token_fee_pm: 0.0
keys:
- name: "openai_key1"
- name: "openai_key2"
siliconflow:
qw-72b-p:
name: "Qwen/QVQ-72B-Preview"
short_name: "QW-72B-P"
company: "siliconflow"
max_input_token: 8100
max_output_token: 2048
top_p: 0.5
top_k: 1
temperature: 0.5
input_token_fee_pm: 30.0
output_token_fee_pm: 60.0
train_token_fee_pm: 0.0
keys:
- name: "siliconflow_1"
Step2, llm_keys.yaml
- The keys name of the model in llm_config.yaml corresponds to llm_keys.yaml one by one
keys:
openai_key1: "xx"
openai_key2: "xx"
anthropic_key1: "your_anthropic_api_key_1"
anthropic_key2: "your_anthropic_api_key_2"
Step3, load models
from descartcan.llm.config import load_models_from_yaml
from descartcan.llm import LLMClient
async def main():
# The first method
models = load_models_from_yaml(config_file="examples/llm_config.yaml", keys_file="examples/llm_keys.yaml")
print(models.list_models())
resp = await models.get_model_instance("gpt-4o").chat("who r u?")
print(resp)
# The second method
client = LLMClient(config_file="llm_config.yaml", keys_file="llm_keys.yaml")
print(client.list_models())
resp = await client.chat("qw-72b-p", "who r u?", system_prompt="")
print(resp)
async for chunk in client.chat_stream("qw-72b-p", "who r u?", system_prompt=""):
print(chunk)
if __name__ == '__main__':
import asyncio
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
descartcan-2025.4.3.1.tar.gz
(12.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file descartcan-2025.4.3.1.tar.gz.
File metadata
- Download URL: descartcan-2025.4.3.1.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a814a92c755e24ae467ec72bd05ea525d3075b4bd1c99f0221b151f34cd51d4
|
|
| MD5 |
e64883f5f1b068226260c01f9bf76a81
|
|
| BLAKE2b-256 |
7de5a5420e82743d04203fec7aae8512344b0c27cbdb542428079934accc25bd
|
File details
Details for the file descartcan-2025.4.3.1-py3-none-any.whl.
File metadata
- Download URL: descartcan-2025.4.3.1-py3-none-any.whl
- Upload date:
- Size: 26.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24c332bfba4350a8fe81029ac8b6d4440bd51179272191dfab544e3c9491a8d9
|
|
| MD5 |
415e4edd644e7d085a3686e8c329a872
|
|
| BLAKE2b-256 |
bc7e4f7a8648e9889530d4e74713dbbba4d61a22b3edb7a1cedebe396eeadd1e
|