Skip to content

Commit a751354

Browse files
committed
Merge PR #547 from soniyaLama0/feature/top-k-parameter
2 parents 5652ac5 + fc203cf commit a751354

7 files changed

Lines changed: 756 additions & 700 deletions

File tree

backend/app/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class Settings(BaseSettings):
5454
GOOGLE_SERVICE_ACCOUNT_FILE: str = ""
5555

5656
# Celery / Redis background processing
57+
CELERY_ENABLED: bool = True
5758
CELERY_BROKER_URL: str = "redis://localhost:6379/0"
5859
CELERY_RESULT_BACKEND: str = "redis://localhost:6379/1"
5960
CELERY_TASK_TRACK_STARTED: bool = True

backend/app/rag/agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def get_agent_executor(
8282

8383
llm = HuggingFaceEndpoint(
8484
repo_id=settings.LLM_MODEL,
85+
model=settings.LLM_MODEL,
8586
huggingfacehub_api_token=token,
8687
max_new_tokens=settings.LLM_MAX_NEW_TOKENS,
8788
temperature=settings.LLM_TEMPERATURE,
@@ -156,7 +157,8 @@ def generate_answer(
156157
model=settings.LLM_MODEL,
157158
max_tokens=256,
158159
)
159-
answer = response.choices[0].message.content.strip() if response.choices else "Hello! How can I help you today?"
160+
content = response.choices[0].message.content if response.choices else None
161+
answer = content.strip() if content else "Hello! How can I help you today?"
160162
except Exception:
161163
answer = "Hello! I'm Document AI Analyst. How can I help you with your documents?"
162164
return {"answer": answer, "sources": []}

backend/app/rag/summarizer.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,8 @@ def generate_document_summary(
6666
max_tokens=settings.SUMMARY_MAX_TOKENS,
6767
temperature=settings.LLM_TEMPERATURE,
6868
)
69-
70-
# Defensive check for malformed or empty response structures
71-
summary = None
72-
if response and getattr(response, "choices", None):
73-
first_choice = response.choices[0]
74-
message = getattr(first_choice, "message", None)
75-
content = getattr(message, "content", None)
76-
if content:
77-
summary = content.strip()
69+
content = response.choices[0].message.content if response.choices else None
70+
summary = content.strip() if content else None
7871

7972
return summary or None
8073

0 commit comments

Comments
 (0)