Skip to content

Commit f063d86

Browse files
committed
Make sure we're actually using the original id's
1 parent dad820b commit f063d86

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

app/api/v1/routes/ideas.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ..dependencies.auth import verify_token
1010

1111
from ....services.analyzer import centroid_analysis
12-
from ..models.request import IdeaRequest
12+
from ..models.request import IdeaInput, IdeaRequest
1313
from ..models.response import AnalysisResponse, RelationshipGraph
1414
from app.services.types import PlotData, Results, RankedIdea
1515

@@ -79,10 +79,11 @@ async def rank_ideas(
7979
)
8080

8181
# Perform core analysis
82+
print('Starting analysis for ideas: \n', ideaRequest)
8283
results, plot_data = centroid_analysis(ideas)
8384
await CreditService.deduct_credits(user_id, "basic_analysis", num_ideas, total_bytes)
8485

85-
response = await build_base_response(ideas, results, plot_data)
86+
response = await build_base_response(ideas, results, plot_data, ideaRequest.ideas)
8687

8788
if ideaRequest.advanced_features:
8889
response = await process_advanced_features(
@@ -123,11 +124,14 @@ def _generate_edges(ranked_ideas: List[RankedIdea], similarity_matrix: List[List
123124

124125
return edges
125126

126-
async def build_base_response(ideas: List[str], results: Results, plot_data: PlotData) -> dict:
127+
async def build_base_response(ideas: List[str], results: Results, plot_data: PlotData, idea_inputs: List[IdeaInput]) -> dict:
127128
"""Build base response with ranked ideas and similarity scores"""
129+
# Create lookup dict from idea string to original input
130+
idea_to_input = {input.idea: input for input in idea_inputs}
131+
128132
ranked_ideas = [
129133
RankedIdea(
130-
id=str(idx),
134+
id=str(idea_to_input[idea].id) if idea_to_input[idea].id is not None else str(idx),
131135
idea=idea,
132136
similarity_score=results["similarity"][idx],
133137
cluster_id=plot_data["kmeans_data"]["cluster"][idx],

0 commit comments

Comments
 (0)