Upload 3 files
Browse files- .env +1 -0
- app.py +51 -0
- requirements.txt +6 -0
.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
GROQ_API_KEY=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
|
app.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from dotenv import load_dotenv
|
| 3 |
+
from phi.agent import Agent
|
| 4 |
+
from phi.model.groq import Groq
|
| 5 |
+
from phi.tools.duckduckgo import DuckDuckGo
|
| 6 |
+
|
| 7 |
+
# Load environment variables (for API key)
|
| 8 |
+
load_dotenv()
|
| 9 |
+
|
| 10 |
+
# Initialize Groq model
|
| 11 |
+
model = Groq(id="llama3-70b-8192")
|
| 12 |
+
|
| 13 |
+
# Agent 1: Homework Helper Agent (academic help + web search)
|
| 14 |
+
homework_helper_agent = Agent(
|
| 15 |
+
name="HomeworkHelperAgent",
|
| 16 |
+
model=model,
|
| 17 |
+
tools=[DuckDuckGo()],
|
| 18 |
+
instructions=["Give clear and simple academic explanations. Always include sources if searched."],
|
| 19 |
+
show_tool_calls=True,
|
| 20 |
+
markdown=True,
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# Agent 2: Study Tips Coach Agent (motivation, schedules, tips)
|
| 24 |
+
study_tips_coach_agent = Agent(
|
| 25 |
+
name="StudyTipsCoachAgent",
|
| 26 |
+
model=model,
|
| 27 |
+
instructions=["Give encouraging and practical study tips. Include examples where possible."],
|
| 28 |
+
markdown=True,
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
# Function to decide which agent should respond
|
| 32 |
+
def study_buddy_ai(user_prompt):
|
| 33 |
+
academic_keywords = ["explain", "what is", "define", "solve", "difference", "example", "describe"]
|
| 34 |
+
if any(keyword in user_prompt.lower() for keyword in academic_keywords):
|
| 35 |
+
response = homework_helper_agent.run(user_prompt)
|
| 36 |
+
else:
|
| 37 |
+
response = study_tips_coach_agent.run(user_prompt)
|
| 38 |
+
return response.content
|
| 39 |
+
|
| 40 |
+
# CLI loop
|
| 41 |
+
if __name__ == "__main__":
|
| 42 |
+
print("π Welcome to Study Buddy AI!")
|
| 43 |
+
print("Ask anything about your studies or study tips. Type 'exit' to quit.")
|
| 44 |
+
|
| 45 |
+
while True:
|
| 46 |
+
user_input = input("\nπ©βπ You: ")
|
| 47 |
+
if user_input.lower() in ["exit", "quit"]:
|
| 48 |
+
print("π Goodbye! Keep learning and stay productive!")
|
| 49 |
+
break
|
| 50 |
+
response = study_buddy_ai(user_input)
|
| 51 |
+
print("\nπ€ Study Buddy AI:\n" + response)
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
phidata
|
| 2 |
+
groq
|
| 3 |
+
duckduckgo-search
|
| 4 |
+
python-dotenv
|
| 5 |
+
phi
|
| 6 |
+
|