Skip to content

refactor: streamline AI prediction and stock of the day routes with n…#31

Merged
danieldanielecki merged 3 commits intomainfrom
feature/fix-ollama
May 7, 2026
Merged

refactor: streamline AI prediction and stock of the day routes with n…#31
danieldanielecki merged 3 commits intomainfrom
feature/fix-ollama

Conversation

@danieldanielecki
Copy link
Copy Markdown
Member

…ew LLM config resolver

  • Replace redundant BYOK provider logic in both routes with a centralized LLM configuration resolver.
  • Introduce resolveMarketRouteLLMConfig to handle LLM credential resolution based on user tier and requested provider.
  • Update UserProfileMenu to allow both LOCAL and BYOK tiers for the Ollama provider.
  • Enhance error handling and logging for cases where LLM credentials are not available.

…ew LLM config resolver

- Replace redundant BYOK provider logic in both routes with a centralized LLM configuration resolver.
- Introduce `resolveMarketRouteLLMConfig` to handle LLM credential resolution based on user tier and requested provider.
- Update UserProfileMenu to allow both LOCAL and BYOK tiers for the Ollama provider.
- Enhance error handling and logging for cases where LLM credentials are not available.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

Mistral code review

Correctness

  • home-page-client.tsx: The error handling for the symbol data fetch now includes the error message from the response body. This is a good improvement as it provides more context about the failure.
  • deploy.yml: The new environment variables FINNHUB_BASE_URL, FINNHUB_API_KEY, OLLAMA_MODEL, and YAHOO_FINANCE_API_URL are added to the Vercel deployment. This is correct as it ensures the environment variables are available during deployment.
  • yahoo-finance.service.ts: The getSymbolQuote and getSymbolChart methods now handle transient errors by retrying with an alternate Yahoo Finance host. This is a good improvement for reliability.

Edge Cases

  • home-page-client.tsx: The error handling for the symbol data fetch now includes a fallback for when the response body is not JSON. This handles the case where the response body is not valid JSON.
  • yahoo-finance.service.ts: The getSymbolQuote and getSymbolChart methods now handle cases where the response is not OK by throwing an error with the status text. This handles edge cases where the response is not successful.

Security

  • deploy.yml: The new environment variables FINNHUB_API_KEY and OLLAMA_MODEL are marked as sensitive. This ensures they are not exposed in logs or other outputs.
  • yahoo-finance.service.ts: The getSymbolQuote and getSymbolChart methods now use a user-agent header that mimics a browser. This helps avoid being blocked by Yahoo Finance.

Performance

  • yahoo-finance.service.ts: The getSymbolQuote and getSymbolChart methods now retry with an alternate Yahoo Finance host if the initial request fails. This improves reliability and performance by avoiding single points of failure.

Maintainability

  • resolve-market-ai-llm-config.ts: The new file resolve-market-ai-llm-config.ts encapsulates the logic for resolving LLM configurations. This improves maintainability by reducing code duplication and making the logic more modular.
  • ai-subscription-ux.ts: The new file ai-subscription-ux.ts encapsulates the logic for generating AI subscription gate messages. This improves maintainability by making the logic more reusable and easier to update.

Other Observations

  • UserProfileMenu.tsx: The useEffect hook for handling the selected explanation provider now checks if the current provider is allowed for the user's tier. This ensures the UI is consistent with the user's subscription tier.
  • env.ts: The yahooFinanceUrl environment variable now falls back to a default value if not provided. This ensures the application has a default value to fall back on if the environment variable is not set.

Overall, the changes look good and address the concerns mentioned. The improvements in error handling, reliability, and maintainability are particularly notable.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

🚀 Vercel Preview Deployment Ready!

Preview: https://stock-ibyt4z71o-ditectrevs-projects.vercel.app


This comment was automatically generated by GitHub Actions

- Add YAHOO_FINANCE_API_URL to .env.example for configurable API endpoint.
- Update YahooFinanceService to alternate between query1 and query2 endpoints for improved reliability.
- Enhance error handling in HomePageClient and stock panels to provide clearer messages based on API responses.
- Include pricing tier information in AIPredictionPanel and StockOfTheDayPanel for better user guidance.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

🚀 Vercel Preview Deployment Ready!

Preview: https://stock-aqpm7pish-ditectrevs-projects.vercel.app


This comment was automatically generated by GitHub Actions

- Add FINNHUB_BASE_URL, FINNHUB_API_KEY, OLLAMA_MODEL, and YAHOO_FINANCE_API_URL to the deployment workflow for better configuration management.
- Remove optional comment for YAHOO_FINANCE_API_URL in .env.example to streamline the configuration process.
- Update Google Tag Manager script implementation in layout.tsx for improved performance and security.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

🚀 Vercel Preview Deployment Ready!

Preview: https://stock-bebvyhk1d-ditectrevs-projects.vercel.app


This comment was automatically generated by GitHub Actions

Copy link
Copy Markdown
Member Author

@danieldanielecki danieldanielecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

@danieldanielecki danieldanielecki merged commit 0e82780 into main May 7, 2026
8 of 9 checks passed
@danieldanielecki danieldanielecki deleted the feature/fix-ollama branch May 7, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant