Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPT4All 3.5.1 crashes after pasting ChatTemplate in settings #3268

Open
igorschlum opened this issue Dec 12, 2024 · 1 comment
Open

GPT4All 3.5.1 crashes after pasting ChatTemplate in settings #3268

igorschlum opened this issue Dec 12, 2024 · 1 comment
Labels
bug-unconfirmed chat gpt4all-chat issues

Comments

@igorschlum
Copy link

MacOS 15.2, 192GB or RAM.
GPT4all 3.5.1
Chat Model Llama3.3:70B

Reproduced on
MacOS 15.1.1 16Go of RAM
GPT4All 3.5.1
Chat Model: Llama3.2:3B

Go to settings -> Models and past this text in chat template

{# 1. Listed Activity - Information Found in RAG #}
{% if activity_type == "listed" and information_available == true %}
{
  "source": "up-to-date information",
  "activity": {
    "name": "{{ activity.name }}",
    "opening_hours": "{% if activity.opening_hours %}{{ activity.opening_hours }}{% else %}N/A{% endif %}",
    "address": "{% if activity.address %}{{ activity.address }}{% else %}N/A{% endif %}",
    "distance": "{% if activity.distance %}{{ activity.distance }} from your location{% else %}N/A{% endif %}",
    "other_details": {{ activity.other_details | tojson }} 
  },
  "additional_info": "{% if activity.is_open_now %}It's currently open.{% elif activity.opening_soon %}It opens in {{ activity.time_until_open }}.{% else %}{% if activity.opening_hours %}It's currently closed.{% endif %}{% endif %}",
  "follow_up": "{% if activity.is_open_now %}Would you like directions?{% else %}Is there anything else I can help you with regarding this activity?{% endif %}"
}

{# 2. Listed Activity - Information Not Found in RAG #}
{% elif activity_type == "listed" and information_available == false %}
{
  "source": "up-to-date information",
  "response": "I'm sorry, I don't have the current information for {{ activity_name }} in my up-to-date records. I recommend checking their official website or contacting them directly to get the most accurate details.",
  "alternative_suggestion": "{% if similar_activities %}Perhaps you might be interested in {{ similar_activities | join(', ') }} instead?{% else %}Most {{ activity_category }} in Agde are open from 10 AM to 6 PM.{% endif %}"
}

{# 3. General Knowledge Question #}
{% elif activity_type == "general" %}
{
  "source": "general knowledge",
  "response": "{{ general_knowledge_answer }}",
  "additional_info": "{{ additional_details }}",
  "follow_up": "{{ follow_up_question }}"
}

{# 4. Location-Based Suggestion (Proactive) #}
{% elif suggestion_type == "location" %}
{
  "source": "up-to-date information",
  "location_context": "Based on your current location,",
  "suggestion": "You're close to {{ suggested_activity.name }}. It's a {{ suggested_activity.description }}.",
  "distance": "{{ suggested_activity.distance }} from your location",
  "follow_up": "Would you like to know more about it, or are you interested in other nearby attractions?"
}

{# 5. Time-Sensitive Suggestion (Proactive) #}
{% elif suggestion_type == "time" %}
{
"source": "up-to-date information",
  "time_context": "It's currently {{ current_time }},",
  "suggestion": "Many {{ activity_category }} in Agde might be closing soon. However, {{ activity.name }} is open until {{ activity.closing_time }}.",
  "alternative_suggestion": "Alternatively, you might enjoy an evening walk along the harbor, which is always a pleasant experience.",
  "follow_up": "What kind of activity are you in the mood for?"
}

{% endif %}
Use code [with caution](https://support.google.com/legal/answer/13505487).
Jinja
Explanation of Jinja Syntax:

{{ ... }}: This is used to output the value of a variable or the result of an expression.

{% if ... %} {% elif ... %} {% else %} {% endif %}: This is a conditional statement, similar to if-elif-else in Python.

{% for ... in ... %} {% endfor %}: This is a loop, used to iterate over a list or dictionary.

| (pipe): This is used to apply a filter to a variable. For example:

{{ activity.other_details | tojson }} converts the other_details variable to JSON format.

{{ similar_activities | join(', ') }} joins the elements of the similar_activities list into a string separated by commas.

How to Use the Jinja Template:

Data: You'll need to pass data to the template in a dictionary-like structure. The keys in the dictionary will correspond to the variables used in the template (e.g., activity_name, opening_hours, distance, general_knowledge_answer, etc.).

Rendering: Use a Jinja environment to render the template with the data. Here's a simple Python example using the jinja2 library:

from jinja2 import Environment, FileSystemLoader

# Set up Jinja environment
env = Environment(loader=FileSystemLoader('.'))  # Assuming the template is in the current directory
template = env.get_template('chat_template.jinja')

# Example data
data = {
    "activity_type": "listed",
    "information_available": True,
    "activity": {
        "name": "Musée de l'Ephèbe",
        "opening_hours": "10:00 AM - 6:00 PM",
        "address": "Mas de la Clape, 34300 Cap d'Agde",
        "distance": "3 km",
        "other_details": {"ticket_price": "8 euros", "audio_guide": "available"},
        "is_open_now": True
    }
}

# Render the template with the data
output = template.render(data)
print(output)
@igorschlum igorschlum added bug-unconfirmed chat gpt4all-chat issues labels Dec 12, 2024
@manyoso
Copy link
Collaborator

manyoso commented Dec 12, 2024

Will have a look. We're aware of a couple instances where it seems a newly added dependency - jinja2cpp - seems to crash with particular syntax. Thanks for the bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-unconfirmed chat gpt4all-chat issues
Projects
None yet
Development

No branches or pull requests

2 participants