HF
Browse files- __pycache__/app.cpython-312.pyc +0 -0
- app.py +53 -7
- test_research.py +15 -7
- tools/__pycache__/blog_tools.cpython-312.pyc +0 -0
- tools/blog_tools.py +4 -4
__pycache__/app.cpython-312.pyc
CHANGED
Binary files a/__pycache__/app.cpython-312.pyc and b/__pycache__/app.cpython-312.pyc differ
|
|
app.py
CHANGED
@@ -13,7 +13,32 @@ def generate_blog_outline(topic: str) -> str:
|
|
13 |
Args:
|
14 |
topic: The main topic for the blog post
|
15 |
"""
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
@tool
|
19 |
def suggest_blog_topics(main_theme: str) -> str:
|
@@ -21,7 +46,28 @@ def suggest_blog_topics(main_theme: str) -> str:
|
|
21 |
Args:
|
22 |
main_theme: The primary theme or area of interest
|
23 |
"""
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
@tool
|
27 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -44,16 +90,16 @@ def research_topic(query: str) -> str:
|
|
44 |
"""
|
45 |
try:
|
46 |
# Create a fresh instance for each search
|
47 |
-
search_tool = DuckDuckGoSearchTool(max_results=5
|
48 |
|
49 |
# Add focus on tech and AI product development
|
50 |
-
enhanced_query = f"{query} AI product development
|
51 |
results = search_tool.forward(enhanced_query)
|
52 |
|
53 |
# Format the results in your style
|
54 |
-
response = f"
|
55 |
response += results
|
56 |
-
response += "\n\nNote:
|
57 |
|
58 |
return response
|
59 |
except Exception as e:
|
@@ -62,7 +108,7 @@ def research_topic(query: str) -> str:
|
|
62 |
final_answer = FinalAnswerTool()
|
63 |
|
64 |
model = HfApiModel(
|
65 |
-
max_tokens=2096
|
66 |
temperature=0.7, # Slightly increased for more natural, conversational tone
|
67 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
68 |
custom_role_conversions=None,
|
|
|
13 |
Args:
|
14 |
topic: The main topic for the blog post
|
15 |
"""
|
16 |
+
try:
|
17 |
+
# Research the topic first
|
18 |
+
search_tool = DuckDuckGoSearchTool(max_results=2)
|
19 |
+
research = search_tool.forward(f"{topic} key aspects challenges solutions")
|
20 |
+
|
21 |
+
# Create an outline based on research and expertise
|
22 |
+
outline = f"# Blog Outline: {topic}\n\n"
|
23 |
+
outline += "## 1. Introduction\n"
|
24 |
+
outline += "- Context and why this matters\n"
|
25 |
+
outline += "- My experience with this topic\n\n"
|
26 |
+
outline += "## 2. Current State\n"
|
27 |
+
outline += "- Key developments\n"
|
28 |
+
outline += "- Market trends\n\n"
|
29 |
+
outline += "## 3. Practical Insights\n"
|
30 |
+
outline += "- Real-world applications\n"
|
31 |
+
outline += "- Lessons from implementation\n\n"
|
32 |
+
outline += "## 4. Looking Forward\n"
|
33 |
+
outline += "- Next steps\n"
|
34 |
+
outline += "- Recommendations\n\n"
|
35 |
+
outline += "## 5. Key Takeaways\n"
|
36 |
+
outline += "- Action items\n"
|
37 |
+
outline += "- Discussion points\n"
|
38 |
+
|
39 |
+
return outline
|
40 |
+
except Exception as e:
|
41 |
+
return f"Error generating outline: {str(e)}"
|
42 |
|
43 |
@tool
|
44 |
def suggest_blog_topics(main_theme: str) -> str:
|
|
|
46 |
Args:
|
47 |
main_theme: The primary theme or area of interest
|
48 |
"""
|
49 |
+
try:
|
50 |
+
# Research current trends
|
51 |
+
search_tool = DuckDuckGoSearchTool(max_results=2)
|
52 |
+
research = search_tool.forward(f"{main_theme} latest developments challenges")
|
53 |
+
|
54 |
+
# Generate topic suggestions based on research and expertise
|
55 |
+
suggestions = f"# Blog Topic Ideas: {main_theme}\n\n"
|
56 |
+
suggestions += "Based on current trends and my product experience:\n\n"
|
57 |
+
suggestions += "1. Practical Implementation:\n"
|
58 |
+
suggestions += " - Building scalable {main_theme} solutions\n"
|
59 |
+
suggestions += " - Real-world challenges and solutions\n\n"
|
60 |
+
suggestions += "2. Product Strategy:\n"
|
61 |
+
suggestions += " - Market fit and user needs\n"
|
62 |
+
suggestions += " - Integration approaches\n\n"
|
63 |
+
suggestions += "3. Future Outlook:\n"
|
64 |
+
suggestions += " - Emerging trends\n"
|
65 |
+
suggestions += " - Potential impact\n\n"
|
66 |
+
suggestions += "\nThese topics combine current research with hands-on insights."
|
67 |
+
|
68 |
+
return suggestions
|
69 |
+
except Exception as e:
|
70 |
+
return f"Error suggesting topics: {str(e)}"
|
71 |
|
72 |
@tool
|
73 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
90 |
"""
|
91 |
try:
|
92 |
# Create a fresh instance for each search
|
93 |
+
search_tool = DuckDuckGoSearchTool(max_results=3) # Reduced from 5 to 3
|
94 |
|
95 |
# Add focus on tech and AI product development
|
96 |
+
enhanced_query = f"{query} AI product development" # Shortened query
|
97 |
results = search_tool.forward(enhanced_query)
|
98 |
|
99 |
# Format the results in your style
|
100 |
+
response = f"Quick research on {query}:\n\n"
|
101 |
response += results
|
102 |
+
response += "\n\nNote: Always verify current info."
|
103 |
|
104 |
return response
|
105 |
except Exception as e:
|
|
|
108 |
final_answer = FinalAnswerTool()
|
109 |
|
110 |
model = HfApiModel(
|
111 |
+
max_tokens=1000, # Reduced from 2096 to stay within limits
|
112 |
temperature=0.7, # Slightly increased for more natural, conversational tone
|
113 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
114 |
custom_role_conversions=None,
|
test_research.py
CHANGED
@@ -1,11 +1,19 @@
|
|
1 |
-
from app import agent
|
2 |
|
3 |
-
def
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
print(research_results)
|
9 |
|
10 |
if __name__ == "__main__":
|
11 |
-
|
|
|
1 |
+
from app import agent, generate_blog_outline, suggest_blog_topics
|
2 |
|
3 |
+
def test_blog_tools():
|
4 |
+
topic = "AI image model development"
|
5 |
+
|
6 |
+
print("\n=== Testing Blog Outline Generation ===")
|
7 |
+
outline = generate_blog_outline(topic)
|
8 |
+
print(outline)
|
9 |
+
|
10 |
+
print("\n=== Testing Topic Suggestions ===")
|
11 |
+
suggestions = suggest_blog_topics(topic)
|
12 |
+
print(suggestions)
|
13 |
+
|
14 |
+
print("\n=== Testing Research ===")
|
15 |
+
research_results = agent.run("Research latest trends in AI image model development and provide key insights")
|
16 |
print(research_results)
|
17 |
|
18 |
if __name__ == "__main__":
|
19 |
+
test_blog_tools()
|
tools/__pycache__/blog_tools.cpython-312.pyc
CHANGED
Binary files a/tools/__pycache__/blog_tools.cpython-312.pyc and b/tools/__pycache__/blog_tools.cpython-312.pyc differ
|
|
tools/blog_tools.py
CHANGED
@@ -21,17 +21,17 @@ def generate_blog_section(topic: str, section_title: str) -> str:
|
|
21 |
section_title: The title of the section to generate
|
22 |
"""
|
23 |
# First, get some background information
|
24 |
-
search_tool = DuckDuckGoSearchTool(max_results=
|
25 |
try:
|
26 |
search_query = f"{topic} {section_title}"
|
27 |
research = search_tool.forward(search_query)
|
28 |
|
29 |
# Format the content in your style
|
30 |
content = f"# {section_title}\n\n"
|
31 |
-
content += f"
|
32 |
-
content += f"
|
33 |
content += f"{research}\n\n"
|
34 |
-
content += "
|
35 |
|
36 |
return content
|
37 |
except Exception as e:
|
|
|
21 |
section_title: The title of the section to generate
|
22 |
"""
|
23 |
# First, get some background information
|
24 |
+
search_tool = DuckDuckGoSearchTool(max_results=2)
|
25 |
try:
|
26 |
search_query = f"{topic} {section_title}"
|
27 |
research = search_tool.forward(search_query)
|
28 |
|
29 |
# Format the content in your style
|
30 |
content = f"# {section_title}\n\n"
|
31 |
+
content += f"Here's my take on {topic}, focusing on {section_title}. "
|
32 |
+
content += f"From my experience in AI products:\n\n"
|
33 |
content += f"{research}\n\n"
|
34 |
+
content += "Questions? Let's discuss."
|
35 |
|
36 |
return content
|
37 |
except Exception as e:
|