srinuksv commited on
Commit
a6ab03d
1 Parent(s): 9a3515a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -16
app.py CHANGED
@@ -28,23 +28,22 @@ llm_client = InferenceClient(
28
  token=os.getenv("HF_TOKEN"),
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"
45
  )
46
- print(result)
47
- return result
 
 
 
48
 
49
 
50
  os.environ["HF_TOKEN"] = os.getenv("HF_TOKEN")
 
28
  token=os.getenv("HF_TOKEN"),
29
  )
30
  def summarize_conversation(history: list):
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")