Uhhy commited on
Commit
391a666
1 Parent(s): 3eeafd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -42,7 +42,6 @@ model_configs = [
42
  {"repo_id": "Ffftdtd5dtft/Mistral-Nemo-Instruct-2407-Q2_K-GGUF", "filename": "mistral-nemo-instruct-2407-q2_k.gguf", "name": "Mistral Nemo Instruct 2407"}
43
  ]
44
 
45
-
46
  class ModelManager:
47
  def __init__(self):
48
  self.models = {}
@@ -113,14 +112,11 @@ async def handle_request(request):
113
 
114
 
115
  async def run_server(port: int):
116
- async with httpx.AsyncClient(base_url=f"http://localhost:{port}") as client:
117
- while True:
118
- request = await client.get("/") # You might need to adjust this based on your expected requests
119
- response = await handle_request(request)
120
- print(f"Received request: {request}")
121
- print(f"Sending response: {response}")
122
- await asyncio.sleep(1) # Adjust the sleep duration as needed
123
 
 
 
124
 
125
  def remove_repetitive_responses(responses):
126
  unique_responses = {}
 
42
  {"repo_id": "Ffftdtd5dtft/Mistral-Nemo-Instruct-2407-Q2_K-GGUF", "filename": "mistral-nemo-instruct-2407-q2_k.gguf", "name": "Mistral Nemo Instruct 2407"}
43
  ]
44
 
 
45
  class ModelManager:
46
  def __init__(self):
47
  self.models = {}
 
112
 
113
 
114
  async def run_server(port: int):
115
+ async def serve_request(request: httpx.Request) -> httpx.Response:
116
+ return await handle_request(request)
 
 
 
 
 
117
 
118
+ server = await httpx.serve(serve_request, host="localhost", port=port)
119
+ await server.aclose()
120
 
121
  def remove_repetitive_responses(responses):
122
  unique_responses = {}