File size: 2,318 Bytes
bfdbe82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528691c
bfdbe82
 
d8a39d4
bfdbe82
d6fca32
bfdbe82
a59db77
bfdbe82
 
 
 
 
 
 
 
 
a59db77
 
bfdbe82
 
 
 
 
 
 
 
 
 
 
528691c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from utils import get_mongo_collection, groq_calls
from groq import Groq
from dotenv import load_dotenv
import os
import random
import uvicorn
from bson import ObjectId

load_dotenv()



app = FastAPI(title="Mind Dump Summariser")

class ReportRequest(BaseModel):
    user_id: str
    username: str



@app.post("/cron_schedulerbot")
async def cron_test():
    return "Hello Cron Tester"



@app.post("/mindDump")
async def generate_report(request: ReportRequest):
    try:
        userid = request.user_id   
        username = request.username     
        journalcollection = get_mongo_collection()
        cursor = journalcollection.find({"type":"mind_dump","userId":userid}).sort("createdAt",-1).limit(1)
        original = ""
        for item in cursor:
            if item["content"].get('original'):
                # print(item["content"]["original"])
                original = item["content"].get('original')

        print(original)
        
        prompt = f"""
        I am giving you the complete mind dump as written by the user :{original}
        You can greet and address him with his name: {username}
        Now you are working as a keen oberserver who can identify patterns among a series of entangled thoughts
        SO basically there are multiple knots that will be present inside the user's mind. ALl of that he has written in the mind dump
        Now starting from start to finish and linking multiple parts in proper series you have to tell user what he has been expriencing
        You need to untie those knots identifying the problems adn what could possibly be causing them
        You should not bring rememdies or solution externally, whatever you say to the user has to be from what he has written in the mind dump section
        Remember, you're not being asked as a chatbot, you'll have to run just one time and hence whatever output you give should be complete in it's own sense
        You shouldn't ask questions or further clarifications.
 
        """

        final = groq_calls(prompt)

        return {"Summary points": final}

    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e))
    
if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8000)