-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path84_github_tools.py
More file actions
52 lines (40 loc) · 1.49 KB
/
84_github_tools.py
File metadata and controls
52 lines (40 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
"""
GitHub Tools -- search repos, read files, list issues from agents.
No API key needed (optional GITHUB_TOKEN increases rate limit from 60 to 5000/hr).
Read-only operations only.
Run: python examples/84_github_tools.py
"""
from selectools.toolbox.github_tools import github_get_file, github_list_issues, github_search_repos
print("=== GitHub Tools Example ===\n")
# Note: These tools make real API calls to GitHub.
# Uncomment to test:
# 1. Search repositories
# result = github_search_repos.function("python ai agent framework", max_results=3)
# print(f"Repos:\n{result}\n")
# 2. Get a file
# result = github_get_file.function("johnnichev/selectools", "README.md")
# print(f"File content:\n{result[:200]}...\n")
# 3. List issues
# result = github_list_issues.function("johnnichev/selectools", state="open", max_results=5)
# print(f"Issues:\n{result}\n")
# Show tool metadata
for tool in [github_search_repos, github_get_file, github_list_issues]:
print(f"{tool.name}:")
print(f" {tool.description}")
print()
print(
"""
--- Agent Pattern ---
from selectools import Agent
from selectools.providers import OpenAIProvider
from selectools.toolbox.github_tools import github_search_repos, github_get_file
agent = Agent(
tools=[github_search_repos, github_get_file],
provider=OpenAIProvider(),
)
result = agent.run("Find the top Python AI frameworks and read their README")
"""
)
print("Set GITHUB_TOKEN env var for higher rate limits (5000/hr vs 60/hr)")
print("Done!")