Spaces:
Sleeping
Sleeping
Commit ·
567ace1
1
Parent(s): 05cc402
Fix all indentation errors in app.py
Browse files- __pycache__/app.cpython-312.pyc +0 -0
- app.py +9 -9
__pycache__/app.cpython-312.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-312.pyc and b/__pycache__/app.cpython-312.pyc differ
|
|
|
app.py
CHANGED
|
@@ -507,7 +507,7 @@ Minimum purchase is 1 roll (67-70 yards)."""
|
|
| 507 |
prompt = f"User: {user_message}\nAssistant:"
|
| 508 |
else:
|
| 509 |
# Fallback format for other models
|
| 510 |
-
|
| 511 |
|
| 512 |
logger.info(f"Using model: {self.model}")
|
| 513 |
logger.info(f"API Key present: {bool(self.api_key)}")
|
|
@@ -516,13 +516,13 @@ Minimum purchase is 1 roll (67-70 yards)."""
|
|
| 516 |
|
| 517 |
# Generate response with DialoGPT-optimized parameters
|
| 518 |
if "dialogpt" in self.model.lower():
|
| 519 |
-
|
| 520 |
-
|
| 521 |
max_new_tokens=150,
|
| 522 |
temperature=0.8,
|
| 523 |
-
|
| 524 |
top_k=50,
|
| 525 |
-
|
| 526 |
do_sample=True,
|
| 527 |
stop_sequences=["User:", "Assistant:", "\n\n"]
|
| 528 |
)
|
|
@@ -544,10 +544,10 @@ Minimum purchase is 1 roll (67-70 yards)."""
|
|
| 544 |
# Clean up the response based on model type
|
| 545 |
if "dialogpt" in self.model.lower() or "gpt2" in self.model.lower():
|
| 546 |
# Clean up DialoGPT/GPT-2 response
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
|
| 552 |
# Remove any remaining conversation markers
|
| 553 |
assistant_response = assistant_response.replace("User:", "").replace("Assistant:", "").strip()
|
|
|
|
| 507 |
prompt = f"User: {user_message}\nAssistant:"
|
| 508 |
else:
|
| 509 |
# Fallback format for other models
|
| 510 |
+
prompt = f"User: {user_message}\nAssistant:"
|
| 511 |
|
| 512 |
logger.info(f"Using model: {self.model}")
|
| 513 |
logger.info(f"API Key present: {bool(self.api_key)}")
|
|
|
|
| 516 |
|
| 517 |
# Generate response with DialoGPT-optimized parameters
|
| 518 |
if "dialogpt" in self.model.lower():
|
| 519 |
+
response = self.client.text_generation(
|
| 520 |
+
prompt,
|
| 521 |
max_new_tokens=150,
|
| 522 |
temperature=0.8,
|
| 523 |
+
top_p=0.9,
|
| 524 |
top_k=50,
|
| 525 |
+
repetition_penalty=1.1,
|
| 526 |
do_sample=True,
|
| 527 |
stop_sequences=["User:", "Assistant:", "\n\n"]
|
| 528 |
)
|
|
|
|
| 544 |
# Clean up the response based on model type
|
| 545 |
if "dialogpt" in self.model.lower() or "gpt2" in self.model.lower():
|
| 546 |
# Clean up DialoGPT/GPT-2 response
|
| 547 |
+
if "Assistant:" in response:
|
| 548 |
+
assistant_response = response.split("Assistant:")[-1].strip()
|
| 549 |
+
else:
|
| 550 |
+
assistant_response = response.strip()
|
| 551 |
|
| 552 |
# Remove any remaining conversation markers
|
| 553 |
assistant_response = assistant_response.replace("User:", "").replace("Assistant:", "").strip()
|