2023-09-29: Back on my own
Tags: devjournal
Published: 2023-10-02 03:43:06

Sorry, I forgot to write the blog post on Friday, again, but here I am writing it on Sunday.

Anyway, I ended up breaking away from the 3-man team that we'd been working together as for the past 2 weeks or so for the login and registration, and honestly, I don't think it required more than 2 people, anyway.

The first solo project I was assigned to was to going back to WebSockets to build a little chatroom. There was a Github with the code, and all my boss wanted me to do was set that up so it would run a FastAPI server on a different port from the main app, and you can just go to an address to start chatting away in there with a basic HTML page.

While we'd already made a test app for WebSockets, the main idea here was for me to start thinking about logging and what sort of protocols we should start assembling for such a thing.

Logging seems like a simple thing to accomplish, but there is definitely some nuance that tends to get overlooked, like how to archive them, where to actually place the lines so that it actually logs useful information, and thinking about levels of logs, like info, warning, error, etc.

We decided that we were going to use Loguru for our Python logging, which seems to be pretty robust and definitely very simple to use. You just add a line like this: `logger.add("./logs/file_{time}.log", enqueue=True, rotation="15 minutes")` and then call `logger.info("string")` wherever needed. There are a bunch of options for it, as well, such as backtracing and diagnosing.

Once I got the logging done pretty well with the WebSockets app, he wanted to try adding logging to another FastAPI app that uses LangChain streams to stream AI chat to the screen, kind of like how it is on the ChatGPT website. It definitely makes for a more interactive experience rather than the normal command line behavior of having to wait for it to output the entire response, which could take upwards of several minutes. At least you can watch the words appear on the screen with a stream.

Unfortunately, I ran into some pretty annoying problems trying to get that LangChain FastAPI app to run via a server connection, particularly in the CORS domain, so I ended up having to give up on making it work.

At this point, which was Thursday afternoon, my boss had already wanted me to start on another project, which was another revisit of a topic. He wanted me to take that data generation that I had had before and start producing more fake data for more legal subpractices, like at least 50 of them from what I could estimate.

From what I'd learned from watching some videos on LangChain, I felt like I could definitely rebuild my old data generation script into a LangChain that would perform far more efficiently and with less overhead. So my most recent task was doing that. Though, my boss also wanted me to help my coworker with adding logging to the main app's backend FastAPI, so I just gave him a rundown on how Loguru works when he told me. Then I got to work thinking about how I'd implement this new LangChain app, and that's where I left off on Friday.

So let's start this week off on that note as I finish this post on a Sunday night. Cheers.