Update app.py
Browse files
app.py
CHANGED
|
@@ -1458,8 +1458,14 @@ class Hive:
|
|
| 1458 |
if hasattr(self, 'client') and self.client: # Remote Inference
|
| 1459 |
stop_sequences = ["</s>", "Assistant:"] + [self.tok.decode(st) for st in self.stop_tokens]
|
| 1460 |
try:
|
| 1461 |
-
|
| 1462 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1463 |
except Exception as e:
|
| 1464 |
print(f"[ModelBridge] Remote inference stream failed: {e}")
|
| 1465 |
yield "[Error: Could not get response from remote model]"
|
|
@@ -1485,7 +1491,7 @@ class Hive:
|
|
| 1485 |
yield new_text
|
| 1486 |
|
| 1487 |
def chat(self, message:str, effective_role:str, caller_id: Optional[str],
|
| 1488 |
-
k:int=None, max_new_tokens:int=
|
| 1489 |
temp = temperature if temperature is not None else (self.decoding_temperature if not self.lite_mode else 0.7)
|
| 1490 |
|
| 1491 |
# This logic was previously in _prepare_chat_input
|
|
@@ -1865,7 +1871,7 @@ def launch_ui(bootstrap_instance: "Bootstrap"):
|
|
| 1865 |
|
| 1866 |
eff_role = role if mode == "admin" else "user"
|
| 1867 |
final_message, intent = hive_instance._prepare_chat_input(user_text, "en", False, None) # type: ignore
|
| 1868 |
-
max_tokens =
|
| 1869 |
full_prompt = hive_instance.compiler.compile(final_message, [], intent=intent) # type: ignore
|
| 1870 |
|
| 1871 |
full_reply = ""
|
|
|
|
| 1458 |
if hasattr(self, 'client') and self.client: # Remote Inference
|
| 1459 |
stop_sequences = ["</s>", "Assistant:"] + [self.tok.decode(st) for st in self.stop_tokens]
|
| 1460 |
try:
|
| 1461 |
+
messages = [{"role": "user", "content": prompt}]
|
| 1462 |
+
for chunk in self.client.chat_completion(
|
| 1463 |
+
messages=messages, max_tokens=int(max_new_tokens), temperature=float(temperature),
|
| 1464 |
+
do_sample=True, stop=stop_sequences, stream=True
|
| 1465 |
+
):
|
| 1466 |
+
content = chunk.choices[0].delta.content
|
| 1467 |
+
if content:
|
| 1468 |
+
yield content
|
| 1469 |
except Exception as e:
|
| 1470 |
print(f"[ModelBridge] Remote inference stream failed: {e}")
|
| 1471 |
yield "[Error: Could not get response from remote model]"
|
|
|
|
| 1491 |
yield new_text
|
| 1492 |
|
| 1493 |
def chat(self, message:str, effective_role:str, caller_id: Optional[str],
|
| 1494 |
+
k:int=None, max_new_tokens:int=1024, temperature:float=None, prompt_override: Optional[str] = None) -> str: # type: ignore
|
| 1495 |
temp = temperature if temperature is not None else (self.decoding_temperature if not self.lite_mode else 0.7)
|
| 1496 |
|
| 1497 |
# This logic was previously in _prepare_chat_input
|
|
|
|
| 1871 |
|
| 1872 |
eff_role = role if mode == "admin" else "user"
|
| 1873 |
final_message, intent = hive_instance._prepare_chat_input(user_text, "en", False, None) # type: ignore
|
| 1874 |
+
max_tokens = 1024 if intent == "essay_review" else 1024 # Increased for longer responses
|
| 1875 |
full_prompt = hive_instance.compiler.compile(final_message, [], intent=intent) # type: ignore
|
| 1876 |
|
| 1877 |
full_reply = ""
|