-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
56 lines (52 loc) · 2 KB
/
main.py
File metadata and controls
56 lines (52 loc) · 2 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
import asyncio
from llm_selector import LLMSelector, LLMSelectorConfig
async def main():
# Configuration des modèles disponibles avec poids
models = {
"openai/gpt-4": {
"description": "OpenAI GPT-4 for complex reasoning and coding",
"weight": 2.0 # Plus de chances d'être sélectionné
},
"anthropic/claude-3": {
"description": "Anthropic Claude 3 for safe and helpful responses",
"weight": 1.5
},
"cerebras/llama3.3-70b": {
"description": "Cerebras Llama 3.3 70B for fast inference",
"weight": 1.0
},
"openai/gpt-3.5-turbo": {
"description": "OpenAI GPT-3.5 Turbo for quick tasks",
"weight": 0.8 # Moins de chances
},
"anthropic/claude-2": {
"description": "Anthropic Claude 2 for balanced performance",
"weight": 1.0
},
}
# Configurations des services de sélection avec fallbacks
# Les clés API peuvent être :
# - En clair: "sk-your-key"
# - Variable d'environnement: "env:OPENROUTER_API_KEY"
# - Clé dans .env: "dotenv:OPENROUTER_KEY"
selector_configs = [
LLMSelectorConfig(
model="openrouter/openai/gpt-oss-20b",
api_base="https://openrouter.ai/api/v1",
api_key="env:OPENROUTER_API_KEY" # Utilise la variable d'environnement
),
LLMSelectorConfig(
model="anthropic/claude-3-haiku",
api_key="dotenv:ANTHROPIC_KEY" # Utilise la clé dans .env
),
LLMSelectorConfig(
model="openai/gpt-3.5-turbo",
api_key="sk-your-openai-key" # Clé en clair
),
]
selector = LLMSelector(models=models, selector_configs=selector_configs)
user_input = "I need to write a complex Python script for data analysis."
selected_model = await selector.select(user_input)
print(f"Selected model: {selected_model}")
if __name__ == "__main__":
asyncio.run(main())