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

Document efficient development and testing workflow #254

Open
MarcSkovMadsen opened this issue Jun 18, 2023 · 1 comment
Open

Document efficient development and testing workflow #254

MarcSkovMadsen opened this issue Jun 18, 2023 · 1 comment

Comments

@MarcSkovMadsen
Copy link

MarcSkovMadsen commented Jun 18, 2023

I'm new to guidance and handlebars templates.

I can see that I need to learn how to setup an efficient workflow, modularize my code and configure automated testing. This is not currently well described.

Please

  • Describe the existence and use of guidance.llms.Mock().
  • Describe an example of using pytest and the Mock
  • Describe a recommended workflow for developing, modularizing and testing some larger Program/ template/ prompt.
@MarcSkovMadsen
Copy link
Author

Pytest and Mock Example

An example like the below would have helped really a lot. Took me 1 hour and involved exploring the guidance repository, the guidance issues and trying out creating my own mock etc.

import guidance
import pytest

def test_guidance_mock_example():
    # Given
    guidance.llm = guidance.llms.Mock(["The answer is 2"])

    template = """
{{#user~}}
What is 1+1
{{~/user}}
{{#assistant~}}
{{gen 'result'}}
{{~/assistant}}
"""
    
    # When
    program = guidance(template)
    result = program()
    # Then
    assert result.text == """
<|im_start|>user
What is 1+1<|im_end|>
<|im_start|>assistant
The answer is 2<|im_end|>
"""

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