Spaces:
Running
Running
Lode Nachtergaele
commited on
Commit
·
6439c21
1
Parent(s):
ae7a494
get summary from repo
Browse files- app.py +32 -19
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,22 +1,35 @@
|
|
1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
2 |
import datetime
|
3 |
-
import
|
|
|
4 |
import pytz
|
5 |
import yaml
|
6 |
-
from
|
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
-
def
|
13 |
-
|
14 |
-
"""A tool that does nothing yet
|
15 |
Args:
|
16 |
-
|
17 |
-
|
|
|
|
|
18 |
"""
|
19 |
-
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -37,33 +50,33 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
37 |
final_answer = FinalAnswerTool()
|
38 |
|
39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
40 |
-
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
41 |
|
42 |
model = HfApiModel(
|
43 |
-
max_tokens=2096,
|
44 |
-
temperature=0.5,
|
45 |
-
model_id=
|
46 |
-
custom_role_conversions=None,
|
47 |
)
|
48 |
|
49 |
|
50 |
# Import tool from Hub
|
51 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
52 |
|
53 |
-
with open("prompts.yaml",
|
54 |
prompt_templates = yaml.safe_load(stream)
|
55 |
-
|
56 |
agent = CodeAgent(
|
57 |
model=model,
|
58 |
-
tools=[final_answer],
|
59 |
max_steps=6,
|
60 |
verbosity_level=1,
|
61 |
grammar=None,
|
62 |
planning_interval=None,
|
63 |
name=None,
|
64 |
description=None,
|
65 |
-
prompt_templates=prompt_templates
|
66 |
)
|
67 |
|
68 |
|
69 |
-
GradioUI(agent).launch()
|
|
|
|
|
1 |
import datetime
|
2 |
+
from dataclasses import dataclass
|
3 |
+
|
4 |
import pytz
|
5 |
import yaml
|
6 |
+
from gitingest import ingest
|
7 |
+
from smolagents import CodeAgent, HfApiModel, load_tool, tool
|
8 |
|
9 |
from Gradio_UI import GradioUI
|
10 |
+
from tools.final_answer import FinalAnswerTool
|
11 |
+
|
12 |
+
|
13 |
+
@dataclass
|
14 |
+
class RepoData:
|
15 |
+
summary: str
|
16 |
+
tree: str
|
17 |
+
content: str
|
18 |
+
|
19 |
|
20 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
21 |
@tool
|
22 |
+
def git_github_repo_summary(user: str, repo: str) -> str:
|
23 |
+
"""A tool that does nothing yet
|
|
|
24 |
Args:
|
25 |
+
user: the user of the github repository
|
26 |
+
repo: the name of the repository
|
27 |
+
Returns:
|
28 |
+
summary: a string with a summary of the github repository repo of user
|
29 |
"""
|
30 |
+
summary, tree, content = ingest(f"https://github.com/{user}/{repo}")
|
31 |
+
return summary
|
32 |
+
|
33 |
|
34 |
@tool
|
35 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
50 |
final_answer = FinalAnswerTool()
|
51 |
|
52 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
53 |
+
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
54 |
|
55 |
model = HfApiModel(
|
56 |
+
max_tokens=2096,
|
57 |
+
temperature=0.5,
|
58 |
+
model_id="Qwen/Qwen2.5-Coder-32B-Instruct", # it is possible that this model may be overloaded
|
59 |
+
custom_role_conversions=None,
|
60 |
)
|
61 |
|
62 |
|
63 |
# Import tool from Hub
|
64 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
65 |
|
66 |
+
with open("prompts.yaml", "r") as stream:
|
67 |
prompt_templates = yaml.safe_load(stream)
|
68 |
+
|
69 |
agent = CodeAgent(
|
70 |
model=model,
|
71 |
+
tools=[final_answer], ## add your tools here (don't remove final answer)
|
72 |
max_steps=6,
|
73 |
verbosity_level=1,
|
74 |
grammar=None,
|
75 |
planning_interval=None,
|
76 |
name=None,
|
77 |
description=None,
|
78 |
+
prompt_templates=prompt_templates,
|
79 |
)
|
80 |
|
81 |
|
82 |
+
GradioUI(agent).launch()
|
requirements.txt
CHANGED
@@ -3,3 +3,4 @@ smolagents
|
|
3 |
requests
|
4 |
duckduckgo_search
|
5 |
pandas
|
|
|
|
3 |
requests
|
4 |
duckduckgo_search
|
5 |
pandas
|
6 |
+
gitingest
|