Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- README.md +3 -9
- custom.css +135 -0
- deploy.py +167 -0
README.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
colorFrom: green
|
| 5 |
-
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: TaskPilot_AI
|
| 3 |
+
app_file: deploy.py
|
|
|
|
|
|
|
| 4 |
sdk: gradio
|
| 5 |
+
sdk_version: 5.49.1
|
|
|
|
|
|
|
| 6 |
---
|
|
|
|
|
|
custom.css
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* ===== FONT (DEV STYLE) ===== */
|
| 2 |
+
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap');
|
| 3 |
+
|
| 4 |
+
/* ===== GLOBAL BACKGROUND ===== */
|
| 5 |
+
html, body {
|
| 6 |
+
background: #0a0a0f !important;
|
| 7 |
+
font-family: 'JetBrains Mono', monospace;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
/* ===== MAIN CONTAINER ===== */
|
| 11 |
+
.gradio-container {
|
| 12 |
+
background: transparent !important;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
/* ===== CHAT AREA (REMOVE WHITE) ===== */
|
| 16 |
+
[data-testid="chatbot"] {
|
| 17 |
+
background: transparent !important;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
[data-testid="chatbot"] > div {
|
| 21 |
+
background: linear-gradient(135deg, #0f0c29, #302b63, #24243e) !important;
|
| 22 |
+
border-radius: 16px;
|
| 23 |
+
padding: 16px;
|
| 24 |
+
min-height: 400px;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
/* Remove all internal white layers */
|
| 28 |
+
[data-testid="chatbot"] * {
|
| 29 |
+
background-color: transparent !important;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
/* ===== USER MESSAGE (CYAN GLOW) ===== */
|
| 33 |
+
.user.message {
|
| 34 |
+
background: rgba(0, 255, 255, 0.12) !important;
|
| 35 |
+
border: 1px solid rgba(0, 255, 255, 0.7) !important;
|
| 36 |
+
border-radius: 12px;
|
| 37 |
+
padding: 12px;
|
| 38 |
+
|
| 39 |
+
box-shadow: 0 0 10px #00ffff;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/* ===== BOT MESSAGE (STRONG CYAN GLOW) ===== */
|
| 43 |
+
.bot.message {
|
| 44 |
+
background: rgba(0, 255, 255, 0.12) !important;
|
| 45 |
+
border: 1px solid rgba(0, 255, 255, 0.7) !important;
|
| 46 |
+
border-radius: 12px;
|
| 47 |
+
padding: 12px;
|
| 48 |
+
|
| 49 |
+
box-shadow:
|
| 50 |
+
0 0 10px #00ffff,
|
| 51 |
+
0 0 20px rgba(0, 255, 255, 0.5);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
/* ===== π₯ FORCE BLACK TEXT (FINAL FIX) ===== */
|
| 55 |
+
.user.message,
|
| 56 |
+
.user.message *,
|
| 57 |
+
.bot.message,
|
| 58 |
+
.bot.message * {
|
| 59 |
+
color: #000000 !important;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
/* ===== TEXTAREA (CYBERPUNK INPUT) ===== */
|
| 63 |
+
textarea {
|
| 64 |
+
background: rgba(5, 10, 20, 0.95) !important;
|
| 65 |
+
color: #00ffff !important;
|
| 66 |
+
|
| 67 |
+
border: 1px solid rgba(0, 255, 255, 0.4) !important;
|
| 68 |
+
border-radius: 12px !important;
|
| 69 |
+
|
| 70 |
+
padding: 14px !important;
|
| 71 |
+
font-size: 15px !important;
|
| 72 |
+
font-family: 'JetBrains Mono', monospace !important;
|
| 73 |
+
|
| 74 |
+
min-height: 90px !important;
|
| 75 |
+
resize: none !important;
|
| 76 |
+
|
| 77 |
+
caret-color: #00ffff !important;
|
| 78 |
+
|
| 79 |
+
box-shadow: inset 0 0 10px rgba(0, 255, 255, 0.15);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/* ===== PLACEHOLDER ===== */
|
| 83 |
+
textarea::placeholder {
|
| 84 |
+
color: rgba(0, 255, 255, 0.5) !important;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/* ===== TEXTAREA FOCUS ===== */
|
| 88 |
+
textarea:focus {
|
| 89 |
+
outline: none !important;
|
| 90 |
+
|
| 91 |
+
border: 1px solid #00ffff !important;
|
| 92 |
+
|
| 93 |
+
box-shadow:
|
| 94 |
+
0 0 8px #00ffff,
|
| 95 |
+
0 0 20px rgba(0, 255, 255, 0.5),
|
| 96 |
+
inset 0 0 12px rgba(0, 255, 255, 0.2);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
/* ===== MOVE INPUT UP ===== */
|
| 100 |
+
[data-testid="textbox"] {
|
| 101 |
+
margin-top: -12px !important;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
/* ===== SEND BUTTON ===== */
|
| 105 |
+
button {
|
| 106 |
+
background: linear-gradient(45deg, #00f0ff, #ff00c8) !important;
|
| 107 |
+
border: none !important;
|
| 108 |
+
color: black !important;
|
| 109 |
+
font-weight: bold;
|
| 110 |
+
border-radius: 10px;
|
| 111 |
+
padding: 10px 16px;
|
| 112 |
+
|
| 113 |
+
box-shadow: 0 0 10px rgba(255, 0, 200, 0.5);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
/* ===== BUTTON HOVER ===== */
|
| 117 |
+
button:hover {
|
| 118 |
+
box-shadow:
|
| 119 |
+
0 0 15px #ff00c8,
|
| 120 |
+
0 0 25px #00ffff;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/* ===== SCROLLBAR ===== */
|
| 124 |
+
[data-testid="chatbot"]::-webkit-scrollbar {
|
| 125 |
+
width: 8px;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
[data-testid="chatbot"]::-webkit-scrollbar-track {
|
| 129 |
+
background: #0a0a0f;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
[data-testid="chatbot"]::-webkit-scrollbar-thumb {
|
| 133 |
+
background: linear-gradient(#00ffff, #ff00c8);
|
| 134 |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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from rich.console import Console
|
| 2 |
+
from dotenv import load_dotenv
|
| 3 |
+
from openai import AzureOpenAI
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import gradio as gr
|
| 7 |
+
|
| 8 |
+
load_dotenv(override=True)
|
| 9 |
+
|
| 10 |
+
# ββ OpenAI client ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 11 |
+
openai_key = os.getenv('OPENAI_API_KEY')
|
| 12 |
+
openai = AzureOpenAI(
|
| 13 |
+
api_version="2025-02-01-preview",
|
| 14 |
+
azure_endpoint="https://api.chatgpt.tomtom-global.com/",
|
| 15 |
+
api_key=openai_key
|
| 16 |
+
)
|
| 17 |
+
model = "dep-gpt-5.4"
|
| 18 |
+
|
| 19 |
+
# ββ Helpers ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 20 |
+
def show(text):
|
| 21 |
+
try:
|
| 22 |
+
Console().print(text)
|
| 23 |
+
except Exception:
|
| 24 |
+
print(text)
|
| 25 |
+
|
| 26 |
+
# ββ Todo state βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 27 |
+
todos = []
|
| 28 |
+
completed = []
|
| 29 |
+
|
| 30 |
+
# ββ Todo tools βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 31 |
+
def get_todo_report() -> str:
|
| 32 |
+
result = ""
|
| 33 |
+
for index, todo in enumerate(todos):
|
| 34 |
+
if completed[index]:
|
| 35 |
+
result += f"Todo #{index + 1}: ~~{todo}~~ β
\n"
|
| 36 |
+
else:
|
| 37 |
+
result += f"Todo #{index + 1}: {todo} β³\n"
|
| 38 |
+
show(result)
|
| 39 |
+
return result
|
| 40 |
+
|
| 41 |
+
def create_todos(descriptions: list[str]) -> str:
|
| 42 |
+
todos.extend(descriptions)
|
| 43 |
+
completed.extend([False] * len(descriptions))
|
| 44 |
+
return get_todo_report()
|
| 45 |
+
|
| 46 |
+
def mark_complete(index: int, completion_notes: str) -> str:
|
| 47 |
+
if 1 <= index <= len(todos):
|
| 48 |
+
completed[index - 1] = True
|
| 49 |
+
else:
|
| 50 |
+
return "No todo at this index."
|
| 51 |
+
Console().print(completion_notes)
|
| 52 |
+
return get_todo_report()
|
| 53 |
+
|
| 54 |
+
# ββ Tool schemas βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 55 |
+
create_todos_json = {
|
| 56 |
+
"name": "create_todos",
|
| 57 |
+
"description": "Add new todos from a list of descriptions and return the full list",
|
| 58 |
+
"parameters": {
|
| 59 |
+
"type": "object",
|
| 60 |
+
"properties": {
|
| 61 |
+
"descriptions": {
|
| 62 |
+
"type": "array",
|
| 63 |
+
"items": {"type": "string"},
|
| 64 |
+
"title": "Descriptions"
|
| 65 |
+
}
|
| 66 |
+
},
|
| 67 |
+
"required": ["descriptions"],
|
| 68 |
+
"additionalProperties": False
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
mark_complete_json = {
|
| 73 |
+
"name": "mark_complete",
|
| 74 |
+
"description": "Mark complete the todo at the given position (starting from 1) and return the full list",
|
| 75 |
+
"parameters": {
|
| 76 |
+
"type": "object",
|
| 77 |
+
"properties": {
|
| 78 |
+
"index": {
|
| 79 |
+
"description": "The 1-based index of the todo to mark as complete",
|
| 80 |
+
"title": "Index",
|
| 81 |
+
"type": "integer"
|
| 82 |
+
},
|
| 83 |
+
"completion_notes": {
|
| 84 |
+
"description": "Notes about how you completed the todo in rich console markup",
|
| 85 |
+
"title": "Completion Notes",
|
| 86 |
+
"type": "string"
|
| 87 |
+
}
|
| 88 |
+
},
|
| 89 |
+
"required": ["index", "completion_notes"],
|
| 90 |
+
"additionalProperties": False
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
tools = [
|
| 95 |
+
{"type": "function", "function": create_todos_json},
|
| 96 |
+
{"type": "function", "function": mark_complete_json}
|
| 97 |
+
]
|
| 98 |
+
|
| 99 |
+
TOOL_MAP = {
|
| 100 |
+
"create_todos": create_todos,
|
| 101 |
+
"mark_complete": mark_complete
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
# ββ Tool call handler ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 105 |
+
def handle_tool_calls(tool_calls):
|
| 106 |
+
results = []
|
| 107 |
+
for tool_call in tool_calls:
|
| 108 |
+
tool_name = tool_call.function.name
|
| 109 |
+
arguments = json.loads(tool_call.function.arguments)
|
| 110 |
+
tool = TOOL_MAP.get(tool_name)
|
| 111 |
+
result = tool(**arguments) if tool else {}
|
| 112 |
+
results.append({
|
| 113 |
+
"role": "tool",
|
| 114 |
+
"content": json.dumps(result),
|
| 115 |
+
"tool_call_id": tool_call.id
|
| 116 |
+
})
|
| 117 |
+
return results
|
| 118 |
+
|
| 119 |
+
# ββ System prompt ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 120 |
+
system_message = """
|
| 121 |
+
You are given a problem to solve, by using your todo tools to plan a list of steps, then carrying out each step in turn.
|
| 122 |
+
Now use the todo list tools, create a plan, carry out the steps, and reply with the solution.
|
| 123 |
+
If any quantity isn't provided in the question, then include a step to come up with a reasonable estimate.
|
| 124 |
+
Provide your solution in Markdown format (use ~~strikethrough~~ for completed tasks, bullet points, etc.).
|
| 125 |
+
Do not ask the user questions or clarification; respond only with the answer after using your tools.
|
| 126 |
+
"""
|
| 127 |
+
|
| 128 |
+
# ββ Agent loop βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 129 |
+
def loop(message, history):
|
| 130 |
+
global todos, completed
|
| 131 |
+
todos, completed = [], [] # reset state for each new conversation turn
|
| 132 |
+
|
| 133 |
+
done = False
|
| 134 |
+
messages = [{"role": "system", "content": system_message}] + history + [{"role": "user", "content": message}]
|
| 135 |
+
|
| 136 |
+
max_steps = 10
|
| 137 |
+
steps = 0
|
| 138 |
+
while not done and steps < max_steps:
|
| 139 |
+
steps += 1
|
| 140 |
+
response = openai.chat.completions.create(
|
| 141 |
+
model=model,
|
| 142 |
+
messages=messages,
|
| 143 |
+
tools=tools,
|
| 144 |
+
reasoning_effort="none"
|
| 145 |
+
)
|
| 146 |
+
finish_reason = response.choices[0].finish_reason
|
| 147 |
+
|
| 148 |
+
if finish_reason == "tool_calls":
|
| 149 |
+
msg = response.choices[0].message
|
| 150 |
+
tool_calls = msg.tool_calls
|
| 151 |
+
results = handle_tool_calls(tool_calls)
|
| 152 |
+
messages.append(msg)
|
| 153 |
+
messages.extend(results)
|
| 154 |
+
else:
|
| 155 |
+
done = True
|
| 156 |
+
|
| 157 |
+
return response.choices[0].message.content
|
| 158 |
+
|
| 159 |
+
def load_css():
|
| 160 |
+
with open("custom.css", "r") as f:
|
| 161 |
+
return f.read()
|
| 162 |
+
|
| 163 |
+
custom_css = load_css()
|
| 164 |
+
|
| 165 |
+
# ββ Launch Gradio ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 166 |
+
if __name__ == "__main__":
|
| 167 |
+
gr.ChatInterface(loop, type="messages",css=custom_css).launch()
|