added_predictors

This commit is contained in:
Nunzi99
2025-10-17 15:22:39 +02:00
parent ed6a4d12a6
commit e2125d5815
5 changed files with 105 additions and 4 deletions

View File

@@ -51,6 +51,7 @@ if __name__ == "__main__":
type="index",
label="Modello da usare"
)
# Per qualche motivo deep seek non viene mostrato ma se si fa print(provider.choices) sembra esserci
provider.change(fn=chat.choose_provider, inputs=provider, outputs=None)
style = gr.Dropdown(

View File

@@ -5,6 +5,8 @@ from agno.agent import Agent
from agno.models.base import Model
from agno.models.google import Gemini
from agno.models.ollama import Ollama
from agno.models.openai import OpenAIChat
from agno.models.deepseek import DeepSeek
from agno.utils.log import log_warning
from agno.tools import Toolkit
from pydantic import BaseModel
@@ -19,6 +21,8 @@ class AppModels(Enum):
"""
GEMINI = "gemini-2.0-flash" # API online
GEMINI_PRO = "gemini-2.0-pro" # API online, più costoso ma migliore
GPT_4 = "gpt-4"
DEEPSEEK = "deepseek-chat"
OLLAMA_GPT = "gpt-oss:latest" # + good - slow (13b)
OLLAMA_QWEN = "qwen3:latest" # + good + fast (8b)
OLLAMA_QWEN_4B = "qwen3:4b" # + fast + decent (4b)
@@ -49,10 +53,20 @@ class AppModels(Enum):
Controlla quali provider di modelli LLM online hanno le loro API keys disponibili
come variabili d'ambiente e ritorna una lista di provider disponibili.
"""
availables = []
if not os.getenv("GOOGLE_API_KEY"):
log_warning("No GOOGLE_API_KEY set in environment variables.")
return []
availables = [AppModels.GEMINI, AppModels.GEMINI_PRO]
else:
availables.append(AppModels.GEMINI)
availables.append(AppModels.GEMINI_PRO)
if not os.getenv("OPENAI_API_KEY"):
log_warning("No OPENAI_API_KEY set in environment variables.")
else:
availables.append(AppModels.GPT_4)
if not os.getenv("DEEPSEEK_API_KEY"):
log_warning("No DEEPSEEK_API_KEY set in environment variables.")
else:
availables.append(AppModels.DEEPSEEK)
return availables
@staticmethod
@@ -63,7 +77,9 @@ class AppModels(Enum):
d'ambiente e ritorna una lista di provider disponibili.
L'ordine di preferenza è:
1. Gemini (Google)
2. Ollama (locale)
2. OpenAI
3. DeepSeek
4. Ollama (locale)
"""
availables = [
*AppModels.availables_online(),
@@ -87,7 +103,10 @@ class AppModels(Enum):
return Gemini(name, instructions=[instructions])
elif self in {model for model in AppModels if model.name.startswith("OLLAMA")}:
return Ollama(name, instructions=[instructions])
elif self in {model for model in AppModels if model.name.startswith("GPT")}:
return OpenAIChat(name, instructions=[instructions])
elif self in {model for model in AppModels if model.name.startswith("DEEPSEEK")}:
return DeepSeek(name, instructions=[instructions])
raise ValueError(f"Modello non supportato: {self}")
def get_agent(self, instructions: str, name: str = "", output: BaseModel | None = None, tools: list[Toolkit] = []) -> Agent: