Bhaskar2611 commited on
Commit
295f0a0
·
verified ·
1 Parent(s): bdf2d37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -7
app.py CHANGED
@@ -71,9 +71,8 @@ HF_TOKEN = os.getenv("HF_TOKEN")
71
  if not HF_TOKEN:
72
  raise ValueError("HF_TOKEN is missing.")
73
 
74
- # Create HF client
75
  client = InferenceClient(
76
- provider="nscale",
77
  api_key=HF_TOKEN
78
  )
79
 
@@ -85,7 +84,6 @@ system_message = (
85
  "based on their requirements."
86
  )
87
 
88
- # Chat function
89
  def chat_function(message, history):
90
 
91
  messages = [
@@ -99,7 +97,6 @@ def chat_function(message, history):
99
 
100
  for item in history:
101
 
102
- # Modern Gradio messages format
103
  if isinstance(item, dict):
104
 
105
  role = item.get("role")
@@ -111,7 +108,6 @@ def chat_function(message, history):
111
  "content": content
112
  })
113
 
114
- # Older tuple fallback
115
  elif isinstance(item, (list, tuple)) and len(item) == 2:
116
 
117
  user_msg, assistant_msg = item
@@ -128,7 +124,6 @@ def chat_function(message, history):
128
  "content": assistant_msg
129
  })
130
 
131
- # Current user message
132
  messages.append({
133
  "role": "user",
134
  "content": message
@@ -137,7 +132,7 @@ def chat_function(message, history):
137
  try:
138
 
139
  completion = client.chat.completions.create(
140
- model="Qwen/Qwen2.5-Coder-7B-Instruct",
141
  messages=messages,
142
  max_tokens=2048,
143
  temperature=0.7,
 
71
  if not HF_TOKEN:
72
  raise ValueError("HF_TOKEN is missing.")
73
 
74
+ # Initialize client
75
  client = InferenceClient(
 
76
  api_key=HF_TOKEN
77
  )
78
 
 
84
  "based on their requirements."
85
  )
86
 
 
87
  def chat_function(message, history):
88
 
89
  messages = [
 
97
 
98
  for item in history:
99
 
 
100
  if isinstance(item, dict):
101
 
102
  role = item.get("role")
 
108
  "content": content
109
  })
110
 
 
111
  elif isinstance(item, (list, tuple)) and len(item) == 2:
112
 
113
  user_msg, assistant_msg = item
 
124
  "content": assistant_msg
125
  })
126
 
 
127
  messages.append({
128
  "role": "user",
129
  "content": message
 
132
  try:
133
 
134
  completion = client.chat.completions.create(
135
+ model="Qwen/Qwen2.5-Coder-7B-Instruct:nscale",
136
  messages=messages,
137
  max_tokens=2048,
138
  temperature=0.7,