forked from trpc-group/trpc-agent-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
61 lines (53 loc) · 2.01 KB
/
Copy pathconfig.py
File metadata and controls
61 lines (53 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Tencent is pleased to support the open source community by making tRPC-Agent-Python available.
#
# Copyright (C) 2026 Tencent. All rights reserved.
#
# tRPC-Agent-Python is licensed under Apache-2.0.
""" Agent config module"""
import os
from mem0.configs.base import MemoryConfig
def get_model_config() -> tuple[str, str, str]:
"""Get model config from environment variables"""
api_key = os.getenv('TRPC_AGENT_API_KEY', '')
url = os.getenv('TRPC_AGENT_BASE_URL', '')
model_name = os.getenv('TRPC_AGENT_MODEL_NAME', '')
if not api_key or not url or not model_name:
raise ValueError('''TRPC_AGENT_API_KEY, TRPC_AGENT_BASE_URL,
and TRPC_AGENT_MODEL_NAME must be set in environment variables''')
return api_key, url, model_name
def get_memory_config() -> MemoryConfig:
"""Get memory config from environment variables"""
memory_config = {
"vector_store": {
"provider": "qdrant",
"config": {
"host": "localhost",
"port": 6333,
"collection_name": "mem0",
}
},
"llm": {
"provider": "deepseek",
"config": {
"model": os.getenv('TRPC_AGENT_MODEL_NAME', ''),
"api_key": os.getenv('TRPC_AGENT_API_KEY', ''),
"deepseek_base_url": os.getenv('TRPC_AGENT_BASE_URL', ''),
"temperature": 0.2,
"max_tokens": 2000,
}
},
"embedder": {
"provider": "huggingface",
"config": {
"model": "multi-qa-MiniLM-L6-cos-v1" # local running, no API key needed
# "model": "text-embedding-3-small" # local running, no API key needed
}
}
}
return MemoryConfig(**memory_config)
def get_mem0_platform_config() -> dict:
"""Get mem0 platform config from environment variables"""
return {
"api_key": os.getenv('MEM0_API_KEY', ''),
"host": os.getenv('MEM0_BASE_URL', ''),
}