Spaces:
Runtime error
Runtime error
update
Browse files- __init__.py.willdelete +0 -1
- read.me.md +66 -1
- teams/base_team/cache.py +0 -107
- version.txt +1 -0
- ai_quant_agent.txt โ ๅ่ๆฐๆฎๅ ็ปๆ/ai_quant_agent.txt +0 -0
- cline_code_prompt.txt โ ๅ่ๆฐๆฎๅ ็ปๆ/cline_code_prompt.txt +0 -0
- get_weather_agent.txt โ ๅ่ๆฐๆฎๅ ็ปๆ/get_weather_agent.txt +0 -0
__init__.py.willdelete
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
print('\n\n\n\n\n\n\n\n\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&')
|
|
|
|
|
|
read.me.md
CHANGED
|
@@ -1 +1,66 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ้กน็ฎ็ฎๅฝ็ปๆไธ่ฏดๆ
|
| 2 |
+
|
| 3 |
+
ๆฌ้กน็ฎๅ
ๅซไปฅไธไธป่ฆ็ฎๅฝๅๆไปถ๏ผ
|
| 4 |
+
|
| 5 |
+
```
|
| 6 |
+
.
|
| 7 |
+
โโโ .gitattributes
|
| 8 |
+
โโโ .gitignore
|
| 9 |
+
โโโ ai_quant_agent.txt
|
| 10 |
+
โโโ cline_code_prompt.txt
|
| 11 |
+
โโโ Dockerfile
|
| 12 |
+
โโโ get_weather_agent.txt
|
| 13 |
+
โโโ push.sh
|
| 14 |
+
โโโ read.me.md
|
| 15 |
+
โโโ README copy.md
|
| 16 |
+
โโโ README.md
|
| 17 |
+
โโโ requirements.txt
|
| 18 |
+
โโโ team_framework/
|
| 19 |
+
โ โโโ __init__.py
|
| 20 |
+
โ โโโ api_key_manager.py
|
| 21 |
+
โ โโโ load_agents.py
|
| 22 |
+
โ โโโ load_team_config.py
|
| 23 |
+
โ โโโ load_tools.py
|
| 24 |
+
โ โโโ supabase_cli.py
|
| 25 |
+
โ โโโ team_quant_rows-20250514.sql
|
| 26 |
+
โโโ teams/
|
| 27 |
+
โโโ base_team/
|
| 28 |
+
โโโ __init__.py
|
| 29 |
+
โโโ .env.example
|
| 30 |
+
โโโ agent.py
|
| 31 |
+
โโโ tools/
|
| 32 |
+
โโโ __init__.py
|
| 33 |
+
โโโ get_current_time.py
|
| 34 |
+
โโโ get_weather.py
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
## ๆไปถๅ็ฎๅฝ่ฏดๆ
|
| 38 |
+
|
| 39 |
+
* `.gitattributes`: Git ๅฑๆงๆไปถ๏ผ็จไบๅฎไนๆไปถๅฆไฝ่ขซ Git ๅค็๏ผไพๅฆ๏ผ่กๅฐพ็ฌฆ๏ผใ
|
| 40 |
+
* `.gitignore`: Git ๅฟฝ็ฅๆไปถ๏ผๅๅบไบไธๅบ่ขซ Git ่ท่ธช็ๆไปถๅ็ฎๅฝใ
|
| 41 |
+
* `ai_quant_agent.txt`: ๅฏ่ฝๆฏไธ AI ้ๅไปฃ็็ธๅ
ณ็ๆๆฌๆไปถ๏ผๅฏ่ฝๅ
ๅซ้
็ฝฎๆๆ็คบไฟกๆฏใ
|
| 42 |
+
* `cline_code_prompt.txt`: ๅฏ่ฝๆฏ็จไบไปฃ็ ็ๆ็ๆ็คบๆๆฌๆไปถใ
|
| 43 |
+
* `Dockerfile`: Docker ้ๅๆๅปบๆไปถ๏ผๅฎไนไบๅฆไฝๆๅปบ้กน็ฎ็ Docker ้ๅใ
|
| 44 |
+
* `get_weather_agent.txt`: ๅฏ่ฝๆฏไธ่ทๅๅคฉๆฐไปฃ็็ธๅ
ณ็ๆๆฌๆไปถ๏ผๅฏ่ฝๅ
ๅซ้
็ฝฎๆๆ็คบไฟกๆฏใ
|
| 45 |
+
* `push.sh`: Shell ่ๆฌ๏ผๅฏ่ฝ็จไบๆๅปบๅๆจ้ Docker ้ๅๆไปฃ็ ๅฐไปๅบใ
|
| 46 |
+
* `read.me.md`: ๆฌๆไปถ๏ผๆไพ้กน็ฎ็็ฎๅฝ็ปๆๅ่ฏดๆใ
|
| 47 |
+
* `README copy.md`, `README.md`: ้กน็ฎ็ๆ น README ๆไปถ๏ผ้ๅธธๅ
ๅซ้กน็ฎ็ไป็ปใๅฎ่ฃ
ๅไฝฟ็จ่ฏดๆใ
|
| 48 |
+
* `requirements.txt`: Python ไพ่ตๆไปถ๏ผๅๅบไบ้กน็ฎๆ้็ๆๆ Python ๅ
ใ
|
| 49 |
+
* `team_framework/`: ๅข้ๆกๆถ็ๆ ธๅฟไปฃ็ ็ฎๅฝใ
|
| 50 |
+
* `__init__.py`: Python ๅ
็ๅๅงๅๆไปถใ
|
| 51 |
+
* `api_key_manager.py`: ่ด่ดฃ็ฎก็ API ๅฏ้ฅ็ๆจกๅใ
|
| 52 |
+
* `load_agents.py`: ่ด่ดฃๅ ่ฝฝไปฃ็้
็ฝฎๅๅฎ็ฐ็ๆจกๅใ
|
| 53 |
+
* `load_team_config.py`: ่ด่ดฃๅ ่ฝฝๅข้้
็ฝฎ็ๆจกๅใ
|
| 54 |
+
* `load_tools.py`: ่ด่ดฃๅ ่ฝฝๅทฅๅ
ท็ๆจกๅใ
|
| 55 |
+
* `supabase_cli.py`: ไธ Supabase ๅฝไปค่กๆฅๅฃไบคไบ็ธๅ
ณ็ๆจกๅใ
|
| 56 |
+
* `team_quant_rows-20250514.sql`: SQL ๆไปถ๏ผๅฏ่ฝๅ
ๅซๆฐๆฎๅบๆจกๅผๅฎไนๆๅๅงๆฐๆฎ๏ผๆฅๆๅ็ผ่กจ็คบๅฏ่ฝๆฏๆไธชๆถ้ด็น็ๅฟซ็
งๆ่ฟ็งปใ
|
| 57 |
+
* `teams/`: ๅญๆพไธๅๅข้้
็ฝฎๅไปฃ็ ็็ฎๅฝใ
|
| 58 |
+
* `base_team/`: ๅบ็กๅข้็้
็ฝฎๅไปฃ็ ็ฎๅฝใๆ ธๅฟๅฟ
้กปๅ
ๆฌไธไธชๆไปถ๏ผ__init__.pyใ.envใagent.py
|
| 59 |
+
* `__init__.py`: Python ๅ
็ๅๅงๅๆไปถใ
|
| 60 |
+
* `.env`: ็ฏๅขๅ้ๆไปถ๏ผๅฝๅๅข้ๆ้็้
็ฝฎ้กนใ
|
| 61 |
+
* `.env.example`: ็ฏๅขๅ้็คบไพๆไปถ๏ผ่ฏดๆไบ่ฟ่กๆญคๅข้ๆ้็้
็ฝฎ้กนใ
|
| 62 |
+
* `agent.py`: ๅบ็กๅข้็ไปฃ็้ป่พๅฎ็ฐใ
|
| 63 |
+
* `tools/`: ๏ผๅฏ้๏ผๅบ็กๅข้ไฝฟ็จ็ๅทฅๅ
ทๆจกๅ็ฎๅฝใใๅผบ็ๅปบ่ฎฎ้็จๆ็็MCPใๆ่
่ชๅฎไนๅผๅMCP๏ผๅนถไฝฟ็จMCP่ฟ่ก่ฐ็จใ
|
| 64 |
+
* `__init__.py`: Python ๅ
็ๅๅงๅๆไปถใ
|
| 65 |
+
* `get_current_time.py`: ่ทๅๅฝๅๆถ้ด็ๅทฅๅ
ทๅฎ็ฐใ
|
| 66 |
+
* `get_weather.py`: ่ทๅๅคฉๆฐ็ๅทฅๅ
ทๅฎ็ฐใ
|
teams/base_team/cache.py
DELETED
|
@@ -1,107 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
from supabase import create_client, Client
|
| 3 |
-
import time
|
| 4 |
-
from dotenv import load_dotenv
|
| 5 |
-
|
| 6 |
-
load_dotenv()
|
| 7 |
-
|
| 8 |
-
# Simple in-memory cache
|
| 9 |
-
api_key_cache = {}
|
| 10 |
-
last_loaded_time = 0
|
| 11 |
-
CACHE_TTL = 300 # Cache time-to-live in seconds (5 minutes)
|
| 12 |
-
|
| 13 |
-
def get_supabase_client() -> Client:
|
| 14 |
-
"""Initializes and returns a Supabase client."""
|
| 15 |
-
url: str = os.environ.get("SUPABASE_URL")
|
| 16 |
-
key: str = os.environ.get("SUPABASE_KEY")
|
| 17 |
-
if not url or not key:
|
| 18 |
-
print("Supabase URL or Key not found in environment variables.")
|
| 19 |
-
return None
|
| 20 |
-
return create_client(url, key)
|
| 21 |
-
|
| 22 |
-
def load_api_keys_from_db():
|
| 23 |
-
"""Loads API keys from the database into the cache."""
|
| 24 |
-
global api_key_cache
|
| 25 |
-
|
| 26 |
-
print("Loading API keys from database...")
|
| 27 |
-
supabase: Client = get_supabase_client()
|
| 28 |
-
if not supabase:
|
| 29 |
-
return {}
|
| 30 |
-
|
| 31 |
-
try:
|
| 32 |
-
response = supabase.from_("app_config").select("config").eq("id", 1).execute()
|
| 33 |
-
#[
|
| 34 |
-
# {
|
| 35 |
-
# 'config': {
|
| 36 |
-
# 'api_keys': [
|
| 37 |
-
# {'api_key': 'xxxxx', 'can_use_at': 0},
|
| 38 |
-
# {'api_key': 'yyyyy', 'can_use_at': 0}
|
| 39 |
-
# ]
|
| 40 |
-
# }
|
| 41 |
-
# }
|
| 42 |
-
#]
|
| 43 |
-
# print(f"Supabase response data: {response.data}")
|
| 44 |
-
|
| 45 |
-
if response.data and response.data[0] and 'config' in response.data[0] and 'api_keys' in response.data[0]['config']:
|
| 46 |
-
api_keys_list = response.data[0]['config']['api_keys']
|
| 47 |
-
if api_keys_list:
|
| 48 |
-
api_key_cache = {item['api_key']: item['can_use_at'] for item in api_keys_list}
|
| 49 |
-
# {'xxxxx': 0, 'yyyyy': 0}
|
| 50 |
-
# print(f"Successfully loaded {len(api_key_cache)} API keys with can_use_at timestamps.")
|
| 51 |
-
# print(f"API keys cache: {api_key_cache}")
|
| 52 |
-
else:
|
| 53 |
-
print("API keys list is empty in the database response.")
|
| 54 |
-
api_key_cache = {}
|
| 55 |
-
else:
|
| 56 |
-
print("Unexpected database response structure or no data found.")
|
| 57 |
-
api_key_cache = {}
|
| 58 |
-
|
| 59 |
-
except Exception as e:
|
| 60 |
-
print(f"Error loading API keys from database: {e}")
|
| 61 |
-
api_key_cache = {} # Clear cache on error
|
| 62 |
-
|
| 63 |
-
return api_key_cache
|
| 64 |
-
|
| 65 |
-
def get_api_key():
|
| 66 |
-
"""Gets an API key from the cache, loading from DB if necessary."""
|
| 67 |
-
global api_key_cache
|
| 68 |
-
# print("\n\n\n\n\nGetting API key...")
|
| 69 |
-
# print(api_key_cache)
|
| 70 |
-
|
| 71 |
-
# Ensure cache is loaded
|
| 72 |
-
if not api_key_cache :
|
| 73 |
-
load_api_keys_from_db()
|
| 74 |
-
# api_key_cache={'xxxxx': 1, 'yyyyy': 0}
|
| 75 |
-
# print('api_key_cache',api_key_cache)
|
| 76 |
-
|
| 77 |
-
# Sort available keys by their 'can_use_at' timestamp in ascending order
|
| 78 |
-
sorted_key_cache = sorted(api_key_cache, key=lambda key: api_key_cache.get(key, float('inf')))
|
| 79 |
-
# print('\n\n\n\n\n\n\n\n\nsorted_key_cache',sorted_key_cache)
|
| 80 |
-
|
| 81 |
-
# Select the key with the smallest 'can_use_at' value
|
| 82 |
-
selected_key = sorted_key_cache[0]
|
| 83 |
-
|
| 84 |
-
# TODO: Update the 'can_use_at' timestamp for the selected key in the cache
|
| 85 |
-
# This requires knowing the rate limit or delay period for the API.
|
| 86 |
-
# For now, we'll just return the key. In a real system, you'd update the cache
|
| 87 |
-
# with a future timestamp after using the key successfully.
|
| 88 |
-
# Example: api_key_cache[selected_key] = time.time() + API_RATE_LIMIT_DELAY
|
| 89 |
-
|
| 90 |
-
# print(f"Using API key: {selected_key[:5]}...") # Print partial key for security
|
| 91 |
-
api_key_cache[selected_key]=time.time()
|
| 92 |
-
return selected_key
|
| 93 |
-
|
| 94 |
-
# Example usage (for testing)
|
| 95 |
-
if __name__ == "__main__":
|
| 96 |
-
# In a real application, environment variables would be set
|
| 97 |
-
# For testing, you might set them here or use a .env file loader
|
| 98 |
-
# os.environ['SUPABASE_URL'] = 'your_supabase_url'
|
| 99 |
-
# os.environ['SUPABASE_KEY'] = 'your_supabase_key'
|
| 100 |
-
|
| 101 |
-
# keys = load_api_keys_from_db()
|
| 102 |
-
# print("Loaded keys:", keys)
|
| 103 |
-
|
| 104 |
-
# # Simulate using cached keys
|
| 105 |
-
# keys = load_api_keys_from_db()
|
| 106 |
-
# print("Loaded keys (from cache):", keys)
|
| 107 |
-
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
version.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
v0.1.0
|
ai_quant_agent.txt โ ๅ่ๆฐๆฎๅ
็ปๆ/ai_quant_agent.txt
RENAMED
|
File without changes
|
cline_code_prompt.txt โ ๅ่ๆฐๆฎๅ
็ปๆ/cline_code_prompt.txt
RENAMED
|
File without changes
|
get_weather_agent.txt โ ๅ่ๆฐๆฎๅ
็ปๆ/get_weather_agent.txt
RENAMED
|
File without changes
|