testing new features
This commit is contained in:
+15
-2
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
|
||||
from ai import prompts
|
||||
from cashflow_model import FinancialModel
|
||||
from cashflow_model import CurrencyConverter, FinancialModel
|
||||
from engine.forecast import ForecastService
|
||||
|
||||
|
||||
@@ -10,8 +10,15 @@ class AssistantError(Exception):
|
||||
|
||||
|
||||
class AssistantService:
|
||||
def __init__(self, model: FinancialModel):
|
||||
def __init__(
|
||||
self,
|
||||
model: FinancialModel,
|
||||
converter: CurrencyConverter | None = None,
|
||||
display_currency: str | None = None,
|
||||
):
|
||||
self.model = model
|
||||
self.converter = converter or CurrencyConverter(model.exchange_rates)
|
||||
self.display_currency = display_currency or model.base_currency
|
||||
|
||||
def analyze(self, months: int = 12) -> dict:
|
||||
forecast_service = ForecastService(self.model)
|
||||
@@ -22,6 +29,8 @@ class AssistantService:
|
||||
model_json=json.dumps(self.model.to_dict(), indent=2, ensure_ascii=False),
|
||||
forecast_json=json.dumps(forecast_result, indent=2, ensure_ascii=False),
|
||||
months=months,
|
||||
base_currency=self.model.base_currency,
|
||||
display_currency=self.display_currency,
|
||||
)
|
||||
|
||||
return {
|
||||
@@ -39,6 +48,8 @@ class AssistantService:
|
||||
model_json=json.dumps(self.model.to_dict(), indent=2, ensure_ascii=False),
|
||||
forecast_json=json.dumps(forecast_result, indent=2, ensure_ascii=False),
|
||||
question=question,
|
||||
base_currency=self.model.base_currency,
|
||||
display_currency=self.display_currency,
|
||||
)
|
||||
|
||||
return {
|
||||
@@ -49,6 +60,8 @@ class AssistantService:
|
||||
def compare_scenarios(self, scenarios_json: str) -> dict:
|
||||
prompt = prompts.SCENARIO_COMPARISON_PROMPT.format(
|
||||
scenarios_json=scenarios_json,
|
||||
base_currency=self.model.base_currency,
|
||||
display_currency=self.display_currency,
|
||||
)
|
||||
return {
|
||||
"prompt": prompt,
|
||||
|
||||
Reference in New Issue
Block a user