Leonydis137 commited on
Commit
c14168b
·
verified ·
1 Parent(s): 5d09900

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -6
app.py CHANGED
@@ -245,13 +245,11 @@ 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
- @app.get("/status")
249
- def status():
250
- return {"status": "active", "agents": ["planner", "executor", "critic"]}
251
-
252
  from ctransformers import AutoModelForCausalLM
253
  from src.core.cognitive_engine import CognitiveEngine
254
 
 
255
  llm_model = AutoModelForCausalLM.from_pretrained(
256
  "TheBloke/zephyr-7B-alpha-GGUF",
257
  model_file="zephyr-7b-alpha.Q4_K_M.gguf",
@@ -260,11 +258,22 @@ llm_model = AutoModelForCausalLM.from_pretrained(
260
  temperature=0.7
261
  )
262
 
 
 
263
  cognitive_engine = CognitiveEngine(llm_model)
264
 
265
- response = model.generate("Hello, how are you?")
266
- print(response)
 
 
267
 
 
 
 
 
 
268
  if __name__ == "__main__":
 
 
269
  import uvicorn
270
  uvicorn.run(app, host="0.0.0.0", port=7860)
 
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
 
252
+ # Load LLM model
253
  llm_model = AutoModelForCausalLM.from_pretrained(
254
  "TheBloke/zephyr-7B-alpha-GGUF",
255
  model_file="zephyr-7b-alpha.Q4_K_M.gguf",
 
258
  temperature=0.7
259
  )
260
 
261
+ # Initialize FastAPI and engine
262
+ app = FastAPI()
263
  cognitive_engine = CognitiveEngine(llm_model)
264
 
265
+ # Routes
266
+ @app.get("/status")
267
+ def status():
268
+ return {"status": "active", "agents": ["planner", "executor", "critic"]}
269
 
270
+ @app.get("/generate")
271
+ def generate(prompt: str):
272
+ return {"response": llm_model(prompt)}
273
+
274
+ # Test the model at startup (optional)
275
  if __name__ == "__main__":
276
+ print(llm_model("Hello, how are you?"))
277
+
278
  import uvicorn
279
  uvicorn.run(app, host="0.0.0.0", port=7860)