Skip to content

Commit

Permalink
Dedupe user location passed in image, diagram generation prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
debanjum committed Oct 24, 2024
1 parent 2a32836 commit 37317e3
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/khoj/routers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,10 +684,7 @@ async def generate_better_diagram_description(
prompts.personality_context.format(personality=agent.personality) if agent and agent.personality else ""
)

if location_data:
location_prompt = prompts.user_location.format(location=f"{location_data}")
else:
location_prompt = "Unknown"
location = f"{location_data}" if location_data else "Unknown"

user_references = "\n\n".join([f"# {item['compiled']}" for item in note_references])

Expand All @@ -705,7 +702,7 @@ async def generate_better_diagram_description(
improve_diagram_description_prompt = prompts.improve_diagram_description_prompt.format(
query=q,
chat_history=chat_history,
location=location_prompt,
location=location,
current_date=today_date,
references=user_references,
online_results=simplified_online_results,
Expand Down Expand Up @@ -770,10 +767,7 @@ async def generate_better_image_prompt(
)
model_type = model_type or TextToImageModelConfig.ModelType.OPENAI

if location_data:
location_prompt = prompts.user_location.format(location=f"{location_data}")
else:
location_prompt = "Unknown"
location = f"{location_data}" if location_data else "Unknown"

user_references = "\n\n".join([f"# {item['compiled']}" for item in note_references])

Expand All @@ -790,7 +784,7 @@ async def generate_better_image_prompt(
image_prompt = prompts.image_generation_improve_prompt_dalle.format(
query=q,
chat_history=conversation_history,
location=location_prompt,
location=location,
current_date=today_date,
references=user_references,
online_results=simplified_online_results,
Expand All @@ -800,7 +794,7 @@ async def generate_better_image_prompt(
image_prompt = prompts.image_generation_improve_prompt_sd.format(
query=q,
chat_history=conversation_history,
location=location_prompt,
location=location,
current_date=today_date,
references=user_references,
online_results=simplified_online_results,
Expand Down

0 comments on commit 37317e3

Please sign in to comment.