Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add YouTube connection #63

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions agents/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
"timeline_read_count": 10,
"cast_interval": 60
},
{
"name": "youtube",
"comment_fetch_count": 10
},
{
"name": "openai",
"model": "gpt-3.5-turbo"
Expand Down
680 changes: 456 additions & 224 deletions poetry.lock

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ description = "A launch-pad for AI agents"
authors = ["Ayoub Ed <[email protected]>", "Efrain <[email protected]>", "Max <[email protected]>"]
license = "MIT License"
readme = "README.md"
packages = [
{ include = "src" }
]

[tool.poetry.dependencies]
python = "^3.10"
Expand All @@ -14,7 +17,9 @@ tweepy = "^4.14.0"
prompt-toolkit = "^3.0.48"
anthropic = "^0.42.0"
farcaster = "^0.7.11"

google-api-python-client = "^2.97.0"
google-auth-oauthlib = "^1.0.0"
google-auth-httplib2 = "^0.1.0"

[build-system]
requires = ["poetry-core"]
Expand Down
2 changes: 2 additions & 0 deletions src/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ def __init__(
self.example_accounts = agent_dict["example_accounts"]
self.loop_delay = agent_dict["loop_delay"]
self.connection_manager = ConnectionManager(agent_dict["config"])
self.connection_manager.parent_agent = self
self.use_time_based_weights = agent_dict["use_time_based_weights"]
self.time_based_multipliers = agent_dict["time_based_multipliers"]


has_twitter_tasks = any("tweet" in task["name"] for task in agent_dict.get("tasks", []))

Expand Down
5 changes: 5 additions & 0 deletions src/connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
from src.connections.ollama_connection import OllamaConnection
from src.connections.echochambers_connection import EchochambersConnection
from src.connections.hyperbolic_connection import HyperbolicConnection
from src.connections.youtube_connection import YouTubeConnection

logger = logging.getLogger("connection_manager")

class ConnectionManager:
def __init__(self, agent_config):
self.connections : Dict[str, BaseConnection] = {}
self.parent_agent = None
for config in agent_config:
self._register_connection(config)

Expand All @@ -36,6 +38,8 @@ def _class_name_to_type(class_name: str) -> Type[BaseConnection]:
return EchochambersConnection
elif class_name == "hyperbolic":
return HyperbolicConnection
elif class_name == "youtube":
return YouTubeConnection

return None

Expand All @@ -52,6 +56,7 @@ def _register_connection(self, config_dic: Dict[str, Any]) -> None:
name = config_dic["name"]
connection_class = self._class_name_to_type(name)
connection = connection_class(config_dic)
connection.connection_manager = self
self.connections[name] = connection
except Exception as e:
logging.error(f"Failed to initialize connection {name}: {e}")
Expand Down
Loading