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

Rename twitter toolkit. #1926

Merged
merged 389 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
389 commits
Select commit Hold shift + click to select a range
230ceff
README
ashpreetbedi Jan 15, 2025
e81ee51
README
ashpreetbedi Jan 15, 2025
2ab0398
Agno Agent
ashpreetbedi Jan 15, 2025
38fcee0
README
ashpreetbedi Jan 15, 2025
b510450
README
ashpreetbedi Jan 15, 2025
0a737c9
README
ashpreetbedi Jan 15, 2025
29e5b33
README
ashpreetbedi Jan 15, 2025
cee37ab
README
ashpreetbedi Jan 15, 2025
66ef924
README
ashpreetbedi Jan 15, 2025
de55bad
README
ashpreetbedi Jan 15, 2025
dcdff52
README
ashpreetbedi Jan 15, 2025
a238c9f
README
ashpreetbedi Jan 15, 2025
c672f04
README
ashpreetbedi Jan 15, 2025
15628f8
README
ashpreetbedi Jan 16, 2025
c70822e
README
ashpreetbedi Jan 16, 2025
89e6334
README
ashpreetbedi Jan 16, 2025
0d02fba
Remove content type
dirkbrnd Jan 16, 2025
74c762f
update-prd-resources-phi-2408 (#1799)
ysolanky Jan 16, 2025
ddba816
Fix workflows playground
dirkbrnd Jan 16, 2025
e1c9d80
Merge branch 'refactor/agno' of https://github.com/phidatahq/phidata …
dirkbrnd Jan 16, 2025
5d74ee1
Update
dirkbrnd Jan 16, 2025
a82caaf
Merge
dirkbrnd Jan 16, 2025
385865d
Update
dirkbrnd Jan 16, 2025
fd0f04b
Fix multimodal agents playground
dirkbrnd Jan 16, 2025
7478a45
Fix validate call (#1802)
willemcdejongh Jan 16, 2025
b725cbf
Fix style
dirkbrnd Jan 16, 2025
28a78c9
Update run response dump
dirkbrnd Jan 16, 2025
4b9eb6c
Refactor agno models (#1803)
dirkbrnd Jan 16, 2025
72f4f01
Revert (#1804)
dirkbrnd Jan 16, 2025
e98757b
Fix empty session_id handling (#1805)
willemcdejongh Jan 16, 2025
6207401
User agent session GET
dirkbrnd Jan 16, 2025
283c551
Update
dirkbrnd Jan 16, 2025
24f30bd
README
ashpreetbedi Jan 17, 2025
9ffe711
README
ashpreetbedi Jan 17, 2025
38d48f9
README
ashpreetbedi Jan 17, 2025
da25560
README
ashpreetbedi Jan 17, 2025
48b93a0
Agno Agent
ashpreetbedi Jan 17, 2025
6c09191
Playground API updates (#1808)
willemcdejongh Jan 17, 2025
f425b7b
fix-workflows (#1810)
ysolanky Jan 17, 2025
e8b0625
Audio and Video interface updates (#1783)
dirkbrnd Jan 17, 2025
b275ed1
Update
dirkbrnd Jan 17, 2025
c4272ae
Update
dirkbrnd Jan 17, 2025
c4d4845
Add desi vocals error handling
dirkbrnd Jan 17, 2025
0eef02d
Fix json validation error (#1815)
willemcdejongh Jan 17, 2025
e03d658
README
ashpreetbedi Jan 17, 2025
624ed5d
README
ashpreetbedi Jan 17, 2025
5f2069b
README
ashpreetbedi Jan 17, 2025
4e3d154
README
ashpreetbedi Jan 17, 2025
6b54532
README
ashpreetbedi Jan 17, 2025
488eb1d
README
ashpreetbedi Jan 17, 2025
d85a9d9
README
ashpreetbedi Jan 17, 2025
7dbd67c
Readme update (#1816)
dirkbrnd Jan 17, 2025
9bbcb46
README
ashpreetbedi Jan 17, 2025
e259eee
Update
dirkbrnd Jan 17, 2025
eb09c4a
Fix image in markdown (#1820)
anuragts Jan 17, 2025
746d939
README
ashpreetbedi Jan 18, 2025
0ee5347
Merge
dirkbrnd Jan 18, 2025
55c3d4b
Updates from 2.7.8
dirkbrnd Jan 18, 2025
104e549
Update
dirkbrnd Jan 18, 2025
9fdf0e7
README
ashpreetbedi Jan 18, 2025
d634b5f
README
ashpreetbedi Jan 19, 2025
1be2274
README
ashpreetbedi Jan 19, 2025
d2098ae
README
ashpreetbedi Jan 19, 2025
b5fb91f
README
ashpreetbedi Jan 19, 2025
7f8bff9
README
ashpreetbedi Jan 19, 2025
2ed387f
README
ashpreetbedi Jan 19, 2025
9883dcf
Update
dirkbrnd Jan 19, 2025
faeda88
Merge
dirkbrnd Jan 19, 2025
e0f6aa2
Merge
dirkbrnd Jan 19, 2025
cb8cfe1
README
ashpreetbedi Jan 19, 2025
e07b6c2
README
ashpreetbedi Jan 19, 2025
1e80ddf
Fix system role
ashpreetbedi Jan 19, 2025
b1c2a53
README
ashpreetbedi Jan 19, 2025
5f45ff8
README
ashpreetbedi Jan 19, 2025
c4fae5c
Use slots
ashpreetbedi Jan 19, 2025
42f5a3c
README
ashpreetbedi Jan 20, 2025
07b534f
README
ashpreetbedi Jan 20, 2025
8f96afc
Exceptions
ashpreetbedi Jan 20, 2025
1d5bd46
README
ashpreetbedi Jan 20, 2025
2261d63
Refactor agno models structure - Part 1 (#1823)
dirkbrnd Jan 20, 2025
8287094
Revert some changes from https://github.com/phidatahq/phidata/pull/18…
ashpreetbedi Jan 20, 2025
631a211
README
ashpreetbedi Jan 20, 2025
0d0ba91
Merge
dirkbrnd Jan 20, 2025
dd841be
Merge branch 'refactor/agno' of https://github.com/phidatahq/phidata …
dirkbrnd Jan 20, 2025
431e700
Refactor agno models structure - Part 2 (#1824)
dirkbrnd Jan 20, 2025
9d3e7c4
Merge branch 'refactor/agno' of https://github.com/phidatahq/phidata …
dirkbrnd Jan 20, 2025
ed3a2eb
Refactor/sort cookbooks (#1830)
willemcdejongh Jan 20, 2025
4527454
Fix issue in OpenAI
dirkbrnd Jan 20, 2025
263bf50
fix: remove (#1831)
anuragts Jan 20, 2025
d0372e2
Merge
dirkbrnd Jan 20, 2025
95ee9e5
Update
dirkbrnd Jan 20, 2025
0fcd7a3
Merge
dirkbrnd Jan 20, 2025
18a55b1
Further cookbook refactor
dirkbrnd Jan 20, 2025
52a4020
README
ashpreetbedi Jan 20, 2025
33623f2
Refactor/fix delete rename (#1818)
willemcdejongh Jan 20, 2025
46b0e52
README
ashpreetbedi Jan 20, 2025
10de13c
Fix show tool calls error (#1835)
ashpreetbedi Jan 20, 2025
0361c35
v0.0.3
ashpreetbedi Jan 20, 2025
15c2d8e
README
ashpreetbedi Jan 21, 2025
488c6b7
README
ashpreetbedi Jan 21, 2025
b6aced0
Update
dirkbrnd Jan 21, 2025
0e8934a
Merge branch 'refactor/agno' of https://github.com/phidatahq/phidata …
dirkbrnd Jan 21, 2025
c27a6f8
add-codeowners-phi-2438 (#1837)
ysolanky Jan 21, 2025
1fd397a
Merge branch 'refactor/agno' of https://github.com/phidatahq/phidata …
dirkbrnd Jan 21, 2025
aff0ded
Fix streamlit paperpal cookbook (#1841)
willemcdejongh Jan 21, 2025
91ed721
Merge branch 'main' of https://github.com/phidatahq/phidata into refa…
dirkbrnd Jan 21, 2025
520a3dd
Fix game workflow
dirkbrnd Jan 21, 2025
5b8efcd
issues-and-pull-requests-templates-phi-2439 (#1838)
ysolanky Jan 21, 2025
96a7ecd
Fixes for models
dirkbrnd Jan 21, 2025
af12059
Merge branch 'refactor/agno' of https://github.com/phidatahq/phidata …
dirkbrnd Jan 21, 2025
51f080a
Vector DB updates (#1842)
willemcdejongh Jan 21, 2025
7491d1d
Fix style
dirkbrnd Jan 21, 2025
126f302
Merge branch 'refactor/agno' of https://github.com/phidatahq/phidata …
dirkbrnd Jan 21, 2025
ae53bf5
streamlit app for game generator workflow (#1846)
Ayush0054 Jan 21, 2025
7c4280d
README
ashpreetbedi Jan 21, 2025
38a29ec
Update sys message formatting
ashpreetbedi Jan 21, 2025
24aeb6e
Fix system message state var formatting
ashpreetbedi Jan 21, 2025
382c413
README
ashpreetbedi Jan 21, 2025
2b073e8
v0.0.4
ashpreetbedi Jan 21, 2025
b4d23d2
README
ashpreetbedi Jan 21, 2025
fdec47e
v0.0.5
ashpreetbedi Jan 21, 2025
d62b374
README
ashpreetbedi Jan 21, 2025
f271e76
update-azure-openai-readme-phi-2442 (#1848)
ysolanky Jan 21, 2025
dce9e1d
PHI-2422 Update S3 buckets (#1847)
willemcdejongh Jan 21, 2025
07428e6
v0.0.6
ashpreetbedi Jan 22, 2025
3cda283
v0.0.6
ashpreetbedi Jan 22, 2025
48af605
Merge branch 'agno/v0.0.6' into refactor/agno
ashpreetbedi Jan 22, 2025
394a339
v0.0.7
ashpreetbedi Jan 22, 2025
31a496a
Fix: Make mongodb workflow storage class name consistent (#1853)
manthanguptaa Jan 22, 2025
86db451
Refactor/testing tools (#1856)
willemcdejongh Jan 22, 2025
0559bed
refactor/small-cookbook-updates (#1858)
willemcdejongh Jan 22, 2025
4be73bb
Fix vertex ai (#1844)
dirkbrnd Jan 22, 2025
75f63a4
Update team
dirkbrnd Jan 22, 2025
4a5e311
Merge branch 'refactor/agno' of https://github.com/phidatahq/phidata …
dirkbrnd Jan 22, 2025
cf2112c
Merge
dirkbrnd Jan 22, 2025
ff91a6c
README
ashpreetbedi Jan 22, 2025
e8db595
README
ashpreetbedi Jan 22, 2025
380abf8
v0.1.0
ashpreetbedi Jan 23, 2025
a575875
Style fix
dirkbrnd Jan 23, 2025
82a52ce
medical image diagnosis agent streamlit (#1862)
Ayush0054 Jan 23, 2025
5d40d14
Examples/ sql agent streamlit app (#1854)
Ayush0054 Jan 23, 2025
978132a
Fix teams and multimodal
dirkbrnd Jan 23, 2025
f732301
Merge branch 'refactor/agno' of https://github.com/phidatahq/phidata …
dirkbrnd Jan 23, 2025
f85af4b
Fix rag cookbooks (#1869)
manthanguptaa Jan 23, 2025
9079869
Fix hybrid search cookbook (#1870)
manthanguptaa Jan 23, 2025
0f4cdb9
Refactor: Move from model param to id for consistency (#1873)
manthanguptaa Jan 23, 2025
21291dd
Update Agent concepts readme (#1872)
willemcdejongh Jan 24, 2025
ca52ac0
Merge
dirkbrnd Jan 24, 2025
07d6869
fix: table name (#1879)
anuragts Jan 24, 2025
3618620
Fix public asset urls (#1880)
willemcdejongh Jan 24, 2025
3d68156
Reliability Evals (#1767)
manthanguptaa Jan 24, 2025
65161d7
Formatting fix
ashpreetbedi Jan 24, 2025
34718bf
ollama-streaming-fix-phi-2510 (#1876)
ysolanky Jan 24, 2025
7b49309
v0.1.1
ashpreetbedi Jan 24, 2025
2b51ef5
Update cookbook
ashpreetbedi Jan 24, 2025
ce2cf53
README
ashpreetbedi Jan 24, 2025
0cd5062
Movie Recommendation
ashpreetbedi Jan 24, 2025
0163ec6
README
ashpreetbedi Jan 25, 2025
2c15d4e
README
ashpreetbedi Jan 25, 2025
0eba81e
README
ashpreetbedi Jan 25, 2025
e09bc40
README
ashpreetbedi Jan 25, 2025
d4a5b6b
Examples/llmos (#1883)
Ayush0054 Jan 25, 2025
9591b87
update
dirkbrnd Jan 25, 2025
357d6c6
Merge
dirkbrnd Jan 25, 2025
a8116dd
Formatting
ashpreetbedi Jan 25, 2025
53cd19f
Update getting started cookbooks (#1881)
dirkbrnd Jan 25, 2025
897010f
Fix tool calls propagation to RunResponse (#1884)
ashpreetbedi Jan 25, 2025
c2c00ec
Update dependencies
ashpreetbedi Jan 25, 2025
888d8e6
Restructure cookbooks
ashpreetbedi Jan 25, 2025
3d4be62
README
ashpreetbedi Jan 26, 2025
81bede2
README
ashpreetbedi Jan 26, 2025
d4e2e9c
README
ashpreetbedi Jan 26, 2025
4a7754e
README
ashpreetbedi Jan 26, 2025
469b673
README
ashpreetbedi Jan 26, 2025
feae285
README
ashpreetbedi Jan 26, 2025
805339f
README
ashpreetbedi Jan 26, 2025
80ac48b
README
ashpreetbedi Jan 26, 2025
6dc3f63
README
ashpreetbedi Jan 26, 2025
cce24bb
README
ashpreetbedi Jan 26, 2025
21fd610
Sql Agent
ashpreetbedi Jan 26, 2025
46a4e3c
README
ashpreetbedi Jan 26, 2025
18c29fd
README
ashpreetbedi Jan 26, 2025
037cf21
README
ashpreetbedi Jan 27, 2025
44dee2c
v0.1.2
ashpreetbedi Jan 27, 2025
7e5da3c
README
ashpreetbedi Jan 27, 2025
aaf968b
fix: change model from deprecated model (#1896)
anuragts Jan 27, 2025
c858388
Update
dirkbrnd Jan 27, 2025
4b6f4f9
update-spinner-speed (#1895)
ysolanky Jan 27, 2025
01f6f4a
fix streamlit app readme (#1897)
Ayush0054 Jan 27, 2025
c2236af
reasoning-update-phi-2507 (#1875)
ysolanky Jan 27, 2025
5d90376
Groq Reasoning
ashpreetbedi Jan 27, 2025
314d83f
Merge branch 'main' of https://github.com/phidatahq/phidata into refa…
dirkbrnd Jan 27, 2025
f4eee2a
Update cookbook structure (#1899)
ashpreetbedi Jan 27, 2025
579dd4a
Merge
dirkbrnd Jan 27, 2025
61eeec1
Merge branch 'refactor/agno' of https://github.com/phidatahq/phidata …
dirkbrnd Jan 27, 2025
63c1844
Move geobuddy to apps
dirkbrnd Jan 27, 2025
1b7aa98
README
ashpreetbedi Jan 27, 2025
fbcc52f
Merge
dirkbrnd Jan 27, 2025
6e00093
Workflows cookbook (#1901)
manthanguptaa Jan 27, 2025
6f1f288
README
ashpreetbedi Jan 27, 2025
a1a01de
README
ashpreetbedi Jan 27, 2025
b9c9242
update-agentgetresponse-ag-2540 (#1902)
ysolanky Jan 27, 2025
38a9f5a
Add instructions in readme for cursor (#1900)
dirkbrnd Jan 27, 2025
50d264d
README
ashpreetbedi Jan 27, 2025
891d3a0
Refactor/image analyst (#1908)
willemcdejongh Jan 28, 2025
8e5879c
update
dirkbrnd Jan 28, 2025
512a953
update phidata to agno (#1903)
dirkbrnd Jan 28, 2025
e531ecb
fix: update instructions not to send image in response body (#1909)
anuragts Jan 28, 2025
81915d1
fix: remove voice id (#1913)
anuragts Jan 28, 2025
096a5ed
Move workflows_playground
dirkbrnd Jan 28, 2025
c11112a
README
ashpreetbedi Jan 28, 2025
f04a5de
workflow-description-update-ag-2541 (#1907)
ysolanky Jan 28, 2025
2451e7a
README
ashpreetbedi Jan 29, 2025
af6f703
arxiv-toolkit-update-ag-2549 (#1922)
ysolanky Jan 29, 2025
48f5da3
Rename twitter toolkit. WIP on updating features/testing
dirkbrnd Jan 29, 2025
a53b941
README
ashpreetbedi Jan 29, 2025
cbc04d5
Refactor MongoWorkflowStorage -> MongoDbWorkflowStorage (#1928)
manthanguptaa Jan 29, 2025
5dcb170
Logo update
ashpreetbedi Jan 29, 2025
d5c00e5
README
ashpreetbedi Jan 29, 2025
e8f73c6
README
ashpreetbedi Jan 29, 2025
0f10de6
Fix rename and delete regressions (#1923)
willemcdejongh Jan 29, 2025
ad6d1c6
README
ashpreetbedi Jan 29, 2025
281165b
README
ashpreetbedi Jan 29, 2025
9e678f3
Update workflows session to parse response_models (#1915)
dirkbrnd Jan 29, 2025
ea58834
Move and test all the TBD cookbooks (#1927)
dirkbrnd Jan 29, 2025
ee9a4a5
README
ashpreetbedi Jan 29, 2025
bbf2c8c
README
ashpreetbedi Jan 29, 2025
5ac9829
README.md
ashpreetbedi Jan 29, 2025
14de733
README
ashpreetbedi Jan 29, 2025
45b0da5
README
ashpreetbedi Jan 29, 2025
983ed4e
README
ashpreetbedi Jan 29, 2025
2613b1c
README
ashpreetbedi Jan 29, 2025
e0860b8
async-tool-calls-ag-2546 (#1921)
ysolanky Jan 29, 2025
6f429e2
v0.1.3
ashpreetbedi Jan 29, 2025
59624f1
README
ashpreetbedi Jan 29, 2025
1524da5
README
ashpreetbedi Jan 29, 2025
8a718b2
README
ashpreetbedi Jan 29, 2025
6a6580a
README
ashpreetbedi Jan 29, 2025
d055183
README
ashpreetbedi Jan 29, 2025
0897321
Merge branch 'refactor/agno' of https://github.com/phidatahq/phidata …
dirkbrnd Jan 29, 2025
d88cad8
Refactor vector db (#1924)
manthanguptaa Jan 29, 2025
17a3905
Examples/ agentic rag streamlit app (#1904)
Ayush0054 Jan 29, 2025
00a008b
Update cookbook
dirkbrnd Jan 29, 2025
895f884
Merge branch 'refactor/agno' of https://github.com/phidatahq/phidata …
dirkbrnd Jan 29, 2025
feadbad
Merge
dirkbrnd Jan 30, 2025
2265c63
Merge
dirkbrnd Jan 30, 2025
d48a0b4
Merge
dirkbrnd Jan 30, 2025
245353d
Update
dirkbrnd Jan 30, 2025
7be27c9
Merge branch 'main' into twitter-to-x
dirkbrnd Jan 30, 2025
43c6fd4
Merge branch 'main' into twitter-to-x
dirkbrnd Jan 31, 2025
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
1 change: 0 additions & 1 deletion cookbook/examples/agents/shopping_partner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.exa import ExaTools
from agno.tools.firecrawl import FirecrawlTools

agent = Agent(
name="shopping partner",
Expand Down
1 change: 1 addition & 0 deletions cookbook/examples/apps/agentic_rag/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
about_widget,
add_message,
display_tool_calls,

export_chat_history,
rename_session_widget,
session_selector_widget,
Expand Down
1 change: 0 additions & 1 deletion cookbook/examples/apps/agentic_rag/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def session_selector_widget(agent: Agent, model_id: str) -> None:
)
st.rerun()


def about_widget() -> None:
"""Display an about section in the sidebar"""
st.sidebar.markdown("---")
Expand Down
2 changes: 1 addition & 1 deletion cookbook/examples/apps/game_generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ source ~/.venvs/aienv/bin/activate
pip install -r cookbook/examples/apps/game_generator/requirements.txt
```

### 3. Export `OPENAI_API_KEY`
### 3. Export `OPENAI_API_KEY`

```shell
export OPENAI_API_KEY=sk-***
Expand Down
46 changes: 0 additions & 46 deletions cookbook/tools/twitter_tools.py

This file was deleted.

78 changes: 78 additions & 0 deletions cookbook/tools/x_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
from agno.agent import Agent
from agno.tools.x import XTools

"""
To set up an X developer account and obtain the necessary keys, follow these steps:

1. **Create an X Developer Account:**
- Go to the X Developer website: https://developer.x.com/
- Sign in with your X account or create a new one if you don't have an account.
- Apply for a developer account by providing the required information about your intended use of the X API.

2. **Create a Project and App:**
- Once your developer account is approved, log in to the X Developer portal.
- Navigate to the "Projects & Apps" section and create a new project.
- Within the project, create a new app. This app will be used to generate the necessary API keys and tokens.
- You'll get a client id and client secret, but you can ignore them.

3. **Generate API Keys, Tokens, and Client Credentials:**
- After creating the app, navigate to the "Keys and tokens" tab.
- Generate the following keys, tokens, and client credentials:
- **API Key (Consumer Key)**
- **API Secret Key (Consumer Secret)**
- **Bearer Token**
- **Access Token**
- **Access Token Secret**

4. **Set Environment Variables:**
- Export the generated keys, tokens, and client credentials as environment variables in your system or provide them as arguments to the `XTools` constructor.
- `X_CONSUMER_KEY`
- `X_CONSUMER_SECRET`
- `X_ACCESS_TOKEN`
- `X_ACCESS_TOKEN_SECRET`
- `X_BEARER_TOKEN`
"""


# Initialize the x toolkit
x_tools = XTools()

# Create an agent with the X toolkit
agent = Agent(
instructions=[
"Use your tools to interact with X (Twitter) as the authorized user @AgnoAgi",
"When asked to create a post, generate appropriate content based on the request",
"Do not actually post content unless explicitly instructed to do so",
"Provide informative responses about the user's timeline and posts",
"Respect X's usage policies and rate limits",
],
tools=[x_tools],
show_tool_calls=True,
debug_mode=True,
)

# Example usage: Get your details
agent.print_response("Can you return my x profile with my home timeline?", markdown=True)

# # Example usage: Get information about a user
# agent.print_response(
# "Can you retrieve information about this user https://x.com/AgnoAgi ",
# markdown=True,
# )

# # Example usage: Reply To a Post
# agent.print_response(
# "Can you reply to this [post ID] post as a general message as to how great this project is: https://x.com/AgnoAgi",
# markdown=True,
# )

# # Example usage: Send a direct message
# agent.print_response(
# "Send direct message to the user @AgnoAgi telling them I want to learn more about them and a link to their community.",
# markdown=True,
# )

# # Example usage: Create a new post
# agent.print_response("Create & post content about how 2025 is the year of the AI agent", markdown=True)


63 changes: 30 additions & 33 deletions libs/agno/agno/tools/twitter.py → libs/agno/agno/tools/x.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
raise ImportError("`tweepy` not installed. Please install using `pip install tweepy`.")


class TwitterTools(Toolkit):
class XTools(Toolkit):
def __init__(
self,
bearer_token: Optional[str] = None,
Expand All @@ -21,7 +21,7 @@ def __init__(
access_token_secret: Optional[str] = None,
):
"""
Initialize the TwitterTools.
Initialize the XTools.

Args:
bearer_token Optional[str]: The bearer token for Twitter API.
Expand All @@ -30,13 +30,13 @@ def __init__(
access_token Optional[str]: The access token for Twitter API.
access_token_secret Optional[str]: The access token secret for Twitter API.
"""
super().__init__(name="twitter")
super().__init__(name="x")

self.bearer_token = bearer_token or os.getenv("TWITTER_BEARER_TOKEN")
self.consumer_key = consumer_key or os.getenv("TWITTER_CONSUMER_KEY")
self.consumer_secret = consumer_secret or os.getenv("TWITTER_CONSUMER_SECRET")
self.access_token = access_token or os.getenv("TWITTER_ACCESS_TOKEN")
self.access_token_secret = access_token_secret or os.getenv("TWITTER_ACCESS_TOKEN_SECRET")
self.bearer_token = bearer_token or os.getenv("X_BEARER_TOKEN")
self.consumer_key = consumer_key or os.getenv("X_CONSUMER_KEY")
self.consumer_secret = consumer_secret or os.getenv("X_CONSUMER_SECRET")
self.access_token = access_token or os.getenv("X_ACCESS_TOKEN")
self.access_token_secret = access_token_secret or os.getenv("X_ACCESS_TOKEN_SECRET")

self.client = tweepy.Client(
bearer_token=self.bearer_token,
Expand All @@ -45,62 +45,59 @@ def __init__(
access_token=self.access_token,
access_token_secret=self.access_token_secret,
)
self.auth = tweepy.OAuth1UserHandler(
self.consumer_key, self.consumer_secret, self.access_token, self.access_token_secret
)
self.api = tweepy.API(self.auth)
self.register(self.create_tweet)
self.register(self.reply_to_tweet)

self.register(self.create_post)
self.register(self.reply_to_post)
self.register(self.send_dm)
self.register(self.get_user_info)
self.register(self.get_home_timeline)

def create_tweet(self, text: str) -> str:
def create_post(self, text: str) -> str:
"""
Create a new tweet.
Create a new X post.

Args:
text (str): The content of the tweet to create.
text (str): The content of the post to create.

Returns:
A JSON-formatted string containing the response from Twitter API with the created tweet details,
or an error message if the tweet creation fails.
A JSON-formatted string containing the response from X API (Twitter API) with the created post details,
or an error message if the post creation fails.
"""
logger.debug(f"Attempting to create tweet with text: {text}")
logger.debug(f"Attempting to create post with text: {text}")
try:
response = self.client.create_tweet(text=text)
tweet_id = response.data["id"]
post_id = response.data["id"]
user = self.client.get_me().data
tweet_url = f"https://twitter.com/{user.username}/status/{tweet_id}"
post_url = f"https://x.com/{user.username}/status/{post_id}"

result = {"message": "Tweet successfully posted!", "url": tweet_url}
result = {"message": "Post successfully created!", "url": post_url}
return json.dumps(result, indent=2)
except tweepy.TweepyException as e:
logger.error(f"Error creating tweet: {e}")
logger.error(f"Error creating post: {e}")
return json.dumps({"error": str(e)})

def reply_to_tweet(self, tweet_id: str, text: str) -> str:
def reply_to_post(self, post_id: str, text: str) -> str:
"""
Reply to an existing tweet.
Reply to an existing post.

Args:
tweet_id (str): The ID of the tweet to reply to.
text (str): The content of the reply tweet.
post_id (str): The ID of the post to reply to.
text (str): The content of the reply post.

Returns:
A JSON-formatted string containing the response from Twitter API with the reply tweet details,
A JSON-formatted string containing the response from Twitter API with the reply post details,
or an error message if the reply fails.
"""
logger.debug(f"Attempting to reply to {tweet_id} with text {text}")
logger.debug(f"Attempting to reply to {post_id} with text {text}")
try:
response = self.client.create_tweet(text=text, in_reply_to_tweet_id=tweet_id)
response = self.client.create_tweet(text=text, in_reply_to_tweet_id=post_id)
reply_id = response.data["id"]
user = self.client.get_me().data
reply_url = f"https://twitter.com/{user.username}/status/{reply_id}"
result = {"message": "Reply successfully posted!", "url": reply_url}
return json.dumps(result, indent=2)
except tweepy.TweepyException as e:
logger.error(f"Error replying to tweet: {e}")
logger.error(f"Error replying to post: {e}")
return json.dumps({"error": str(e)})

def send_dm(self, recipient: str, text: str) -> str:
Expand Down Expand Up @@ -136,7 +133,7 @@ def send_dm(self, recipient: str, text: str) -> str:
}
return json.dumps(result, indent=2)
except tweepy.TweepyException as e:
logger.error(f"Error sending DM: {e}")
logger.error(f"Error from X while sending DM: {e}")
error_message = str(e)
if "User not found" in error_message:
error_message = f"User '{recipient}' not found. Please check the username or user ID."
Expand Down
1 change: 0 additions & 1 deletion libs/agno/agno/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def dataclass_to_dict(dataclass_object, exclude: Optional[set[str]] = None, excl

def nested_model_dump(value):
from pydantic import BaseModel

if isinstance(value, BaseModel):
return value.model_dump()
elif isinstance(value, dict):
Expand Down