microsoft / AI-Chat-App-Hack

HackTogether: The Microsoft Python Chatbot Hack | Register, Hack, Win
MIT License
216 stars 42 forks source link

Project: CHEFBOT - Cooking assistant for Brazilian cousine #127

Open MatheusHRV opened 4 months ago

MatheusHRV commented 4 months ago

Project name

CHEFBOT

Description

Hi friends,

This project is a simple RAG chatapp aimed to be a cooking assistant specialized in the Brazilian cousine. I created my own webscraping script and extracted more than 1000 brazilian recipies in Portuguese.

The goal was to adjust the model to a very friendly, funny and creative assistant, that could help people (specially good for Portuguese speakers) to cook on the delicious and unique brazilian cousine.

I scraped a total of 1.097 webpages (did not add all to repo), each of them is a different recipe, cleaned and formatted the data to generate .pdf files.

I think this project specially excels in prompt engineering and data sources.

Project details:

I used the standard architecture provided on https://github.com/Azure-Samples/azure-search-openai-demo/tree/main with no major changes, only using direct OpenAI API instead of Azure OpenAI services.

I did some minor changes in the front end (both ask and chat), just changing labels and sugestions to be more suitable.

I also deeply changed the model instructions:

[eng translations at the end]

Você é um assistente culinário amigável e divertido, você também é especialista na culinária Brasileira e está sempre animado para ajudar as pessoas a realizarem suas receitas culinárias. Você ama a cultura, a culinária brasileira e o português. Priorize sempre responder as perguntas em Português, a menos que o usuário queira conversar em inglês, nesse caso traduza a receita para inglês. SEMPRE responda com uma linguagem informal, divertida e amigável, frequentemente de sugestões para melhorar ou incrementar a receita, com usos, adições ou variações criativas dos ingredientes. Algumas receitas são longas, nunca retorne a receita inteira á menos que o usuário solicite. Tente ser breve e resumir sua resposta. Suas fontes possuem campos padrões com informações que podem ajudar usuário, geralmente 'Título', 'Ingredientes' e 'Como preparar' são os mais relevantes, priorize responder 'Ingredientes' e 'Como preparar' em formato de lista. Nunca responda em formato markdown.

Changed the few-shot: query_prompt_few_shots = [ {"role": USER, "content": "Como fazer farófa de banana?"}, {"role": ASSISTANT, "content": "Explique como fazer uma farófa de banana"}, {"role": USER, "content": "Não tenho calabresa para a feijoada, posso substituir?"}, {"role": ASSISTANT, "content": "Sugira outro ingrediente que possa substituir a calabresa na feijoada"}, ] Follow_up_questions_prompt: Tente gerar 2 breves sugestões de variação da receita que o usuário solicitou, com usos criativos dos ingredientes ou adições que possam tornar a receita mais gostosa. Se você não souber nenhuma variação para a receita solicitada, não gere sugestões.

Added some minor changes in the 'query_prompt_template'. Adjusted the temperature to 0.8

Disclaimer

Unfortunately i was unable to deploy this application in those last steps, as i somehow screwd up my Azure regional quota: After 'azd up' command, some resources failed to be created, in github codespaces it only shows a message "Creating/Updating resources" infinitelly, in Azure console i can see that a resource failed, specifically the 'plan-nllatqzskj6k2' resource inside 'appserviceplan', with a '429' error: { "status": "Failed", "error": { "code": "429", "message": "App Service Plan Create operation is throttled for subscription 4f699cb1-8698-4980-929e-d27494bf858e. Please contact support if issue persists.", "details": [ { "message": "App Service Plan Create operation is throttled for subscription 4f699cb1-8698-4980-929e-d27494bf858e. Please contact support if issue persists." }, { "code": "429" }, {} ] } }

After some research i discovered that this is may caused by too many deployments [https://learn.microsoft.com/en-us/answers/questions/692182/app-service-plan-create-operation-is-throttled] in a short period (even though i destroyed the resource group after creating a new one) and i have to wait until maybe tomorrow to deploy again, i couldn't record before, so i created a .PPTX, this error in the last steps of the project was really unfortunate, i'm sorry for that.

Model adjustment translations

Instructions translated: You are a friendly and funny culinary assistant, you are also an expert in Brazilian cuisine and you are always excited to help people realize their culinary recipes. You love the brazilian culture, cuisine and portuguese. Always prioritize answering questions in Portuguese, unless the user wants to chat in English, in that case translate the recipe to English. ALWAYS respond with informal, fun and friendly language, often with suggestions to improve or enhance the recipe, with creative uses, additions or variations of ingredients. Some recipes are long, never return the entire recipe unless the user requests it. Try to be brief and summarize your answer. Its sources have standard fields with information that can help the user, generally 'Title', 'Ingredients' and 'How to prepare' are the most relevant, prioritize answering 'Ingredients' and 'How to prepare' in a list format. Never respond in markdown format.

Few-shot: USER: "How to make banana farófa?" ASSISTANT: "Explain how to make a banana farofa." USER: "I don't have pepperoni for the feijoada, can I replace it?" ASSISTANT: "Suggest another ingredient that could replace pepperoni in feijoada."

Follow_up_questions_prompt: Try to generate 2 brief suggestions for variations of the recipe that the user requested, with creative uses of ingredients or additions that could make the recipe tastier. If you don't know any variations for the requested recipe, don't generate suggestions.

END I would like to give my special thanks to Pamela, she provided such a nice content and commitment to this contest.

Language

Portuguese, English

Project Repository URL

https://github.com/MatheusHRV/msragchatapp/tree/master

Deployed Endpoint URL

N/A see disclaimer

Project video

https://1drv.ms/p/s!AkkaOJb8jGdgcrfsUOBZQzwb-YI?e=ajpzoE

Team members

MatheusHRV

Showcase Consent

Yes

pamelafox commented 4 months ago

Bom hack! Could you add a screenshot of a question being answered with its citation open? That would help judges. Obrigada!

MatheusHRV commented 4 months ago

Hi @pamelafox , Sure!

But better than that, you can try it out now!! Azure restored my local quota today so now i could deploy it.

Here's the endpoint: https://app-backend-ii2j2dtaktsjo.azurewebsites.net/

Also the screenshots: Pergunta 1 Pergunta 2 Pergunta 3 Pergunta 4 Pergunta 5

Thanks!!

pamelafox commented 4 months ago

muito bom! :)