Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -27,25 +27,7 @@ llm_client = InferenceClient(
|
|
27 |
model=repo_id,
|
28 |
token=os.getenv("HF_TOKEN"),
|
29 |
)
|
30 |
-
|
31 |
-
try:
|
32 |
-
hist = ''.join([f"'{entry['sender']}: {entry['message']}'\n" for entry in history])
|
33 |
-
hist = "summarize this context and tell me user interest: " + hist
|
34 |
-
|
35 |
-
client = Client("Qwen/Qwen2.5-72B-Instruct")
|
36 |
-
result = client.predict(
|
37 |
-
query=hist,
|
38 |
-
history=[],
|
39 |
-
system="You are clara, created by redferntech. You are a helpful assistant.",
|
40 |
-
api_name="/predict"
|
41 |
-
)
|
42 |
-
return result
|
43 |
-
except Exception as e:
|
44 |
-
print(f"Summarization error: {str(e)}")
|
45 |
-
return "Error during summarization"
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
os.environ["HF_TOKEN"] = os.getenv("HF_TOKEN")
|
50 |
username = os.getenv("username")
|
51 |
password = os.getenv("password")
|
@@ -181,14 +163,17 @@ async def save_chat_history(history: dict):
|
|
181 |
# Check if 'history' is a key in the incoming dictionary
|
182 |
user_id = history.get('userId')
|
183 |
print(user_id)
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
|
|
|
|
|
|
192 |
@app.post("/webhook")
|
193 |
async def receive_form_data(request: Request):
|
194 |
form_data = await request.json()
|
|
|
27 |
model=repo_id,
|
28 |
token=os.getenv("HF_TOKEN"),
|
29 |
)
|
30 |
+
client = Client("Qwen/Qwen2.5-72B-Instruct")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
os.environ["HF_TOKEN"] = os.getenv("HF_TOKEN")
|
32 |
username = os.getenv("username")
|
33 |
password = os.getenv("password")
|
|
|
163 |
# Check if 'history' is a key in the incoming dictionary
|
164 |
user_id = history.get('userId')
|
165 |
print(user_id)
|
166 |
+
hist = ''.join([f"'{entry['sender']}: {entry['message']}'\n" for entry in history['history']])
|
167 |
+
hist = "summarize this context and tell me user interest: " + hist
|
168 |
+
print(hist)
|
169 |
+
result = client.predict(
|
170 |
+
query=hist,
|
171 |
+
history=[],
|
172 |
+
system="You are clara, created by redferntech. You are a helpful assistant.",
|
173 |
+
api_name="/predict"
|
174 |
+
)
|
175 |
+
sf.Lead.update(user_id,{'Description': result})
|
176 |
+
return {"summary": result, "message": "Chat history saved"}
|
177 |
@app.post("/webhook")
|
178 |
async def receive_form_data(request: Request):
|
179 |
form_data = await request.json()
|