This commit is contained in:
2026-06-04 17:59:53 +08:00
parent e6c27ac662
commit 0908495d6f
66 changed files with 4230 additions and 0 deletions
View File
+39
View File
@@ -0,0 +1,39 @@
import asyncio
import httpx
async def create_hermes_profiles(characters: list[dict], base_url: str = "http://localhost:11434/v1"):
async with httpx.AsyncClient(timeout=60.0) as client:
for char in characters:
profile_name = char["name"].lower().replace(" ", "_")
print(f"Creating profile: {profile_name}")
try:
response = await client.post(
f"{base_url}/models",
json={
"name": profile_name,
"system_prompt": f"你是{char['name']},{char.get('personality', '')},{char.get('background', '')}",
},
)
if response.status_code == 200:
print(f" Created: {profile_name}")
else:
print(f" Warning ({response.status_code}): {profile_name} - {response.text[:200]}")
except Exception as e:
print(f" Error creating {profile_name}: {e}")
print("Profile creation completed.")
SAMPLE_CHARACTERS = [
{"name": "侦探_张", "personality": "冷静理智,善于观察和分析", "background": "著名私家侦探"},
{"name": "富商_李", "personality": "精明世故,看透人心", "background": "本地富商,经营古董店"},
{"name": "医生_王", "personality": "温柔体贴,善于倾听", "background": "在本地开诊所的医生"},
{"name": "记者_赵", "personality": "活泼开朗,和所有人关系都很好", "background": "专门报道离奇案件的记者"},
{"name": "艺术家_陈", "personality": "阴郁深沉,似乎藏着秘密", "background": "性格独特的艺术家"},
{"name": "教师_林", "personality": "急躁易怒,说话带刺", "background": "学校老师"},
]
if __name__ == "__main__":
asyncio.run(create_hermes_profiles(SAMPLE_CHARACTERS))
+13
View File
@@ -0,0 +1,13 @@
import asyncio
from app.models.database import init_db
from app.main import settings
from app.models import orm
async def init_database():
await init_db(settings.database_url)
print("Database initialized successfully.")
if __name__ == "__main__":
asyncio.run(init_database())