Skip to content

Commit 0a6968b

Browse files
authored
refactor(providers): remove support for deprecated nemollm engine (#1076)
1 parent d2734ac commit 0a6968b

File tree

18 files changed

+29
-1015
lines changed

18 files changed

+29
-1015
lines changed

examples/configs/llm/nemollm/README.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/configs/llm/nemollm/config.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

examples/configs/llm/nemollm/rails.co

Lines changed: 0 additions & 20 deletions
This file was deleted.

examples/configs/streaming/config.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ models:
99
engine: openai
1010
model: gpt-4
1111

12-
# # Uncomment this and comment the 3 lines above to test with NeMo LLM.
13-
# - type: main
14-
# engine: "nemollm"
15-
# model: "gpt-43b-905"
16-
1712
rails:
1813
dialog:
1914
single_call:

nemoguardrails/llm/filters.py

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def co_v2(
100100
history += f' bot say "{event["script"]}"\n'
101101

102102
elif event["type"] == "StartTool":
103-
s = f' await {event["flow_name"]}'
103+
s = f" await {event['flow_name']}"
104104
for k, v in event.items():
105105
if k in [
106106
"type",
@@ -385,89 +385,15 @@ def indent(text: str, n_spaces: int) -> str:
385385
return textwrap.indent(text, " " * n_spaces)
386386

387387

388-
def user_assistant_sequence_nemollm(events: List[dict]) -> str:
389-
"""Filter that turns an array of events into a sequence of user/assistant messages.
390-
391-
The output will look like:
392-
```
393-
<extra_id_1>User
394-
hi
395-
<extra_id_1>Assistant
396-
Hello there!
397-
<extra_id_1>User
398-
What can you do?
399-
<extra_id_1>Assistant
400-
I can help with many things.
401-
```
402-
"""
403-
history_items = []
404-
for event in events:
405-
if event["type"] == "UserMessage":
406-
# Convert text to string regardless of type (handles both text and multimodal)
407-
history_items.append("<extra_id_1>User\n" + str(event["text"]))
408-
elif event["type"] == "StartUtteranceBotAction":
409-
history_items.append("<extra_id_1>Assistant\n" + event["script"])
410-
411-
return "\n".join(history_items)
412-
413-
414388
def _previous_line(lines: List[str], i: int):
415389
"""Returns the previous lines, skipping comments."""
390+
416391
i = i - 1
417392
while i > 0 and lines[i].strip().startswith("#"):
418393
i -= 1
419394
return lines[i]
420395

421396

422-
def to_messages_nemollm(colang_history: str) -> str:
423-
"""Filter that given a history in colang format, returns a messages string
424-
in the chat format used by NeMo LLM models."""
425-
messages = []
426-
427-
# For now, we use a simple heuristic. The line `user "xxx"` gets translated to
428-
# a message from the user, and the rest gets translated to messages from the assistant.
429-
lines = colang_history.split("\n")
430-
431-
bot_lines = []
432-
for i, line in enumerate(lines):
433-
if line.startswith('user "'):
434-
# If we have bot lines in the buffer, we first add a bot message.
435-
if bot_lines:
436-
messages.append({"type": "assistant", "content": "\n".join(bot_lines)})
437-
bot_lines = []
438-
439-
messages.append({"type": "user", "content": line[6:-1]})
440-
441-
elif line.strip() == "":
442-
# On empty lines, we also reset the bot buffer.
443-
if bot_lines:
444-
messages.append({"type": "assistant", "content": "\n".join(bot_lines)})
445-
bot_lines = []
446-
else:
447-
if i > 0 and _previous_line(lines, i).startswith('user "'):
448-
if not line.strip().startswith("#"):
449-
line = "User intent: " + line.strip()
450-
elif line.startswith("user "):
451-
line = "User intent: " + line[5:].strip()
452-
elif line.startswith("bot "):
453-
line = "Bot intent: " + line[4:].strip()
454-
elif line.startswith(' "'):
455-
line = "Bot message: " + line[2:].strip()
456-
bot_lines.append(line)
457-
458-
# Check if there is a last message from the bot.
459-
if bot_lines:
460-
messages.append({"type": "bot", "content": "\n".join(bot_lines)})
461-
462-
messages_string = ""
463-
for m in messages:
464-
if m["type"] == "assistant" or m["type"] == "bot":
465-
messages_string += "<extra_id_1>Assistant\n" + m["content"] + "\n"
466-
elif m["type"] == "user":
467-
messages_string += "<extra_id_1>User\n" + m["content"] + "\n"
468-
return messages_string
469-
470-
471397
def remove_trailing_new_line(s: str):
472398
if s.endswith("\n"):
473399
s = s[:-1]

nemoguardrails/llm/prompts/nemollm.yml

Lines changed: 0 additions & 189 deletions
This file was deleted.

0 commit comments

Comments
 (0)