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

Parser bug -- empty quotes inside triple quotes makes the parser stop. #1254

Open
aaronvg opened this issue Dec 17, 2024 · 0 comments
Open

Comments

@aaronvg
Copy link
Contributor

aaronvg commented Dec 17, 2024

parser bug — empty quotes makes it stop parsing the last two fields usageCode and usageLanguage.

When the raw response is this:

{
      "projectName": "BAMLIntroduction",
      "projectPlan": """
    This simple project will demonstrate BAML's basic capabilities by creating a text analysis function that:
    1. Takes a simple text input
    2. Analyzes its sentiment and content
    3. Returns a structured response
    """,
      "bamlCode": """
    class TextAnalysis {
      sentiment string @description("The overall sentiment of the text: positive, negative, or neutral")
      mainTopic string @description("The main topic or subject of the text")
      wordCount int @description("Number of words in the text")
    }
    
    function AnalyzeText(text: string) -> TextAnalysis {
      client "openai/gpt-4o-mini"
      prompt #"
        Analyze the following text for its sentiment, main topic, and count the words.
        {{ _.role("user") }} {{ text }}
    
        {{ ctx.output_format }}
      "#
    }
    """,
      "bamlTests": """
    test BasicTextAnalysis {
      functions [AnalyzeText]
      args {
        text "I love learning about new programming languages! BAML seems really interesting and useful."
      }
    }
    
    test EmptyTextAnalysis {
      functions [AnalyzeText]
      args {
        text ""
      }
    }
    """,
      "usageCode": """
    from baml_client import b
    from baml_client.types import TextAnalysis
    
    def main():
        # Analyze some sample text
        sample_text = "I love learning about new programming languages! BAML seems really interesting and useful."
        result = b.AnalyzeText(sample_text)
        
        print(f"Sentiment: {result.sentiment}")
        print(f"Main Topic: {result.mainTopic}")
        print(f"Word Count: {result.wordCount}")
    
    if __name__ == "__main__":
        main()
    """,
      "usageLanguage": "python"
    }

The parser will truncate at the first empty quotes:

    {
      ...
      "bamlTests": "
         ... 
           args {
             text
     "
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant