Spaces:
Paused
Paused
Black Goku commited on
Upload 3 files
Browse files- Dockerfile +6 -0
- app.py +60 -0
- requirements.txt +4 -0
Dockerfile
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10
|
| 2 |
+
WORKDIR /app
|
| 3 |
+
COPY . /app
|
| 4 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 5 |
+
EXPOSE 7860
|
| 6 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from fastapi import FastAPI
|
| 3 |
+
from pydantic import BaseModel
|
| 4 |
+
from huggingface_hub import InferenceClient
|
| 5 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 6 |
+
|
| 7 |
+
app = FastAPI()
|
| 8 |
+
|
| 9 |
+
# Security Pass for Web App
|
| 10 |
+
app.add_middleware(
|
| 11 |
+
CORSMiddleware,
|
| 12 |
+
allow_origins=["*"],
|
| 13 |
+
allow_credentials=True,
|
| 14 |
+
allow_methods=["*"],
|
| 15 |
+
allow_headers=["*"],
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
# Connect to the World-Class Coder Brain
|
| 19 |
+
client = InferenceClient(
|
| 20 |
+
model="Qwen/Qwen2.5-Coder-7B-Instruct",
|
| 21 |
+
token=os.getenv("HF_TOKEN")
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
# The Pro Coding Identity (Optimized for Deep Thinking)
|
| 25 |
+
PRO_IDENTITY = """
|
| 26 |
+
You are Zenvy Quantum Pro, an elite, high-IQ AI software engineer and master coder.
|
| 27 |
+
You were created by the brilliant developer Xirrik.
|
| 28 |
+
|
| 29 |
+
Rules:
|
| 30 |
+
1. When Xirrik asks for code, do not just copy-paste. First, explain your reasoning (how you plan to solve the problem).
|
| 31 |
+
2. Write clean, complete, and fully commented code. Never use placeholders like '// add rest of code here'. Write the whole file.
|
| 32 |
+
3. Be highly supportive and treat Xirrik with the utmost respect.
|
| 33 |
+
4. Keep the output extremely structured using markdown formatting.
|
| 34 |
+
"""
|
| 35 |
+
|
| 36 |
+
class ChatRequest(BaseModel):
|
| 37 |
+
message: str
|
| 38 |
+
|
| 39 |
+
@app.get("/")
|
| 40 |
+
def home():
|
| 41 |
+
return {"status": "Zenvy Quantum Pro is Online"}
|
| 42 |
+
|
| 43 |
+
@app.post("/chat")
|
| 44 |
+
async def chat(request: ChatRequest):
|
| 45 |
+
try:
|
| 46 |
+
# Call the Coder Model
|
| 47 |
+
response = client.chat_completion(
|
| 48 |
+
messages=[
|
| 49 |
+
{"role": "system", "content": PRO_IDENTITY},
|
| 50 |
+
{"role": "user", "content": request.message}
|
| 51 |
+
],
|
| 52 |
+
max_tokens=1000, # Increased to allow very long code files
|
| 53 |
+
temperature=0.3 # Lower temperature makes the code highly accurate and precise
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
reply = response.choices[0].message.content
|
| 57 |
+
return {"reply": reply}
|
| 58 |
+
|
| 59 |
+
except Exception as e:
|
| 60 |
+
return {"reply": f"Pro Core Error: {str(e)}"}
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn
|
| 3 |
+
huggingface_hub
|
| 4 |
+
pydantic
|