Spaces:
Configuration error
Configuration error
Upload 8 files
Browse files- Dockerfile +20 -0
- README.md +178 -10
- agents.py +43 -0
- app.py +8 -0
- inference.py +19 -0
- openenv.yaml +1 -0
- requirements.txt +1 -0
- test_openenv.py +10 -0
Dockerfile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use lightweight Python
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
+
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Copy requirements first (better caching)
|
| 8 |
+
COPY requirements.txt .
|
| 9 |
+
|
| 10 |
+
# Install dependencies
|
| 11 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
+
|
| 13 |
+
# Copy all files
|
| 14 |
+
COPY . .
|
| 15 |
+
|
| 16 |
+
# Expose port (HF uses 7860 internally)
|
| 17 |
+
EXPOSE 7860
|
| 18 |
+
|
| 19 |
+
# Run OpenEnv app
|
| 20 |
+
CMD ["python", "-m", "openenv"]
|
README.md
CHANGED
|
@@ -1,10 +1,178 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Smart Career Advisor Agent (OpenEnv)
|
| 2 |
+
|
| 3 |
+
A lightweight **OpenEnv-compatible smart agent** that provides career guidance based on user interests, with intelligent suggestions and random exploration tips.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## Features
|
| 8 |
+
|
| 9 |
+
* Intent-based career suggestions (AI, Web, Data, Design)
|
| 10 |
+
* Smart agent behavior with structured responses
|
| 11 |
+
* Random growth tips for exploration
|
| 12 |
+
* Stateless design (OpenEnv compliant)
|
| 13 |
+
* Ready for Hugging Face Spaces deployment
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
## Project Structure
|
| 18 |
+
|
| 19 |
+
```
|
| 20 |
+
smart_agent_openenv/
|
| 21 |
+
│
|
| 22 |
+
├── inference.py # OpenEnv entrypoint (REQUIRED)
|
| 23 |
+
├── app.py # Application controller
|
| 24 |
+
├── agents.py # Smart agent logic
|
| 25 |
+
├── requirements.txt # Dependencies
|
| 26 |
+
├── openenv.yaml # OpenEnv config (optional)
|
| 27 |
+
├── Dockerfile # HF deployment
|
| 28 |
+
└── README.md
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
## Requirements
|
| 34 |
+
|
| 35 |
+
* Python **3.10 / 3.11 / 3.12**
|
| 36 |
+
* pip
|
| 37 |
+
* Git
|
| 38 |
+
|
| 39 |
+
---
|
| 40 |
+
|
| 41 |
+
## Installation
|
| 42 |
+
|
| 43 |
+
```bash
|
| 44 |
+
pip install -r requirements.txt
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
---
|
| 48 |
+
|
| 49 |
+
## Local Testing
|
| 50 |
+
|
| 51 |
+
Since CLI may not work on all systems, test manually:
|
| 52 |
+
|
| 53 |
+
```bash
|
| 54 |
+
python test_openenv.py
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
Or create a quick test:
|
| 58 |
+
|
| 59 |
+
```python
|
| 60 |
+
from inference import predict, reset
|
| 61 |
+
|
| 62 |
+
print(predict({"query": "I like AI"}))
|
| 63 |
+
print(reset())
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
---
|
| 67 |
+
|
| 68 |
+
## OpenEnv Contract
|
| 69 |
+
|
| 70 |
+
This project follows required OpenEnv structure:
|
| 71 |
+
|
| 72 |
+
* `inference.py` at root
|
| 73 |
+
* `predict(input_data)` function
|
| 74 |
+
* `reset()` function
|
| 75 |
+
* Stateless execution
|
| 76 |
+
|
| 77 |
+
---
|
| 78 |
+
|
| 79 |
+
## Docker Deployment (Hugging Face)
|
| 80 |
+
|
| 81 |
+
Build runs automatically on HF Spaces using Dockerfile.
|
| 82 |
+
|
| 83 |
+
### Steps:
|
| 84 |
+
|
| 85 |
+
1. Push code to GitHub
|
| 86 |
+
2. Go to Hugging Face Spaces
|
| 87 |
+
3. Create new Space:
|
| 88 |
+
|
| 89 |
+
* SDK → **Docker**
|
| 90 |
+
4. Connect repo or upload files
|
| 91 |
+
5. Wait for build
|
| 92 |
+
|
| 93 |
+
---
|
| 94 |
+
|
| 95 |
+
## Usage Example
|
| 96 |
+
|
| 97 |
+
Input:
|
| 98 |
+
|
| 99 |
+
```json
|
| 100 |
+
{
|
| 101 |
+
"query": "I am interested in AI"
|
| 102 |
+
}
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
Output:
|
| 106 |
+
|
| 107 |
+
```json
|
| 108 |
+
{
|
| 109 |
+
"output": {
|
| 110 |
+
"intent": "ai",
|
| 111 |
+
"careers": ["AI Engineer", "ML Engineer", "Deep Learning Engineer"],
|
| 112 |
+
"tip": "Build real-world projects",
|
| 113 |
+
"message": "Based on your interest in ai, these careers fit you."
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
---
|
| 119 |
+
|
| 120 |
+
## Common Issues & Fixes
|
| 121 |
+
|
| 122 |
+
### `openenv not recognized`
|
| 123 |
+
|
| 124 |
+
Use:
|
| 125 |
+
|
| 126 |
+
```bash
|
| 127 |
+
python -m pip install openenv-core
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
---
|
| 131 |
+
|
| 132 |
+
### `reset post failed`
|
| 133 |
+
|
| 134 |
+
✔ Ensure `reset()` exists in `inference.py`
|
| 135 |
+
|
| 136 |
+
---
|
| 137 |
+
|
| 138 |
+
### `inference.py not detected`
|
| 139 |
+
|
| 140 |
+
✔ File must be in root directory
|
| 141 |
+
|
| 142 |
+
---
|
| 143 |
+
|
| 144 |
+
### Python version issues
|
| 145 |
+
|
| 146 |
+
✔ Use Python 3.10–3.12 (avoid 3.13)
|
| 147 |
+
|
| 148 |
+
---
|
| 149 |
+
|
| 150 |
+
## Submission Steps
|
| 151 |
+
|
| 152 |
+
1. Build project using OpenEnv structure
|
| 153 |
+
2. Test locally
|
| 154 |
+
3. Push to GitHub
|
| 155 |
+
4. Deploy on Hugging Face Spaces
|
| 156 |
+
5. Submit Space URL
|
| 157 |
+
|
| 158 |
+
---
|
| 159 |
+
|
| 160 |
+
## Future Improvements
|
| 161 |
+
|
| 162 |
+
* Multi-agent system (planner + executor)
|
| 163 |
+
* Memory-based reasoning (vector / graph)
|
| 164 |
+
* Integration with LLM APIs
|
| 165 |
+
* Real-world problem solving agents
|
| 166 |
+
|
| 167 |
+
---
|
| 168 |
+
|
| 169 |
+
## Author
|
| 170 |
+
|
| 171 |
+
**Junaid Khan**
|
| 172 |
+
AI Researcher & Developer
|
| 173 |
+
|
| 174 |
+
---
|
| 175 |
+
|
| 176 |
+
## License
|
| 177 |
+
|
| 178 |
+
Open-source project for educational and experimental use.
|
agents.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
|
| 3 |
+
class SmartCareerAgent:
|
| 4 |
+
def __init__(self):
|
| 5 |
+
self.career_map = {
|
| 6 |
+
"ai": ["AI Engineer", "ML Engineer", "Deep Learning Engineer"],
|
| 7 |
+
"web": ["Frontend Developer", "Backend Developer", "Full Stack Developer"],
|
| 8 |
+
"data": ["Data Analyst", "Data Scientist", "Data Engineer"],
|
| 9 |
+
"design": ["UI/UX Designer", "Product Designer"]
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
self.tips = [
|
| 13 |
+
"Build real-world projects",
|
| 14 |
+
"Create a strong GitHub portfolio",
|
| 15 |
+
"Participate in hackathons",
|
| 16 |
+
"Learn problem-solving (DSA)",
|
| 17 |
+
"Follow industry trends"
|
| 18 |
+
]
|
| 19 |
+
|
| 20 |
+
def detect_intent(self, query):
|
| 21 |
+
query = query.lower()
|
| 22 |
+
for key in self.career_map:
|
| 23 |
+
if key in query:
|
| 24 |
+
return key
|
| 25 |
+
return "unknown"
|
| 26 |
+
|
| 27 |
+
def respond(self, query):
|
| 28 |
+
intent = self.detect_intent(query)
|
| 29 |
+
|
| 30 |
+
if intent != "unknown":
|
| 31 |
+
return {
|
| 32 |
+
"intent": intent,
|
| 33 |
+
"careers": self.career_map[intent],
|
| 34 |
+
"tip": random.choice(self.tips),
|
| 35 |
+
"message": f"Based on your interest in {intent}, these careers fit you."
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
return {
|
| 39 |
+
"intent": "unknown",
|
| 40 |
+
"careers": [],
|
| 41 |
+
"tip": random.choice(self.tips),
|
| 42 |
+
"message": "Please tell me your interest (AI, Web, Data, Design)."
|
| 43 |
+
}
|
app.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from agents import SmartCareerAgent
|
| 2 |
+
|
| 3 |
+
class SmartAgentApp:
|
| 4 |
+
def __init__(self):
|
| 5 |
+
self.agent = SmartCareerAgent()
|
| 6 |
+
|
| 7 |
+
def run(self, query):
|
| 8 |
+
return self.agent.respond(query)
|
inference.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from app import SmartAgentApp
|
| 2 |
+
|
| 3 |
+
app_instance = SmartAgentApp()
|
| 4 |
+
|
| 5 |
+
def predict(input_data):
|
| 6 |
+
query = input_data.get("query", "")
|
| 7 |
+
|
| 8 |
+
result = app_instance.run(query)
|
| 9 |
+
|
| 10 |
+
return {
|
| 11 |
+
"output": result
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def reset():
|
| 16 |
+
global app_instance
|
| 17 |
+
app_instance = SmartAgentApp()
|
| 18 |
+
|
| 19 |
+
return {"status": "reset successful"}
|
openenv.yaml
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
entrypoint: inference.py
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
openenv-core
|
test_openenv.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from inference import predict, reset
|
| 2 |
+
|
| 3 |
+
# Test predict
|
| 4 |
+
print("Testing predict...")
|
| 5 |
+
output = predict({"query": "I like AI"})
|
| 6 |
+
print(output)
|
| 7 |
+
|
| 8 |
+
# Test reset
|
| 9 |
+
print("Testing reset...")
|
| 10 |
+
print(reset())
|