Update app.py
Browse files
app.py
CHANGED
@@ -121,7 +121,7 @@ def construct_prompt(user_input, context, chat_history, max_history_turns=1): #
|
|
121 |
print(prompt)
|
122 |
return prompt
|
123 |
|
124 |
-
|
125 |
def chat_with_model(user_input, chat_history=[]):
|
126 |
# Search for relevant products
|
127 |
search_results = search_products(user_input)
|
@@ -142,22 +142,24 @@ def chat_with_model(user_input, chat_history=[]):
|
|
142 |
context = "Das weiß ich nicht."
|
143 |
print("context: ------------------------------------- \n"+context)
|
144 |
|
|
|
145 |
langfuse.observe(
|
146 |
name="search_products",
|
147 |
input={"query": user_input},
|
148 |
output={"context": context},
|
149 |
-
metadata={"
|
150 |
)
|
151 |
|
|
|
152 |
|
153 |
# Pass both user_input and context to construct_prompt
|
154 |
prompt = construct_prompt(user_input, context, chat_history) # This line is changed
|
155 |
print("prompt: ------------------------------------- \n"+prompt)
|
156 |
|
157 |
-
# LangFuse observation:
|
158 |
langfuse.observe(
|
159 |
name="construct_prompt",
|
160 |
-
input={"user_input": user_input, "context": context
|
161 |
output={"prompt": prompt}
|
162 |
)
|
163 |
|
@@ -172,6 +174,7 @@ def chat_with_model(user_input, chat_history=[]):
|
|
172 |
|
173 |
print("respone: ------------------------------------- \n"+response)
|
174 |
# LangFuse observation: Log LLM response
|
|
|
175 |
langfuse.observe(
|
176 |
name="llm_response",
|
177 |
input={"prompt": prompt},
|
|
|
121 |
print(prompt)
|
122 |
return prompt
|
123 |
|
124 |
+
|
125 |
def chat_with_model(user_input, chat_history=[]):
|
126 |
# Search for relevant products
|
127 |
search_results = search_products(user_input)
|
|
|
142 |
context = "Das weiß ich nicht."
|
143 |
print("context: ------------------------------------- \n"+context)
|
144 |
|
145 |
+
# LangFuse observation: Search Results
|
146 |
langfuse.observe(
|
147 |
name="search_products",
|
148 |
input={"query": user_input},
|
149 |
output={"context": context},
|
150 |
+
metadata={"results_count": len(search_results)}
|
151 |
)
|
152 |
|
153 |
+
|
154 |
|
155 |
# Pass both user_input and context to construct_prompt
|
156 |
prompt = construct_prompt(user_input, context, chat_history) # This line is changed
|
157 |
print("prompt: ------------------------------------- \n"+prompt)
|
158 |
|
159 |
+
# LangFuse observation: Prompt Construction
|
160 |
langfuse.observe(
|
161 |
name="construct_prompt",
|
162 |
+
input={"user_input": user_input, "context": context},
|
163 |
output={"prompt": prompt}
|
164 |
)
|
165 |
|
|
|
174 |
|
175 |
print("respone: ------------------------------------- \n"+response)
|
176 |
# LangFuse observation: Log LLM response
|
177 |
+
# LangFuse observation: LLM Response
|
178 |
langfuse.observe(
|
179 |
name="llm_response",
|
180 |
input={"prompt": prompt},
|