Skip to content

Is there an example of Chainlit working with Microsoft Guidance #192

@skprasadu

Description

@skprasadu

Microsoft Guidance seem to be a powerful prompt engineering tool. Is there a working example of how chainlit works with this.

I came up with an example, but not sure if this is a best practice.

@cl.on_chat_start
def start_chat():
    guidance.llm = guidance.llms.OpenAI(...)

@cl.on_message
async def main(message: str):
    program = guidance('''
        {{#system~}}
        You are a helpful assistant
        {{~/system}}

        {{~#geneach 'conversation' stop=False}}
        {{#user~}}
        {{set 'this.user_text' (await 'user_text')  hidden=False}}
        {{~/user}}

        {{#assistant~}}
        {{gen 'this.ai_text' temperature=0 max_tokens=300}}
        {{~/assistant}}
        {{~/geneach}}''')

    program = program(user_text =message)
    
    print(program['conversation'])

    await cl.Message(content=str(program)).send()

This works great. But I get below prompt in my frontend. Not sure if there is a way to format this.

Chatbot

09:37:33 PM

<|im_start|>system
You are a helpful assistant<|im_end|>
<|im_start|>user
hi there<|im_end|>

    <|im_start|>assistant

Any help will be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions