Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/app/api/v1/endpoints/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def chat_with_gemini(
user_id: UUID = Depends(jw_auth_middleware),
):
try:
print("Estoy aca!")
profile_info = get_profile(request) # type: ignore
courses_info = get_sessions(1, request) # type: ignore
chat_id = str(uuid.uuid4())
Expand All @@ -137,8 +136,6 @@ def chat_with_gemini(
gemini_response = generate_gemini_response(
payload.msg, chat_id, metadata, user_id
)
print("sigo aca!")

response = {"uid": chat_id, "response": gemini_response}
return response
except Exception as e:
Expand Down
4 changes: 1 addition & 3 deletions src/app/services/gemini_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def generate_gemini_response(

aux = f"{prompt}\n\nMetadata: {metadata_str}"
passage = gemini_client.find_best_passage(aux)
final_prompt, storable_prompt = generate_prompt(
prompt, passage, metadata
) # storable_prompt doesnt include context
final_prompt, storable_prompt = generate_prompt(prompt, passage, metadata)
# print(f"\n\n final prompt es {final_prompt} \n\n")
response = client.models.generate_content(
model=settings.model_name,
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ async def test_chat_success(client):
fake = [{}]
app.dependency_overrides[jw_auth_middleware] = fake_auth
with (
patch("app.api.v1.endpoints.chat.generate_gemini_response") as mock_chat,
patch("app.api.v1.endpoints.chat.get_profile", return_value=fake),
patch("app.api.v1.endpoints.chat.get_sessions"),
patch(
"app.api.v1.endpoints.chat.generate_gemini_response",
return_value="Respuesta de Prueba",
),
):

mock_chat.return_value = "Respuesta de Prueba"
response = await client.post(get_url(), json=valid_payload)
data = response.json()
print(data)
assert data["response"] == "Respuesta de Prueba"
assert response.status_code == 200
assert "uid" in data, "La respuesta debe incluir la clave 'uid'"
assert is_valid_uuid(data["uid"]), f"uid no es un UUID válido: {data['uid']}"
mock_chat.assert_called_once()
app.dependency_overrides.pop(jw_auth_middleware)
Loading