feat: Release v0.10 - Modular Architecture & External Config
- Refactor codebase into src/ (preprocessing, translation, assembly) - Add pipeline/ scripts for individual stages - Externalize configuration to config/config.yaml - Fix Cover Image preservation - Update documentation and manuals
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
测试 LLM 是否正确保留占位符
|
||||
"""
|
||||
import asyncio
|
||||
import json
|
||||
from openai import AsyncOpenAI
|
||||
|
||||
# 加载配置
|
||||
with open("config/config.json", "r") as f:
|
||||
config = json.load(f)
|
||||
|
||||
v3_config = config["providers"]["v3"]
|
||||
|
||||
# 从 .env 加载 API Key
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
api_key = os.getenv("V3_API_KEY") or v3_config.get("api_key", "")
|
||||
|
||||
# 加载 prompts
|
||||
with open("config/prompts.json", "r") as f:
|
||||
prompts = json.load(f)
|
||||
|
||||
system_prompt = prompts["translation"]["system"]
|
||||
|
||||
# 测试文本 - 包含占位符
|
||||
test_text = """p_00058 [BODY] Also that night, the board and the remaining leadership at the company were holding a series of increasingly hostile meetings. After the all-φ1φhands, the false projection of unity between Sutskever and the other leaders had collapsed. Many of the executives who had sat next to Sutskever during the livestream had been nearly as blindsided as the rest of the staff, having learned of Altman's dismissal moments before it was announced. φ2φRiled up by Sutskever's poor performance, they had demanded to meet with the rest of the board. Roughly a dozen executives, including Murati and Lightcap, had gathered in a conference room at the office."""
|
||||
|
||||
async def test_translation():
|
||||
client = AsyncOpenAI(
|
||||
base_url=v3_config["base_url"],
|
||||
api_key=api_key,
|
||||
default_headers=v3_config.get("extra_headers", {})
|
||||
)
|
||||
|
||||
model = v3_config["models"]["fast"]
|
||||
|
||||
print("=" * 60)
|
||||
print("SYSTEM PROMPT:")
|
||||
print("=" * 60)
|
||||
print(system_prompt)
|
||||
print()
|
||||
print("=" * 60)
|
||||
print("USER PROMPT:")
|
||||
print("=" * 60)
|
||||
print(test_text)
|
||||
print()
|
||||
print("=" * 60)
|
||||
print(f"Calling LLM ({model})...")
|
||||
print("=" * 60)
|
||||
|
||||
response = await client.chat.completions.create(
|
||||
model=model,
|
||||
messages=[
|
||||
{"role": "system", "content": system_prompt},
|
||||
{"role": "user", "content": test_text}
|
||||
],
|
||||
temperature=0.3
|
||||
)
|
||||
|
||||
result = response.choices[0].message.content
|
||||
|
||||
print()
|
||||
print("=" * 60)
|
||||
print("LLM RESPONSE:")
|
||||
print("=" * 60)
|
||||
print(result)
|
||||
print()
|
||||
|
||||
# 检查占位符
|
||||
has_phi1 = "φ1φ" in result
|
||||
has_phi2 = "φ2φ" in result
|
||||
print("=" * 60)
|
||||
print("PLACEHOLDER CHECK:")
|
||||
print(f" φ1φ present: {has_phi1}")
|
||||
print(f" φ2φ present: {has_phi2}")
|
||||
print("=" * 60)
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(test_translation())
|
||||
Reference in New Issue
Block a user