Spaces:
Sleeping
Sleeping
updates
Browse files
app.py
CHANGED
@@ -30,7 +30,7 @@ get_headers = {
|
|
30 |
}
|
31 |
|
32 |
|
33 |
-
def
|
34 |
|
35 |
class QueryHackerNews(BaseModel):
|
36 |
query: str = Field(..., description="The user query.")
|
@@ -129,17 +129,29 @@ def create_tools(cfg):
|
|
129 |
all_stories = '---------\n\n'.join(texts)
|
130 |
return summarize_text(all_stories)
|
131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
return (
|
133 |
-
tools_factory.
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
143 |
tools_factory.get_llama_index_tools("tavily_research", "TavilyToolSpec", api_key=cfg.tavily_api_key) +
|
144 |
tools_factory.standard_tools() +
|
145 |
tools_factory.guardrail_tools() +
|
@@ -166,7 +178,7 @@ def initialize_agent(_cfg):
|
|
166 |
st.session_state.log_messages.append(output)
|
167 |
|
168 |
agent = Agent(
|
169 |
-
tools=
|
170 |
topic="hacker news",
|
171 |
custom_instructions=bot_instructions,
|
172 |
update_func=update_func
|
|
|
30 |
}
|
31 |
|
32 |
|
33 |
+
def create_assistant_tools(cfg):
|
34 |
|
35 |
class QueryHackerNews(BaseModel):
|
36 |
query: str = Field(..., description="The user query.")
|
|
|
129 |
all_stories = '---------\n\n'.join(texts)
|
130 |
return summarize_text(all_stories)
|
131 |
|
132 |
+
def update_story(
|
133 |
+
story_id: str = Field(..., description="The story ID.")
|
134 |
+
) -> str:
|
135 |
+
"""
|
136 |
+
Update the story with the latest information.
|
137 |
+
Returns a string indicating that the story has been updated.
|
138 |
+
"""
|
139 |
+
title, story_url, external_link = get_story_details(story_id)
|
140 |
+
print(f"{title}: ({story_url})")
|
141 |
+
return "story updated!"
|
142 |
+
|
143 |
return (
|
144 |
+
[tools_factory.create_tool(tool) for tool in
|
145 |
+
[
|
146 |
+
get_top_stories,
|
147 |
+
get_show_stories,
|
148 |
+
get_ask_stories,
|
149 |
+
get_story_details,
|
150 |
+
get_story_text,
|
151 |
+
whats_new,
|
152 |
+
update_story, ### TEPM DEBUG
|
153 |
+
]
|
154 |
+
] +
|
155 |
tools_factory.get_llama_index_tools("tavily_research", "TavilyToolSpec", api_key=cfg.tavily_api_key) +
|
156 |
tools_factory.standard_tools() +
|
157 |
tools_factory.guardrail_tools() +
|
|
|
178 |
st.session_state.log_messages.append(output)
|
179 |
|
180 |
agent = Agent(
|
181 |
+
tools=create_assistant_tools(_cfg),
|
182 |
topic="hacker news",
|
183 |
custom_instructions=bot_instructions,
|
184 |
update_func=update_func
|