mirror of
https://github.com/xming521/WeClone.git
synced 2026-08-28 18:07:28 +08:00
chore: update dependencies and configuration
- Updated Python version requirement in `pyproject.toml` to 3.12. - Adjusted dependency specifications for `llamafactory`, `torch`, `torchvision`, and `torchaudio` to include version constraints.
This commit is contained in:
@@ -14,4 +14,3 @@ alwaysApply: true
|
||||
- The project uses uv as the package manager and pyproject.toml as the project configuration file.
|
||||
- You should write as few code comments as possible.
|
||||
- Prefer using the encapsulated logger `from weclone.utils.log import logger` for printing.
|
||||
- Comments should prioritize the use of English.
|
||||
|
||||
@@ -196,3 +196,4 @@ settings-bot8006.jsonc
|
||||
models_final/*
|
||||
/data/*
|
||||
/llamaboard_cache
|
||||
eval_Result/*
|
||||
|
||||
+1
-1
Submodule WC-exp updated: e0a57c1805...e62bd446c9
+12
-8
@@ -4,7 +4,7 @@ version = "0.3.03"
|
||||
description = "One-stop solution for creating your digital avatar from chat history"
|
||||
authors = [{ name = "xming521" }]
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10,<3.11"
|
||||
requires-python = ">=3.12,<3.13"
|
||||
|
||||
dependencies = [
|
||||
"pandas",
|
||||
@@ -15,7 +15,6 @@ dependencies = [
|
||||
"pydantic==2.10.6",
|
||||
"setuptools>=78.1.0",
|
||||
"loguru>=0.7.3",
|
||||
"tomli; python_version < '3.11'",
|
||||
"langchain",
|
||||
"openai==1.87.0",
|
||||
"pip"
|
||||
@@ -33,10 +32,12 @@ config_changelog = """
|
||||
|
||||
[dependency-groups]
|
||||
main = [
|
||||
"llamafactory @ git+https://github.com/hiyouga/LLaMA-Factory.git",
|
||||
"llamafactory==0.9.4",
|
||||
"vllm==0.10.0; platform_system == 'Linux'",
|
||||
"torch==2.7.1",
|
||||
"torchvision==0.22.1",
|
||||
"torch==2.7.1+cu126; platform_system == 'Linux' or platform_system == 'Windows'",
|
||||
"torchvision==0.22.1+cu126; platform_system == 'Linux' or platform_system == 'Windows'",
|
||||
"torchaudio==2.7.1+cu126; platform_system == 'Linux' or platform_system == 'Windows'",
|
||||
"torchdata>=0.10.0; platform_system == 'Linux' or platform_system == 'Windows'",
|
||||
"transformers==4.53.2",
|
||||
"accelerate==1.7.0",
|
||||
"triton==3.3.1; platform_system == 'Linux'",
|
||||
@@ -83,7 +84,10 @@ triton = [
|
||||
{ index = "pytorch-cu126", marker = "platform_system == 'Windows'" },
|
||||
{ index = "pytorch-cu126", marker = "platform_system == 'Linux'" },
|
||||
]
|
||||
|
||||
torchdata = [
|
||||
{ index = "pytorch-cu126", marker = "platform_system == 'Windows'" },
|
||||
{ index = "pytorch-cu126", marker = "platform_system == 'Linux'" },
|
||||
]
|
||||
|
||||
[[tool.uv.index]]
|
||||
name = "pytorch-cu126"
|
||||
@@ -105,7 +109,7 @@ ignore = ["**/archive"]
|
||||
reportMissingImports = "error"
|
||||
reportMissingTypeStubs = false
|
||||
|
||||
pythonVersion = "3.10"
|
||||
pythonVersion = "3.12"
|
||||
pythonPlatform = "Linux"
|
||||
|
||||
[tool.ruff]
|
||||
@@ -126,7 +130,7 @@ lint.select = [
|
||||
"C4", # flake8-comprehensions
|
||||
"Q", # flake8-quotes
|
||||
]
|
||||
target-version = "py310"
|
||||
target-version = "py312"
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
addopts = "-x -v -s --tb=short"
|
||||
|
||||
@@ -260,13 +260,11 @@ def run_webchat_demo_test(config_file: str):
|
||||
"""执行 webchat-demo 测试"""
|
||||
print_test_header("webchat-demo", config_file)
|
||||
|
||||
with mock.patch("weclone.eval.web_demo.main") as mock_main:
|
||||
mock_main.return_value = None
|
||||
try:
|
||||
result = run_cli_command(["webchat-demo"], config_file, timeout=20)
|
||||
assert result.returncode == 0, f"webchat-demo command execution failed for config {config_file}"
|
||||
except subprocess.TimeoutExpired:
|
||||
pass
|
||||
try:
|
||||
result = run_cli_command(["webchat-demo"], config_file, timeout=20)
|
||||
assert result.returncode == 0, f"webchat-demo command execution failed for config {config_file}"
|
||||
except subprocess.TimeoutExpired:
|
||||
pass
|
||||
|
||||
def run_server_test(config_file: str) -> subprocess.Popen:
|
||||
"""执行 server 测试,返回进程对象"""
|
||||
|
||||
@@ -22,6 +22,8 @@ class OnlineLLM:
|
||||
model_name: str,
|
||||
default_system: Optional[str] = None,
|
||||
max_workers: int = 10,
|
||||
prompt_with_system: bool = False,
|
||||
response_format: str = "json_object",
|
||||
):
|
||||
self.api_key = api_key
|
||||
self.base_url = base_url
|
||||
@@ -30,6 +32,8 @@ class OnlineLLM:
|
||||
self.max_workers = max_workers
|
||||
self.client = OpenAI(api_key=self.api_key, base_url=self.base_url, max_retries=0)
|
||||
self.executor = ThreadPoolExecutor(max_workers=max_workers)
|
||||
self.prompt_with_system = prompt_with_system
|
||||
self.response_format = response_format
|
||||
|
||||
@retry_openai_api(max_retries=200, base_delay=30.0, max_delay=180.0)
|
||||
def chat(
|
||||
@@ -40,20 +44,29 @@ class OnlineLLM:
|
||||
top_p: float = 0.95,
|
||||
stream: bool = False,
|
||||
):
|
||||
messages: List[ChatCompletionMessageParam] = [
|
||||
# {"role": "system", "content": self.default_system},
|
||||
{"role": "user", "content": prompt_text},
|
||||
]
|
||||
response = self.client.chat.completions.create(
|
||||
model=self.model_name,
|
||||
messages=messages,
|
||||
stream=stream,
|
||||
temperature=temperature,
|
||||
max_tokens=max_tokens,
|
||||
top_p=top_p,
|
||||
response_format={"type": "json_object"},
|
||||
messages: List[ChatCompletionMessageParam] = []
|
||||
if self.prompt_with_system:
|
||||
messages = prompt_text
|
||||
else:
|
||||
messages = [
|
||||
# {"role": "system", "content": self.default_system},
|
||||
{"role": "user", "content": prompt_text},
|
||||
]
|
||||
|
||||
params = {
|
||||
"model": self.model_name,
|
||||
"messages": messages,
|
||||
"stream": stream,
|
||||
"temperature": temperature,
|
||||
"max_tokens": max_tokens,
|
||||
"top_p": top_p,
|
||||
# extra_body={"chat_template_kwargs": {"enable_thinking": False}}
|
||||
)
|
||||
}
|
||||
|
||||
if self.response_format:
|
||||
params["response_format"] = {"type": self.response_format}
|
||||
|
||||
response = self.client.chat.completions.create(**params)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
Reference in New Issue
Block a user