40 lines
1.9 KiB
Python
40 lines
1.9 KiB
Python
|
|
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))
|