Custom ChatBot for my startup

Hello guys,

So I am trying to build a chatbot for my startup. It should be able to act as a mental health companion to individuals.

I have tried the ChatCompletion method with the gpt-3.5-turbo model. But there have been many cases where it doesn’t respond the way I expect it to even though I set the system role to:

You are a mental health companion that can provide help and offer mental health advices and tips to people

Now I want to be able to improve this. I have collected some data in a text file and I know I can try:

  • Fine-Tuning (I don’t know how to prepare my data for this)
  • Creating vector embeddings from my data, storing and inferencing from a vector database service provider (I haven’t found a guide to do this)

I am open to any suggestions. And possibly implementation links and guides.

Here is a short breakdown of what my code looks like:

messages = [{"role": "system", "content": "You are a mental health companion that can provide help and offer mental health advices and tips to people"}]

connected_clients = set()  # Store WebSocket connections
@app.websocket("/chatComplete") # WebSocket route
async def websocket_endpoint(websocket: WebSocket):
    await websocket.accept()
    connected_clients.add(websocket)
 
    try:
        while True:
            data = await websocket.receive_text()
            message_history = json.loads(data)
            message_history.insert(0, messages[0])
            response = openai.ChatCompletion.create(
                model = "gpt-3.5-turbo",
                messages = message_history
            )
            ChatGPT_reply = response["choices"][0]["message"]["content"]
            
            await websocket.send_text(ChatGPT_reply) # Broadcast the response to client  
                
    except WebSocketDisconnect:
        connected_clients.remove(websocket)
1 Like

Vector embeddings and semantic search should work best for this use-case. You can use an open-source project like this to get started GitHub - Anil-matcha/ChatPDF: Chat with any PDF. Easily upload the PDF documents you'd like to chat with. Instant answers. Ask questions, extract information, and summarize documents with AI. Sources included. .

Here is a guide if you want to understand ways to implement vector db retrieval How to train a custom GPT on your data with EmbedAI + LlamaIndex | by Anil Chandra Naidu Matcha | Dec, 2023 | LlamaIndex Blog

1 Like

Something tells me I am not the target audience for this product at this point, as opposed to your intended end user.

Obviously I need to really dig in, but never been that good at coding. Learned HTML in the mid 90s and CSS and thats about it. lol Other than taking a visual basic class in high school, which I remember essentially nothing from.

Please let me know if the suggested solution helps. Because consistency is exactly what I am looking for but have yet to find.

If you have a conversation AI working that can remember previous chats, the next step would be improve on the guidance.

20 tokens saying what the AI can already do isn’t much to transform its behavior, and a startup isn’t founded by a magic sentence using another’s product.

If you can’t expand that to 200 or 2000 words detailing every operational mode and behavioral quirk, then you have not hit the wall or come to the skill level where you can put the same quality of information into a fine-tune training file or a knowledge database.

Your input in invaluable.

If you don’t mind me asking, are you a programmer or in the IT field in general?

Clearly you’ve got a strong understanding of working with AI. Trial and error or school taught?

My superhero power is reading. I am more IT technology than programmer.

https://platform.openai.com/docs/guides/prompt-engineering/strategy-provide-reference-text

AI makes finding the answers easier, but sometimes you have to plot your own course, and overcome the expectations you or others might have and experiment. Language fluency and understanding more about AI language generation comes in handy to make this in five minutes just for demonstration:

Note that the above user is employing the forum platform to promote their own site in their every post. There goals may not align with yours.

2 Likes