Technologic101 commited on
Commit
c5d3c0b
·
1 Parent(s): 0b07c26

task: shorten prompt return

Browse files
Files changed (2) hide show
  1. src/app.py +5 -4
  2. src/chains/design_rag.py +2 -2
src/app.py CHANGED
@@ -14,8 +14,9 @@ For every user message, analyze their design preferences and requirements, consi
14
  2. Color preferences and mood
15
  3. Layout and structural needs
16
  4. Key visual elements
 
17
 
18
- First explain how you understand their requirements, then show relevant design examples."""
19
 
20
  @cl.on_chat_start
21
  async def init():
@@ -42,14 +43,14 @@ async def main(message: cl.Message):
42
  # Get LLM's analysis of requirements
43
  analysis = await llm.ainvoke(conversation_history)
44
 
45
- # Get design examples based on full conversation
46
  designs = await design_rag.query_similar_designs(
47
  [msg.content for msg in conversation_history],
48
- num_examples=3
49
  )
50
 
51
  # Combine analysis with designs
52
- response = f"{analysis.content}\n\nHere are some relevant designs:\n\n{designs}"
53
 
54
  # Add assistant's response to history
55
  conversation_history.append(SystemMessage(content=response))
 
14
  2. Color preferences and mood
15
  3. Layout and structural needs
16
  4. Key visual elements
17
+ 5. Intended audience and user experience
18
 
19
+ First briefly explain how you understand their requirements, then show the closest match."""
20
 
21
  @cl.on_chat_start
22
  async def init():
 
43
  # Get LLM's analysis of requirements
44
  analysis = await llm.ainvoke(conversation_history)
45
 
46
+ # Get best design example based on full conversation
47
  designs = await design_rag.query_similar_designs(
48
  [msg.content for msg in conversation_history],
49
+ num_examples=1
50
  )
51
 
52
  # Combine analysis with designs
53
+ response = f"{analysis.content}\n\nHere is the best match from the zen garden:\n\n{designs}"
54
 
55
  # Add assistant's response to history
56
  conversation_history.append(SystemMessage(content=response))
src/chains/design_rag.py CHANGED
@@ -20,7 +20,7 @@ class DesignRAG:
20
  # Create retriever
21
  self.retriever = self.vector_store.as_retriever(
22
  search_type="similarity",
23
- search_kwargs={"k": 5}
24
  )
25
 
26
  # Create LLM
@@ -86,7 +86,7 @@ class DesignRAG:
86
  print(f"Error creating vector store: {str(e)}")
87
  raise
88
 
89
- async def query_similar_designs(self, conversation_history: List[str], num_examples: int = 5) -> str:
90
  """Find similar designs based on conversation history
91
 
92
  Args:
 
20
  # Create retriever
21
  self.retriever = self.vector_store.as_retriever(
22
  search_type="similarity",
23
+ search_kwargs={"k": 1}
24
  )
25
 
26
  # Create LLM
 
86
  print(f"Error creating vector store: {str(e)}")
87
  raise
88
 
89
+ async def query_similar_designs(self, conversation_history: List[str], num_examples: int = 1) -> str:
90
  """Find similar designs based on conversation history
91
 
92
  Args: