Spaces:
Sleeping
Sleeping
build: configure multi-mode deployment and fix HF Space build errors
Browse files- Dockerfile +14 -3
- README.md +10 -0
- __pycache__/inference.cpython-311.pyc +0 -0
- app.py +12 -2
- email_env_openenv.egg-info/PKG-INFO +9 -0
- email_env_openenv.egg-info/SOURCES.txt +13 -0
- email_env_openenv.egg-info/dependency_links.txt +1 -0
- email_env_openenv.egg-info/entry_points.txt +2 -0
- email_env_openenv.egg-info/requires.txt +5 -0
- email_env_openenv.egg-info/top_level.txt +5 -0
- pyproject.toml +19 -0
- tasks.py +19 -3
- uv.lock +0 -0
Dockerfile
CHANGED
|
@@ -1,9 +1,20 @@
|
|
| 1 |
-
FROM python:3.
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
COPY . .
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
CMD
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Install uv
|
| 6 |
+
RUN pip install --no-cache-dir uv
|
| 7 |
+
|
| 8 |
+
# Copy project files
|
| 9 |
COPY . .
|
| 10 |
|
| 11 |
+
# Install dependencies using uv
|
| 12 |
+
# --frozen ensures we use the uv.lock file
|
| 13 |
+
RUN uv sync --frozen
|
| 14 |
+
|
| 15 |
+
# Expose port for FastAPI
|
| 16 |
+
EXPOSE 7860
|
| 17 |
|
| 18 |
+
# CMD runs the API server via the entry point defined in pyproject.toml
|
| 19 |
+
# "server" points to app:start_server
|
| 20 |
+
CMD ["uv", "run", "server"]
|
README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Email Triage AI Environment (OpenEnv)
|
| 2 |
|
| 3 |
## Overview
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Email Triage Agent
|
| 3 |
+
emoji: 📧
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: gray
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
app_port: 7860
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
# Email Triage AI Environment (OpenEnv)
|
| 12 |
|
| 13 |
## Overview
|
__pycache__/inference.cpython-311.pyc
ADDED
|
Binary file (4.57 kB). View file
|
|
|
app.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from env import EmailEnv
|
|
|
|
| 3 |
|
| 4 |
app = FastAPI()
|
| 5 |
-
|
| 6 |
env = EmailEnv()
|
| 7 |
|
| 8 |
@app.post("/reset")
|
|
@@ -23,4 +23,14 @@ def step(action: dict):
|
|
| 23 |
|
| 24 |
@app.get("/")
|
| 25 |
def root():
|
| 26 |
-
return {"message": "Email Env is running"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from env import EmailEnv
|
| 3 |
+
from inference import run_inference
|
| 4 |
|
| 5 |
app = FastAPI()
|
|
|
|
| 6 |
env = EmailEnv()
|
| 7 |
|
| 8 |
@app.post("/reset")
|
|
|
|
| 23 |
|
| 24 |
@app.get("/")
|
| 25 |
def root():
|
| 26 |
+
return {"message": "Email Env is running"}
|
| 27 |
+
|
| 28 |
+
def start_server():
|
| 29 |
+
import uvicorn
|
| 30 |
+
uvicorn.run("app:app", host="0.0.0.0", port=7860)
|
| 31 |
+
|
| 32 |
+
def main():
|
| 33 |
+
run_inference()
|
| 34 |
+
|
| 35 |
+
if __name__ == "__main__":
|
| 36 |
+
main()
|
email_env_openenv.egg-info/PKG-INFO
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: email-env-openenv
|
| 3 |
+
Version: 0.1.0
|
| 4 |
+
Summary: Email Triage AI Environment for Hackathon
|
| 5 |
+
Requires-Dist: openai
|
| 6 |
+
Requires-Dist: pydantic
|
| 7 |
+
Requires-Dist: openenv-core>=0.2.0
|
| 8 |
+
Requires-Dist: fastapi
|
| 9 |
+
Requires-Dist: uvicorn
|
email_env_openenv.egg-info/SOURCES.txt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
README.md
|
| 2 |
+
app.py
|
| 3 |
+
env.py
|
| 4 |
+
inference.py
|
| 5 |
+
models.py
|
| 6 |
+
pyproject.toml
|
| 7 |
+
tasks.py
|
| 8 |
+
email_env_openenv.egg-info/PKG-INFO
|
| 9 |
+
email_env_openenv.egg-info/SOURCES.txt
|
| 10 |
+
email_env_openenv.egg-info/dependency_links.txt
|
| 11 |
+
email_env_openenv.egg-info/entry_points.txt
|
| 12 |
+
email_env_openenv.egg-info/requires.txt
|
| 13 |
+
email_env_openenv.egg-info/top_level.txt
|
email_env_openenv.egg-info/dependency_links.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
email_env_openenv.egg-info/entry_points.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[console_scripts]
|
| 2 |
+
server = app:start_server
|
email_env_openenv.egg-info/requires.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
openai
|
| 2 |
+
pydantic
|
| 3 |
+
openenv-core>=0.2.0
|
| 4 |
+
fastapi
|
| 5 |
+
uvicorn
|
email_env_openenv.egg-info/top_level.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
app
|
| 2 |
+
env
|
| 3 |
+
inference
|
| 4 |
+
models
|
| 5 |
+
tasks
|
pyproject.toml
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
[build-system]
|
| 2 |
requires = ["setuptools>=42", "wheel"]
|
| 3 |
build-backend = "setuptools.build_meta"
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
[tool.hf.metadata]
|
| 6 |
sdk = "docker"
|
| 7 |
app_file = "app.py"
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "email-env-openenv"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
description = "Email Triage AI Environment for Hackathon"
|
| 5 |
+
dependencies = [
|
| 6 |
+
"openai",
|
| 7 |
+
"pydantic",
|
| 8 |
+
"openenv-core>=0.2.0",
|
| 9 |
+
"fastapi",
|
| 10 |
+
"uvicorn"
|
| 11 |
+
]
|
| 12 |
+
|
| 13 |
+
[project.scripts]
|
| 14 |
+
server = "app:start_server"
|
| 15 |
+
|
| 16 |
[build-system]
|
| 17 |
requires = ["setuptools>=42", "wheel"]
|
| 18 |
build-backend = "setuptools.build_meta"
|
| 19 |
|
| 20 |
+
[tool.setuptools]
|
| 21 |
+
py-modules = ["app", "env", "inference", "models", "tasks"]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
[tool.hf.metadata]
|
| 25 |
sdk = "docker"
|
| 26 |
app_file = "app.py"
|
tasks.py
CHANGED
|
@@ -6,13 +6,28 @@ def get_sample_emails():
|
|
| 6 |
]
|
| 7 |
|
| 8 |
def task_easy():
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
def task_medium():
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
def task_hard():
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def grade_task(predicted_actions: list, expected_actions: list) -> float:
|
| 18 |
if not expected_actions:
|
|
@@ -21,3 +36,4 @@ def grade_task(predicted_actions: list, expected_actions: list) -> float:
|
|
| 21 |
total = len(expected_actions)
|
| 22 |
correct = sum(1 for p, e in zip(predicted_actions, expected_actions) if p == e)
|
| 23 |
return correct / total
|
|
|
|
|
|
| 6 |
]
|
| 7 |
|
| 8 |
def task_easy():
|
| 9 |
+
emails = [
|
| 10 |
+
{"text": "Win a free iPhone! Click here.", "label": "spam"},
|
| 11 |
+
{"text": "Project meeting at 2pm.", "label": "important"},
|
| 12 |
+
{"text": "Lunch today?", "label": "ignore"}
|
| 13 |
+
]
|
| 14 |
+
return emails, ["delete", "mark_important", "ignore"]
|
| 15 |
|
| 16 |
def task_medium():
|
| 17 |
+
emails = [
|
| 18 |
+
{"text": "Congratulations on your recent purchase. Here is your receipt.", "label": "ignore"},
|
| 19 |
+
{"text": "URGENT: Server down, please check.", "label": "important"},
|
| 20 |
+
{"text": "Claim your gift card today!", "label": "spam"}
|
| 21 |
+
]
|
| 22 |
+
return emails, ["ignore", "mark_important", "delete"]
|
| 23 |
|
| 24 |
def task_hard():
|
| 25 |
+
emails = [
|
| 26 |
+
{"text": "RE: Following up on our previous discussion regarding the sync.", "label": "important"},
|
| 27 |
+
{"text": "Your account subscription will expire soon unless you renew.", "label": "ignore"},
|
| 28 |
+
{"text": "Limited time offer: Get 90% off on all items.", "label": "spam"}
|
| 29 |
+
]
|
| 30 |
+
return emails, ["mark_important", "ignore", "delete"]
|
| 31 |
|
| 32 |
def grade_task(predicted_actions: list, expected_actions: list) -> float:
|
| 33 |
if not expected_actions:
|
|
|
|
| 36 |
total = len(expected_actions)
|
| 37 |
correct = sum(1 for p, e in zip(predicted_actions, expected_actions) if p == e)
|
| 38 |
return correct / total
|
| 39 |
+
|
uv.lock
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|