Skip to content

Dev david isebarn#3

Open
isebarn wants to merge 7 commits intoDatura-ai:mainfrom
isebarn:dev_david_isebarn
Open

Dev david isebarn#3
isebarn wants to merge 7 commits intoDatura-ai:mainfrom
isebarn:dev_david_isebarn

Conversation

@isebarn
Copy link
Copy Markdown

@isebarn isebarn commented Nov 28, 2023

Improved Website: https://test.isebarn.com

An overview of your thoughts on the current project/design, how you improved it, and
what your process was.

My thoughts

The project when I started

I'm not a huge fan of materialUI, or any UI kits. I've used them a lot on the past and they're great to prototype stuff, because the components are all flowing in the same style, but as soon as you need something to look a bit custom, they pose a tremendous difficulty. Since I started using Tailwind (which is fairly recently) I've picked it up fast and it is much easier to work with as soon as you get some momentum with it.

I've specialised in Flask for the past ~6 years. I've never used FastAPI, but it's very similar to Flask it seems, but it looks very good and I suspect it might be even better than Flask. I should research it a bit.

There's not much to say about the "design", it is still in it's infancy, there is no database, no directory structure. However there are tests which I like, it's always very tempting to delay writing tests.

My process

Heres my timeline

. I started up the entire system and tested around for a minute
. I looked over the code a bit to try to fit it in my head
. I reviewed the things requested and made a list of things I wanted to do
. Split that list into backend and frontend
. Decided to allocate 2-3 hours on backend and 2-3 hours on frontend
. Picked out a set of backend/frontend tasks and ordered them in order of importance
. Got to work

Github: https://github.com/isebarn/

FE improvements

  • Set up a nice contrasted color scheme
  • Used a logo from taotensor/logos for the chat "bot" messages
  • Made it look nicer (in my opinion)
  • Chat url can be shared between users
  • Added tailwind as more of a personal choice.

BE improvements

  • Added a conversations global variable that stores all chats:
# example object from the conversations object
uuid: {
	summary, # after the message has been completed a summary is also created
	messages: [
		{
			prompt,
			answer, #(ai response)
			text #(ai image)
		},...
	]
}
  • Conversation chaining.
  • Endpoint to retrieve all conversations
  • Endpoint to retrieve a conversation by it's uuid
  • I would like to remove or resituate the error handlers. In my opinion having error handlers makes code harder to read and does not improve it

Future Improvement Ideas:

What I'd like to do in the backend

  • Convert the naurons.api into a separate service that can be launched individually with docker so that the fastapi has an array of available AI's to communicate with, to minimize wait time for users

  • Database to store chats (right now I just added a dictionary as a global variable).

  • Optionally redis or some sort of fast access storage for chats that are ongoing

  • Refactor a bit.
    I just tossed all methods into the same file.
    Normally I would never do that but since I'm working with a global dictionary for the conversations I didn't really have a choice.
    But I can say that I would structure somewhere along the lines of this:

    prompt_utils.py

    • create_conversation_string
    • create_summary_prompt
    • create_history_prompt

    utils.py

    • process_message

    data.py (some database layer)

    • update_conversation_image
    • update_conversation_messages
    • set_conversation_summary
  • Research if a service like Pusher would do better than StreamingResponse, but that might be better suited once there is more traffic.

  • Set up error monitoring like Sentry

What I'd like to do in the frontend

  • Home page where a user can log in and logged in users can see existing chats
  • Dedicated history page to make it easier to find older chats. This is a missing feature in chatGPT.
  • Find more ways to make the UI nicer. I didn't want to completely copy chatGPT but I used that as a baseline
  • Show all the images generated instead of just the first one
  • Add a dark mode

Functionality ideas

  • I've already added a "summary" to a chat, it would be cool to also detect a few different "types", like "question", "troubleshooting", "research" so that when users look through their chats they can more easily find something. Maybe someone was doing price comparison on a product, which would be labeled "research"
  • Share the chat with a URL, Many people in the same chat
  • Regenerate answer
  • When starting a new chat it would be nice to have chat types, which in the background would add further context to the chat. For example starting a "teacher chat" and would tell the AI that the user is asking for detailed explanations on something rather than general information on it
  • Quiz option where a user can get quizzed on a topic
  • Sentiment analysis on prompts to gauge users mood and use that to tune responses
  • Allow users to define their own custom instructions that get applied automatically to every chat

FE:
Generates/Reads UUID from URL. Sends UUID along with prompt.

BE:
Added a global dictionary "conversations"
conversations.messages is a list of messages
conversations.summary is a AI generated summary of the messages in the conversation
FE:
Fetches the conversation from the UUID
Transforms the messages to the correct format that the page expects

BE:
Create a history prompt from the conversation so that the response from a prompt follows the context of the conversation
Endpoint to return all messages from a conversation
Moved the messages transformation logic from the FE to the BE
use icons for user/bot and for send button
make the chat window easier on the eyes
separate user/bot by gray
- add images to conversation history
- return images with conversation responses
- swap out ImagePreview for img
- Change user messages to have slated background instead of bot messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant