dtka commited on
Commit
8f460b8
·
1 Parent(s): f6899df

Adding economic forcast agent

Browse files
Files changed (5) hide show
  1. .gitignore +11 -0
  2. Dockerfile +13 -0
  3. agent.yaml +15 -0
  4. app.py +51 -0
  5. requirements.txt +3 -0
.gitignore ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # virtual environment
2
+ venv/
3
+
4
+ # environment variables
5
+ .env
6
+
7
+ # build
8
+ build/
9
+
10
+ # logs
11
+ logs/
Dockerfile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install dependencies
6
+ COPY requirements.txt .
7
+ RUN pip install --no-cache-dir -r requirements.txt
8
+
9
+ # Copy the rest of your code
10
+ COPY . .
11
+
12
+ # Expose the agent on port 7860
13
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
agent.yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: collective-intelligence-economic-forecast-agent
2
+ description: |
3
+ An MCP agent that evaluates the economic impact of environmental or crisis scenarios.
4
+ Part of the Collective Intelligence Network project.
5
+ authors:
6
+ - name: Dushyant Kashyap
7
+ tags:
8
+ - mcp
9
+ - agent
10
+ - economic
11
+ - forecast
12
+ parameters:
13
+ - name: input
14
+ type: string
15
+ description: Description of an environmental or socio-political scenario.
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from pydantic import BaseModel
3
+
4
+ app = FastAPI()
5
+
6
+ class InputData(BaseModel):
7
+ input: str
8
+
9
+ @app.post("/agent")
10
+ async def run_agent(data: InputData):
11
+ text = data.input.lower()
12
+
13
+ if "flood" in text or "storm" in text:
14
+ impact = {
15
+ "estimated_gdp_loss_percent": 1.5,
16
+ "sectors_affected": ["agriculture", "logistics", "insurance"],
17
+ "recovery_time_months": 6,
18
+ "notes": "Flooding likely to disrupt food supply chains and increase insurance claims."
19
+ }
20
+ elif "heatwave" in text or "wildfire" in text:
21
+ impact = {
22
+ "estimated_gdp_loss_percent": 0.8,
23
+ "sectors_affected": ["energy", "healthcare", "construction"],
24
+ "recovery_time_months": 4,
25
+ "notes": "Heatwaves increase healthcare load and reduce construction productivity."
26
+ }
27
+ elif "pollution" in text or "emissions" in text:
28
+ impact = {
29
+ "estimated_gdp_loss_percent": 0.3,
30
+ "sectors_affected": ["manufacturing", "public health"],
31
+ "recovery_time_months": 2,
32
+ "notes": "Pollution regulations may temporarily reduce industrial output but save long-term healthcare costs."
33
+ }
34
+ else:
35
+ impact = {
36
+ "estimated_gdp_loss_percent": 0.1,
37
+ "sectors_affected": ["general"],
38
+ "recovery_time_months": 1,
39
+ "notes": "No significant economic disruption detected. Monitoring advised."
40
+ }
41
+
42
+ return {
43
+ "output": {
44
+ "economic_impact_forecast": impact,
45
+ "summary": f"Forecast generated for scenario: '{data.input[:50]}...'"
46
+ }
47
+ }
48
+
49
+ @app.get("/")
50
+ async def healthcheck():
51
+ return {"message": "Economic Forecast Agent is alive"}
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ fastapi==0.110.0
2
+ uvicorn==0.29.0
3
+ pydantic==2.6.4