Skip to content

Commit

Permalink
fixing demos
Browse files Browse the repository at this point in the history
  • Loading branch information
mgonzs13 committed Feb 3, 2025
1 parent 79eb77d commit 03b51f7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion llama_demos/llama_demos/chatllama_demo_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def send_prompt(self) -> None:

self.prompt = ChatPromptTemplate.from_messages(
[
SystemMessage("You are a IA that answer questions."),
SystemMessage("You are an IA that answer questions."),
HumanMessagePromptTemplate.from_template(
template=[
{"type": "text", "text": f"<image>{self.prompt}"},
Expand Down
2 changes: 1 addition & 1 deletion llama_demos/llama_demos/llama_rag_demo_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
[
SystemMessage("You are an AI assistant that answer questions briefly."),
HumanMessagePromptTemplate.from_template(
"Taking into account the followin information:{context}\n\n{question}"
"Taking into account the following information:{context}\n\n{question}"
),
]
)
Expand Down
16 changes: 7 additions & 9 deletions llama_ros/llama_ros/langchain/chat_llama_ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@
{% endif %}
"""

USE_JINJA_TEMPLATE = 0
USE_MINJA_TEMPLATE = 1
USE_LLAMA_TEMPLATE = 2
USE_JINJA_TEMPLATE = "jinja"
USE_MINJA_TEMPLATE = "minja"
USE_LLAMA_TEMPLATE = "llama"


class ChatLlamaROS(BaseChatModel, LlamaROSCommon):
Expand All @@ -130,11 +130,9 @@ class ChatLlamaROS(BaseChatModel, LlamaROSCommon):

@model_validator(mode="before")
def validate_template_method(cls, v):
v["template_value"] = {
"minja": USE_MINJA_TEMPLATE,
"jinja": USE_JINJA_TEMPLATE,
"llama": USE_LLAMA_TEMPLATE,
}[v["template_method"]]

if "template_value" not in v:
return v

if v["template_value"] not in [
USE_MINJA_TEMPLATE,
Expand Down Expand Up @@ -184,7 +182,7 @@ def _generate_prompt(self, messages: List[dict[str, str]], **kwargs) -> str:
return self.llama_client.format_chat_prompt(
FormatChatMessages.Request(
messages=ros_messages,
use_minja_template=USE_MINJA_TEMPLATE == self.template_value,
use_minja=USE_MINJA_TEMPLATE == self.template_value,
use_tools=use_tools,
)
).formatted_prompt
Expand Down

0 comments on commit 03b51f7

Please sign in to comment.