Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -26,12 +26,12 @@ VERBOSE = True
|
|
26 |
MAX_HISTORY = 125
|
27 |
|
28 |
def format_prompt(message, history):
|
29 |
-
|
30 |
for user_prompt, bot_response in history:
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
return
|
35 |
|
36 |
# Define current date/time
|
37 |
date_time_str = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
@@ -136,12 +136,12 @@ def respond(
|
|
136 |
global client
|
137 |
|
138 |
# Format the prompt
|
139 |
-
|
140 |
|
141 |
# Generate response using the InferenceClient
|
142 |
response = ""
|
143 |
for message in client.chat_completion(
|
144 |
-
|
145 |
max_tokens=max_tokens,
|
146 |
temperature=temperature,
|
147 |
top_p=top_p,
|
@@ -182,4 +182,4 @@ demo = gr.ChatInterface(
|
|
182 |
)
|
183 |
|
184 |
if __name__ == "__main__":
|
185 |
-
demo.launch()
|
|
|
26 |
MAX_HISTORY = 125
|
27 |
|
28 |
def format_prompt(message, history):
|
29 |
+
messages = []
|
30 |
for user_prompt, bot_response in history:
|
31 |
+
messages.append({"role": "user", "content": user_prompt})
|
32 |
+
messages.append({"role": "assistant", "content": bot_response})
|
33 |
+
messages.append({"role": "user", "content": message})
|
34 |
+
return messages
|
35 |
|
36 |
# Define current date/time
|
37 |
date_time_str = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
|
136 |
global client
|
137 |
|
138 |
# Format the prompt
|
139 |
+
messages = format_prompt(message, history)
|
140 |
|
141 |
# Generate response using the InferenceClient
|
142 |
response = ""
|
143 |
for message in client.chat_completion(
|
144 |
+
messages=messages,
|
145 |
max_tokens=max_tokens,
|
146 |
temperature=temperature,
|
147 |
top_p=top_p,
|
|
|
182 |
)
|
183 |
|
184 |
if __name__ == "__main__":
|
185 |
+
demo.launch(share=True)
|