Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,12 +29,16 @@ llm_client = InferenceClient(
|
|
| 29 |
)
|
| 30 |
def summarize_conversation(history: list):
|
| 31 |
# Construct the conversation history text
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
# Create a client instance
|
| 35 |
client = Client("Qwen/Qwen2.5-72B-Instruct")
|
| 36 |
result = client.predict(
|
| 37 |
-
query=
|
| 38 |
history=[],
|
| 39 |
system="you are a sumarization model your goal is to find the user interest based on conversation",
|
| 40 |
api_name="/model_chat"
|
|
@@ -181,7 +185,7 @@ async def save_chat_history(history: dict):
|
|
| 181 |
if 'history' in history and isinstance(history['history'], list):
|
| 182 |
print("Received history:", history['history']) # Debugging line
|
| 183 |
cleaned_summary = summarize_conversation(history['history'])
|
| 184 |
-
print("Cleaned summary:", cleaned_summary) # Debugging line
|
| 185 |
sf.Lead.update(user_id,{'Description': cleaned_summary})
|
| 186 |
return {"summary": cleaned_summary, "message": "Chat history saved"}
|
| 187 |
else:
|
|
|
|
| 29 |
)
|
| 30 |
def summarize_conversation(history: list):
|
| 31 |
# Construct the conversation history text
|
| 32 |
+
hist=''
|
| 33 |
+
for entry in history:
|
| 34 |
+
sender = entry['sender']
|
| 35 |
+
message = entry['message']
|
| 36 |
+
hist += f" '{sender}: {message}'\n"
|
| 37 |
+
hist="summarize this context what user need"+hist
|
| 38 |
# Create a client instance
|
| 39 |
client = Client("Qwen/Qwen2.5-72B-Instruct")
|
| 40 |
result = client.predict(
|
| 41 |
+
query=hist,
|
| 42 |
history=[],
|
| 43 |
system="you are a sumarization model your goal is to find the user interest based on conversation",
|
| 44 |
api_name="/model_chat"
|
|
|
|
| 185 |
if 'history' in history and isinstance(history['history'], list):
|
| 186 |
print("Received history:", history['history']) # Debugging line
|
| 187 |
cleaned_summary = summarize_conversation(history['history'])
|
| 188 |
+
print("Cleaned summary:", cleaned_summary,type(cleaned_summary)) # Debugging line
|
| 189 |
sf.Lead.update(user_id,{'Description': cleaned_summary})
|
| 190 |
return {"summary": cleaned_summary, "message": "Chat history saved"}
|
| 191 |
else:
|