Refactoring architetturale e spostamento classi base
- Eliminazione del file __init__.py obsoleto che importava ChatManager e Pipeline - Spostamento della classe Pipeline in agents/pipeline.py - Spostamento della classe ChatManager in utils/chat_manager.py - Aggiornamento di __main__.py per importare da app.utils e app.agents, e modifica della logica per utilizzare Pipeline invece di chat per la selezione di provider e stile - Creazione della cartella base con classi base comuni: markets.py (ProductInfo, Price, MarketWrapper), news.py (Article, NewsWrapper), social.py (SocialPost, SocialComment, SocialWrapper) - Aggiornamento di tutti gli import nel progetto (markets/, news/, social/, utils/, tests/) per utilizzare la nuova struttura base/
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from agno.tools import Toolkit
|
||||
from app.utils import WrapperHandler
|
||||
from app.news.base import NewsWrapper, Article
|
||||
from app.base.news import NewsWrapper, Article
|
||||
from app.news.news_api import NewsApiWrapper
|
||||
from app.news.googlenews import GoogleNewsWrapper
|
||||
from app.news.cryptopanic_api import CryptoPanicWrapper
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class Article(BaseModel):
|
||||
source: str = ""
|
||||
time: str = ""
|
||||
title: str = ""
|
||||
description: str = ""
|
||||
|
||||
class NewsWrapper:
|
||||
"""
|
||||
Base class for news API wrappers.
|
||||
All news API wrappers should inherit from this class and implement the methods.
|
||||
"""
|
||||
|
||||
def get_top_headlines(self, limit: int = 100) -> list[Article]:
|
||||
"""
|
||||
Get top headlines, optionally limited by limit.
|
||||
Args:
|
||||
limit (int): The maximum number of articles to return.
|
||||
Returns:
|
||||
list[Article]: A list of Article objects.
|
||||
"""
|
||||
raise NotImplementedError("This method should be overridden by subclasses")
|
||||
|
||||
def get_latest_news(self, query: str, limit: int = 100) -> list[Article]:
|
||||
"""
|
||||
Get latest news based on a query.
|
||||
Args:
|
||||
query (str): The search query.
|
||||
limit (int): The maximum number of articles to return.
|
||||
Returns:
|
||||
list[Article]: A list of Article objects.
|
||||
"""
|
||||
raise NotImplementedError("This method should be overridden by subclasses")
|
||||
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
from typing import Any
|
||||
import requests
|
||||
from enum import Enum
|
||||
from app.news.base import NewsWrapper, Article
|
||||
from app.base.news import NewsWrapper, Article
|
||||
|
||||
|
||||
class CryptoPanicFilter(Enum):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
from typing import Any
|
||||
from agno.tools.duckduckgo import DuckDuckGoTools
|
||||
from app.news.base import Article, NewsWrapper
|
||||
from app.base.news import Article, NewsWrapper
|
||||
|
||||
|
||||
def extract_article(result: dict[str, Any]) -> Article:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from typing import Any
|
||||
from gnews import GNews # type: ignore
|
||||
from app.news.base import Article, NewsWrapper
|
||||
from app.base.news import Article, NewsWrapper
|
||||
|
||||
|
||||
def extract_article(result: dict[str, Any]) -> Article:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
from typing import Any
|
||||
import newsapi # type: ignore
|
||||
from app.news.base import Article, NewsWrapper
|
||||
from app.base.news import Article, NewsWrapper
|
||||
|
||||
|
||||
def extract_article(result: dict[str, Any]) -> Article:
|
||||
|
||||
Reference in New Issue
Block a user