anderson-ufrj
commited on
Commit
·
f317ea3
1
Parent(s):
11a4d19
refactor: change default Maritaca model from sabia-3 to sabiazinho-3
Browse files- Updated all Maritaca client references to use sabiazinho-3 model
- Changed default model in config.py to sabiazinho-3
- Updated chat_stable.py, chat_simple.py, chat_emergency.py endpoints
- Updated MaritacaClient default initialization model
- More cost-effective model choice for production use
src/api/routes/chat_emergency.py
CHANGED
|
@@ -88,7 +88,7 @@ async def try_maritaca(message: str) -> Optional[str]:
|
|
| 88 |
},
|
| 89 |
{"role": "user", "content": message}
|
| 90 |
],
|
| 91 |
-
"model": "
|
| 92 |
"temperature": 0.7,
|
| 93 |
"max_tokens": 400
|
| 94 |
}
|
|
@@ -123,7 +123,7 @@ async def chat_emergency(request: ChatRequest) -> ChatResponse:
|
|
| 123 |
confidence=0.95,
|
| 124 |
suggested_actions=["investigate_contracts", "analyze_expenses", "generate_report"],
|
| 125 |
metadata={
|
| 126 |
-
"model": "
|
| 127 |
"backend": "maritaca_ai",
|
| 128 |
"timestamp": datetime.utcnow().isoformat()
|
| 129 |
}
|
|
|
|
| 88 |
},
|
| 89 |
{"role": "user", "content": message}
|
| 90 |
],
|
| 91 |
+
"model": "sabiazinho-3",
|
| 92 |
"temperature": 0.7,
|
| 93 |
"max_tokens": 400
|
| 94 |
}
|
|
|
|
| 123 |
confidence=0.95,
|
| 124 |
suggested_actions=["investigate_contracts", "analyze_expenses", "generate_report"],
|
| 125 |
metadata={
|
| 126 |
+
"model": "sabiazinho-3",
|
| 127 |
"backend": "maritaca_ai",
|
| 128 |
"timestamp": datetime.utcnow().isoformat()
|
| 129 |
}
|
src/api/routes/chat_simple.py
CHANGED
|
@@ -25,7 +25,7 @@ if MARITACA_API_KEY:
|
|
| 25 |
try:
|
| 26 |
maritaca_client = MaritacaClient(
|
| 27 |
api_key=MARITACA_API_KEY,
|
| 28 |
-
model=MaritacaModel.
|
| 29 |
)
|
| 30 |
logger.info("Maritaca AI client initialized successfully")
|
| 31 |
except Exception as e:
|
|
|
|
| 25 |
try:
|
| 26 |
maritaca_client = MaritacaClient(
|
| 27 |
api_key=MARITACA_API_KEY,
|
| 28 |
+
model=MaritacaModel.SABIAZINHO_3
|
| 29 |
)
|
| 30 |
logger.info("Maritaca AI client initialized successfully")
|
| 31 |
except Exception as e:
|
src/api/routes/chat_stable.py
CHANGED
|
@@ -29,7 +29,7 @@ def get_maritaca_client():
|
|
| 29 |
if api_key:
|
| 30 |
maritaca_client = MaritacaClient(
|
| 31 |
api_key=api_key,
|
| 32 |
-
model=MaritacaModel.
|
| 33 |
)
|
| 34 |
return maritaca_client
|
| 35 |
|
|
@@ -128,7 +128,7 @@ async def process_with_maritaca(message: str, intent_type: IntentType, session_i
|
|
| 128 |
return {
|
| 129 |
"message": response.content if hasattr(response, 'content') else str(response),
|
| 130 |
"agent_used": "maritaca_ai",
|
| 131 |
-
"model": response.model if hasattr(response, 'model') else "
|
| 132 |
"success": True
|
| 133 |
}
|
| 134 |
except Exception as e:
|
|
@@ -143,7 +143,7 @@ async def process_with_maritaca(message: str, intent_type: IntentType, session_i
|
|
| 143 |
headers={"authorization": f"Bearer {os.getenv('MARITACA_API_KEY')}"},
|
| 144 |
json={
|
| 145 |
"messages": [{"role": "user", "content": message}],
|
| 146 |
-
"model": "
|
| 147 |
"temperature": 0.7
|
| 148 |
}
|
| 149 |
)
|
|
@@ -152,7 +152,7 @@ async def process_with_maritaca(message: str, intent_type: IntentType, session_i
|
|
| 152 |
return {
|
| 153 |
"message": data.get("answer", get_fallback_response(intent_type)),
|
| 154 |
"agent_used": "maritaca_direct",
|
| 155 |
-
"model": "
|
| 156 |
"success": True
|
| 157 |
}
|
| 158 |
except Exception as e:
|
|
|
|
| 29 |
if api_key:
|
| 30 |
maritaca_client = MaritacaClient(
|
| 31 |
api_key=api_key,
|
| 32 |
+
model=MaritacaModel.SABIAZINHO_3 # Using efficient model for cost optimization
|
| 33 |
)
|
| 34 |
return maritaca_client
|
| 35 |
|
|
|
|
| 128 |
return {
|
| 129 |
"message": response.content if hasattr(response, 'content') else str(response),
|
| 130 |
"agent_used": "maritaca_ai",
|
| 131 |
+
"model": response.model if hasattr(response, 'model') else "sabiazinho-3",
|
| 132 |
"success": True
|
| 133 |
}
|
| 134 |
except Exception as e:
|
|
|
|
| 143 |
headers={"authorization": f"Bearer {os.getenv('MARITACA_API_KEY')}"},
|
| 144 |
json={
|
| 145 |
"messages": [{"role": "user", "content": message}],
|
| 146 |
+
"model": "sabiazinho-3",
|
| 147 |
"temperature": 0.7
|
| 148 |
}
|
| 149 |
)
|
|
|
|
| 152 |
return {
|
| 153 |
"message": data.get("answer", get_fallback_response(intent_type)),
|
| 154 |
"agent_used": "maritaca_direct",
|
| 155 |
+
"model": "sabiazinho-3",
|
| 156 |
"success": True
|
| 157 |
}
|
| 158 |
except Exception as e:
|
src/core/config.py
CHANGED
|
@@ -114,8 +114,8 @@ class Settings(BaseSettings):
|
|
| 114 |
description="Maritaca AI base URL"
|
| 115 |
)
|
| 116 |
maritaca_model: str = Field(
|
| 117 |
-
default="
|
| 118 |
-
description="Default Maritaca AI model (sabia-3, sabia-3-medium, sabia-3-large)"
|
| 119 |
)
|
| 120 |
|
| 121 |
# Vector Store
|
|
|
|
| 114 |
description="Maritaca AI base URL"
|
| 115 |
)
|
| 116 |
maritaca_model: str = Field(
|
| 117 |
+
default="sabiazinho-3",
|
| 118 |
+
description="Default Maritaca AI model (sabiazinho-3, sabia-3, sabia-3-medium, sabia-3-large)"
|
| 119 |
)
|
| 120 |
|
| 121 |
# Vector Store
|
src/services/maritaca_client.py
CHANGED
|
@@ -80,7 +80,7 @@ class MaritacaClient:
|
|
| 80 |
self,
|
| 81 |
api_key: str,
|
| 82 |
base_url: str = "https://chat.maritaca.ai/api",
|
| 83 |
-
model: str = MaritacaModel.
|
| 84 |
timeout: int = 60,
|
| 85 |
max_retries: int = 3,
|
| 86 |
circuit_breaker_threshold: int = 5,
|
|
@@ -562,7 +562,7 @@ class MaritacaClient:
|
|
| 562 |
# Factory function for easy client creation
|
| 563 |
def create_maritaca_client(
|
| 564 |
api_key: str,
|
| 565 |
-
model: str = MaritacaModel.
|
| 566 |
**kwargs
|
| 567 |
) -> MaritacaClient:
|
| 568 |
"""
|
|
|
|
| 80 |
self,
|
| 81 |
api_key: str,
|
| 82 |
base_url: str = "https://chat.maritaca.ai/api",
|
| 83 |
+
model: str = MaritacaModel.SABIAZINHO_3,
|
| 84 |
timeout: int = 60,
|
| 85 |
max_retries: int = 3,
|
| 86 |
circuit_breaker_threshold: int = 5,
|
|
|
|
| 562 |
# Factory function for easy client creation
|
| 563 |
def create_maritaca_client(
|
| 564 |
api_key: str,
|
| 565 |
+
model: str = MaritacaModel.SABIAZINHO_3,
|
| 566 |
**kwargs
|
| 567 |
) -> MaritacaClient:
|
| 568 |
"""
|