Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,5 @@
|
|
1 |
|
2 |
-
from fastapi import FastAPI
|
3 |
import gradio as gr
|
4 |
-
from src.core.cognitive_engine import CognitiveEngine
|
5 |
from src.utils.hf_packager import HFSpacePackager
|
6 |
from agents.planner import plan_task
|
7 |
from agents.executor import execute_step
|
@@ -17,9 +15,38 @@ import subprocess
|
|
17 |
from sentence_transformers import SentenceTransformer
|
18 |
import numpy as np
|
19 |
import faiss
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
|
|
21 |
app = FastAPI()
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
# Initialize components
|
25 |
cognitive_engine = CognitiveEngine()
|
@@ -245,36 +272,8 @@ with gr.Blocks(css="static/style.css", theme=gr.themes.Soft()) as demo:
|
|
245 |
# Mount Gradio app to FastAPI
|
246 |
gr.mount_gradio_app(app, demo, path="/")
|
247 |
|
248 |
-
from fastapi import FastAPI
|
249 |
-
from ctransformers import AutoModelForCausalLM
|
250 |
-
from src.core.cognitive_engine import CognitiveEngine
|
251 |
-
cognitive_engine = CognitiveEngine(llm_model)
|
252 |
-
|
253 |
-
# Load LLM model
|
254 |
-
llm_model = AutoModelForCausalLM.from_pretrained(
|
255 |
-
"TheBloke/zephyr-7B-alpha-GGUF",
|
256 |
-
model_file="zephyr-7b-alpha.Q4_K_M.gguf",
|
257 |
-
model_type="llama",
|
258 |
-
max_new_tokens=256,
|
259 |
-
temperature=0.7
|
260 |
-
)
|
261 |
-
|
262 |
-
# Initialize FastAPI and engine
|
263 |
-
app = FastAPI()
|
264 |
-
cognitive_engine = CognitiveEngine(llm_model)
|
265 |
-
|
266 |
-
# Routes
|
267 |
-
@app.get("/status")
|
268 |
-
def status():
|
269 |
-
return {"status": "active", "agents": ["planner", "executor", "critic"]}
|
270 |
-
|
271 |
-
@app.get("/generate")
|
272 |
-
def generate(prompt: str):
|
273 |
-
return {"response": llm_model(prompt)}
|
274 |
-
|
275 |
# Test the model at startup (optional)
|
276 |
if __name__ == "__main__":
|
277 |
print(llm_model("Hello, how are you?"))
|
278 |
-
|
279 |
import uvicorn
|
280 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
1 |
|
|
|
2 |
import gradio as gr
|
|
|
3 |
from src.utils.hf_packager import HFSpacePackager
|
4 |
from agents.planner import plan_task
|
5 |
from agents.executor import execute_step
|
|
|
15 |
from sentence_transformers import SentenceTransformer
|
16 |
import numpy as np
|
17 |
import faiss
|
18 |
+
from fastapi import FastAPI
|
19 |
+
from ctransformers import AutoModelForCausalLM
|
20 |
+
from src.core.cognitive_engine import CognitiveEngine
|
21 |
+
cognitive_engine = CognitiveEngine(llm_model)
|
22 |
+
|
23 |
+
# Load LLM model
|
24 |
+
llm_model = AutoModelForCausalLM.from_pretrained(
|
25 |
+
"TheBloke/zephyr-7B-alpha-GGUF",
|
26 |
+
model_file="zephyr-7b-alpha.Q4_K_M.gguf",
|
27 |
+
model_type="llama",
|
28 |
+
max_new_tokens=256,
|
29 |
+
temperature=0.7
|
30 |
+
)
|
31 |
|
32 |
+
# Initialize FastAPI and engine
|
33 |
app = FastAPI()
|
34 |
+
cognitive_engine = CognitiveEngine(llm_model)
|
35 |
+
|
36 |
+
# Routes
|
37 |
+
@app.get("/status")
|
38 |
+
def status():
|
39 |
+
return {"status": "active", "agents": ["planner", "executor", "critic"]}
|
40 |
+
|
41 |
+
@app.get("/generate")
|
42 |
+
def generate(prompt: str):
|
43 |
+
return {"response": llm_model(prompt)}
|
44 |
+
|
45 |
+
# Test the model at startup (optional)
|
46 |
+
if __name__ == "__main__":
|
47 |
+
print(llm_model("Hello, how are you?"))
|
48 |
+
import uvicorn
|
49 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
50 |
|
51 |
# Initialize components
|
52 |
cognitive_engine = CognitiveEngine()
|
|
|
272 |
# Mount Gradio app to FastAPI
|
273 |
gr.mount_gradio_app(app, demo, path="/")
|
274 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
# Test the model at startup (optional)
|
276 |
if __name__ == "__main__":
|
277 |
print(llm_model("Hello, how are you?"))
|
|
|
278 |
import uvicorn
|
279 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|