-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
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
Labels
No labels