Skip to content

Commit

Permalink
summarize on summary page load
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-fenton committed Sep 15, 2024
1 parent 947d39c commit 93f2b37
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
16 changes: 8 additions & 8 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
CONTEXT = ("This is a transcription of my speech in a stream of consciousness style. "
"I want you to write the transcribed text into a casual but coherent piece of paragraph form writing while "
"retaining my voice and tone so it still sounds like I wrote it. "
"Only return the summarized text and nothing else. Don't prefix the response with anything.")
"Only return the summarized text and nothing else.")

class NoteContent(BaseModel):
text: str
Expand Down Expand Up @@ -95,28 +95,28 @@ async def summarize(note: NoteContent):

@app.post("/create_note")
async def create_note(note: NoteIn):
note = Note(
note_obj = Note(
title=note.title,
text=note.text,
date_posted=datetime.now()
)

new_note = await notes_collection.insert_one(note.dict())
new_note = await notes_collection.insert_one(note_obj.dict())

db_note = await notes_collection.find_one({"_id": new_note.inserted_id})
db_note['date_posted'] = db_note['date_posted'].strftime("%Y-%m-%d %H:%M:%S")

# Add note to search engine db
journal_entry = "Date posted: " + db_note['date_posted'] + "Content: " + note.text
journal_entry = "Date posted: " + db_note['date_posted'] + "Content: " + note_obj.text
search_engine_service.insert_entry(journal_entry)

note_parsed = {
"id": str(note["_id"]),
"title": note["title"],
"content": note["content"],
"id": str(db_note["_id"]),
"title": db_note["title"],
"text": db_note["text"],
}

return note_parsed
return str(note_parsed)

@app.post("/query_journal")
async def query(query: Query):
Expand Down
26 changes: 22 additions & 4 deletions frontend/src/routes/summary.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
import axios from "axios";
import { useState } from "react";
import { useEffect, useState } from "react";
import { Button, Flex, Input } from "antd";
import { EditFilled } from "@ant-design/icons"
import "../styles/Summary.css"

const BACKEND_URL = "http://127.0.0.1:8000/create_note";
const BACKEND_URL = "http://127.0.0.1:8000/";

function Summary() {
function Summary({transcript}) {
const { TextArea } = Input;

const [title, setTitle] = useState("");
const [summary, setSummary] = useState("I spent most of the afternoon working on the new prototypes, and it was one of those rare times where I lost track of time because I was so into it. The ideas were just flowing, and everything felt right. It’s such a rush when that happens, you know? When it's just me, the screen, and a cup of coffee, and things are working. It reminded me why I love this job in the first place.");

useEffect(() => {
summarize();
}, []);

const summarize = async () => {
try {
if (transcript.length > 0) {
const response = await axios.post(BACKEND_URL + "summarize", {
text: transcript
});
console.log(response.data);
setSummary(response.data);
};
} catch (err) {
console.error(err);
}
}

const postNote = async (note) => {
try {
console.log(note)
const response = await axios.post(BACKEND_URL, {
const response = await axios.post(BACKEND_URL + "create_note", {
title: title,
text: note
});
Expand Down

0 comments on commit 93f2b37

Please sign in to comment.