LordXido commited on
Commit
82ddb5f
·
verified ·
1 Parent(s): 2177bf1

Upload 7 files

Browse files
Files changed (7) hide show
  1. Dockerfile +10 -0
  2. README 2.md +12 -0
  3. api_gateway.py +15 -0
  4. codex_logic.py +6 -0
  5. openapi_spec.json +41 -0
  6. requirements.txt +2 -0
  7. space.yaml +5 -0
Dockerfile ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY . /app
6
+ RUN pip install --no-cache-dir -r requirements.txt
7
+
8
+ EXPOSE 7860
9
+
10
+ CMD ["uvicorn", "api_gateway:app", "--host", "0.0.0.0", "--port", "7860"]
README 2.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CodexHF Sovereign API Gateway
2
+
3
+ This is the RESTful API backend for evaluating work descriptions via the Codex Work-as-Value engine. It includes ethical constraint enforcement (CodexΛ) and symbolic output.
4
+
5
+ ## Endpoints
6
+ - POST /evaluate
7
+
8
+ ## Setup
9
+ ```
10
+ pip install -r requirements.txt
11
+ uvicorn api_gateway:app --reload
12
+ ```
api_gateway.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from pydantic import BaseModel
3
+ from codex_logic import assess_work_description, validate_use_case
4
+
5
+ app = FastAPI()
6
+
7
+ class EvaluationRequest(BaseModel):
8
+ work_description: str
9
+
10
+ @app.post("/evaluate")
11
+ def evaluate_work(req: EvaluationRequest):
12
+ if not validate_use_case(req.work_description):
13
+ return {"codex_response": "⚠ Rejected: Use case violates CodexΛ constraint."}
14
+ response = assess_work_description(req.work_description)
15
+ return {"codex_response": response}
codex_logic.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ def assess_work_description(work):
2
+ return "✅ Work evaluated. Alignment with Codex principles confirmed. Value anchored."
3
+
4
+ def validate_use_case(work):
5
+ banned = ['weapon', 'fraud', 'spyware', 'surveillance']
6
+ return not any(term in work.lower() for term in banned)
openapi_spec.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "openapi": "3.0.0",
3
+ "info": {
4
+ "title": "Codex Sovereign API Gateway",
5
+ "version": "1.0.0"
6
+ },
7
+ "paths": {
8
+ "/evaluate": {
9
+ "post": {
10
+ "summary": "Evaluate work description",
11
+ "requestBody": {
12
+ "required": true,
13
+ "content": {
14
+ "application/json": {
15
+ "schema": {
16
+ "$ref": "#/components/schemas/EvaluationRequest"
17
+ }
18
+ }
19
+ }
20
+ },
21
+ "responses": {
22
+ "200": {
23
+ "description": "Evaluation Result"
24
+ }
25
+ }
26
+ }
27
+ }
28
+ },
29
+ "components": {
30
+ "schemas": {
31
+ "EvaluationRequest": {
32
+ "type": "object",
33
+ "properties": {
34
+ "work_description": {
35
+ "type": "string"
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastapi==0.103.0
2
+ uvicorn==0.23.2
space.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ title: CodexHF Sovereign API
2
+ sdk: docker
3
+ app_port: 7860
4
+ license: other
5
+ python_version: 3.10