Ahmed Sadik commited on
Commit
f4fd42c
·
1 Parent(s): 13f26b4

fix: truncate question input to 500 characters for embedding generation

Browse files
services/embedding.py CHANGED
@@ -14,7 +14,7 @@ def generate_embeddings(chunks):
14
 
15
  def embed_question(question):
16
  model = get_model()
17
- bge_query = "Represent this sentence for searching relevant passages: " + question
18
  embedding = model.encode([bge_query])
19
  return embedding
20
 
 
14
 
15
  def embed_question(question):
16
  model = get_model()
17
+ bge_query = "Represent this sentence for searching relevant passages: " + question[:500] # Truncate to 500 chars to fit model limits
18
  embedding = model.encode([bge_query])
19
  return embedding
20
 
services/rate_limiter.py CHANGED
@@ -6,17 +6,14 @@ from slowapi.errors import RateLimitExceeded
6
  def get_real_ip(request: Request) -> str:
7
  # check for the real physical IP forwarded by Cloudflare
8
  cf_ip = request.headers.get("CF-Connecting-IP")
9
- print(f"[DEBUG Limiter] Caught CF-Connecting-IP: {cf_ip}", flush=True)
10
  if cf_ip:
11
  return cf_ip
12
 
13
  # fallback to standard forwarded header or raw host
14
  forwarded = request.headers.get("X-Forwarded-For")
15
- print(f"[DEBUG Limiter] Caught X-Forwarded-For: {forwarded}", flush=True)
16
  if forwarded:
17
  return forwarded.split(",")[0].strip()
18
 
19
- print(f"[DEBUG Limiter] Caught Fallback IP: {request.client.host}", flush=True)
20
  return request.client.host
21
 
22
  # Initialize the limiter with your custom IP fetcher
 
6
  def get_real_ip(request: Request) -> str:
7
  # check for the real physical IP forwarded by Cloudflare
8
  cf_ip = request.headers.get("CF-Connecting-IP")
 
9
  if cf_ip:
10
  return cf_ip
11
 
12
  # fallback to standard forwarded header or raw host
13
  forwarded = request.headers.get("X-Forwarded-For")
 
14
  if forwarded:
15
  return forwarded.split(",")[0].strip()
16
 
 
17
  return request.client.host
18
 
19
  # Initialize the limiter with your custom IP fetcher