Chainlit / chainlit

Build Conversational AI in minutes ⚡️
https://docs.chainlit.io
Apache License 2.0
6.1k stars 777 forks source link

How to debug a chainlit app #785

Open holleymcshan opened 4 months ago

holleymcshan commented 4 months ago

Hi there!

I've built my first chainlit app. It's very simple and it runs like this.

cd ./chainlit-backend
chainlit run app.py -h

Start the React app


cd ./frontend
npm i
npm run dev

How do I set it where I set break points in my IDE and debug? I'm currently using cursor but I have VS code and intellij as well. Any guidance would be amazing-- I would love to move forward but I think I'll be stumped until I can play around with breakpoints. Thank you
maciejwojcik86 commented 4 months ago

Hi,

In your main application script add: if __name__ == "__main__": from chainlit.cli import run_chainlit run_chainlit(__file__)

Then run the script from your IDE in debug mode. I hope this will help. Best

rauchrob commented 4 months ago

In your main application script add: if __name__ == "__main__": from chainlit.cli import run_chainlit run_chainlit(__file__)

Then run the script from your IDE in debug mode. I hope this will help. Best

That's exactly how we do it as well. I think it should be added to the documentation.

dahifi commented 4 months ago

I put in a PR.

Added this under 'advanced features' in the docs, although I also feel it should be in the cookbook as well.

fdaligand commented 1 month ago

I believe this pull request (https://github.com/Chainlit/docs/pull/107) is merged. I'm new to GitHub project (and contributing also!), but in my experience, merged pull requests are automatically closed. Why is it not the case here? I can help if needed.

rauchrob commented 1 month ago

I believe this pull request (Chainlit/docs#107) is merged. I'm new to GitHub project (and contributing also!), but in my experience, merged pull requests are automatically closed. Why is it not the case here? I can help if needed.

I think the PR is not linked to this issue.

image