Skip to content

Commit

Permalink
Merge pull request #1 from bovem/dev
Browse files Browse the repository at this point in the history
Added subcommand summarize to generate a draft for bragging document using the information stored in BRAG_DOCS_LOC
  • Loading branch information
bovem committed Jan 16, 2024
2 parents ba3f713 + 5ec9cde commit 8289e54
Show file tree
Hide file tree
Showing 6 changed files with 279 additions and 12 deletions.
97 changes: 92 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ curl -L https://github.com/bovem/brag/releases/download/v0.1/brag-linux-amd64 >
```

## Setup and Usage

### Initialize
To initialize a bragging document directory create a Git repository on any provider
like GitHub, GitLab, BitBucket, etc., and clone the repository locally. You can also
create a local Git repository using `git init`.
Expand All @@ -36,6 +38,7 @@ using the `init` subcommand.
brag init
```

### Adding a new brag
You can add your brags using the `-c`/`--comment` flag.
```bash
brag -c "YOUR TEXT HERE"
Expand All @@ -44,6 +47,7 @@ brag -c "YOUR TEXT HERE"
The brags will be added to the directory specified in the `BRAG_DOCS_LOC` environment
variable.

### Review your brags
To review brags added in a given time period use subcommand `about`.
```bash
brag about last-week
Expand All @@ -52,11 +56,7 @@ brag about last-week
If the `BRAG_DOCS_REPO_SYNC` environment variable is set to `true` then new brags
will be committed and pushed to the Git remote.

## Todos
- [ ] Add a `edit` subcommand to edit recent entries
- [ ] Add a `summarize` subcommand to create a formatted bragging document using LLMs hosted on Ollama

## Sample Output
#### Sample Output
```text
2024-01-02
* 11:12:50 Updated Quarterly Status Report
Expand All @@ -68,3 +68,90 @@ will be committed and pushed to the Git remote.
2024-01-04
* 17:39:50 Provisioned a new Kubernetes cluster
```

### Summarize your brags using self hosted LLMs
To summarize the accomplishments and build a draft for bragging document use the command
`summarize` with a timeframe (similar to `about` command).
```bash
brag summarize last-month
```
If [Ollama](https://www.avni.sh/posts/homelab/self-hosting-ollama/) is deployed and the
`OLLAMA_URL` environment variables is pointing to your Ollama deployment then
a draft bragging document will be generated on your terminal.

Before generating the document the summarize command will ask for the names of your personal
and work project, name of your blog and other content creation channels to differentiate
your work and personal updates in the summarized document.

By default it will use the prompt in [bragDocument.go](./utils/bragDocument.go) but you can
pass your own prompt using the `--prompt` flag.

To select a different model than `llama2:latest` use flag `--model`.

#### Sample Output
```text
Enter the name of your work projects:
Enter the name of your personal projects:
Enter the name of your blog, youtube or any other content creation channels:
Draft Bragging Document
Introduction:
I am excited to share my accomplishments and growth over the past year with you, our esteemed manager and stakeholders. As an integral member of our team, I have been actively contributing to various projects, collaborating with colleagues, and learning new tools and technologies. This document highlights my work achievements, collaboration and mentorship efforts, design and documentation, company building, learning, and outside work contributions.
Work Accomplishments:
1. Project XYZ: As a member of the development team, I designed and built a comprehensive dashboard for monitoring client satisfaction. The dashboard has been instrumental in providing real-time insights into client feedback, enabling us to address their concerns promptly. (hyperlink to Jira ticket)
2. Project ABC: I collaborated with the UX/UI team to redesign a critical feature of the application. My contributions included designing new layouts and providing constructive feedback during the user testing phase, resulting in an improved user experience. (hyperlink to design document)
3. Project DEF: I contributed to the development of a mobile application for a client's business needs. My responsibilities included writing clean, efficient, and well-documented code, ensuring seamless functionality across various platforms. (hyperlink to pull request)
Collaboration and Mentorship:
1. Mentored an intern on the basics of web development, providing guidance on project management, coding best practices, and problem-solving techniques. The intern demonstrated significant improvement throughout the collaboration, showcasing their newfound skills. (hyperlink to mentorship session)
2. Collaborated with cross-functional teams to develop innovative solutions for a client's complex business problem. Through active listening and ideation, we generated several potential ideas and approaches, which were well received by the team and stakeholders. (hyperlink to brainstorming session)
3. Contributed to the creation of an internal knowledge transfer program, providing structured training sessions for new hires. This initiative enhanced the onboarding process, ensuring a smooth transition into our team's workflow. (hyperlink to knowledge transfer session)
Design and Documentation:
1. Created comprehensive design documents for each project, including wireframes, mockups, and style guides. These resources were instrumental in communicating design intent to the development team and stakeholders. (hyperlink to design document)
2. Developed a standard operating procedure (SOP) for our team's documentation process, streamlining the creation and maintenance of technical documents. This initiative has resulted in increased efficiency and consistency across our projects. (hyperlink to SOP document)
Company Building:
1. Participated in the interviewing and recruiting process, contributing to the identification and hiring of top talent for our team. (hyperlink to job postings)
2. Created an updated new hire guide, providing comprehensive information on our team's workflow, tools, and best practices. This document has been instrumental in ensuring a smooth transition for new team members. (hyperlink to new hire guide)
3. Contributed to the development of internal training programs, enhancing the skills of our team members and fostering a collaborative learning environment. (hyperlink to training program)
Learning:
1. Expanded my knowledge of emerging technologies such as React Native, GraphQL, and Machine Learning. Through hands-on projects and collaboration with colleagues, I have gained a deeper understanding of these tools and their potential applications in our workflows. (hyperlink to personal project)
2. Participated in industry events, conferences, and meetups, showcasing our team's work and engaging with peers. These experiences have provided valuable insights into the latest trends and innovations in our field. (hyperlink to event report)
Outside of Work:
1. Published articles on Hacker Noon and other industry platforms, sharing my experiences and insights on web development best practices. The articles have received positive feedback from peers and industry leaders, with several shares and likes on social media platforms. (hyperlink to article)
2. Contributed to OpenSource projects, such as [insert project name], providing new features and enhancements that benefit the broader development community. (hyperlink to OpenSource project)
3. Received recognition from industry leaders and peers for my work in web development, including a mention in [insert publication name] and an award at [insert event name]. (hyperlink to publication or event)
Personal Projects:
1. Developed a personal website showcasing my work and projects, serving as a portfolio and networking tool. (hyperlink to personal website)
2. Created a blog focusing on web development best practices and emerging technologies, providing valuable insights and resources for the industry. (hyperlink to blog)
3. Fostered a community of developers through social media platforms, sharing knowledge and collaborating on projects. (hyperlink to social media channel)
Conclusion:
In conclusion, I have demonstrated significant growth and achievements in my role as a web developer within the past year. Through active collaboration, mentorship, design and documentation, company building, learning, and outside work contributions, I have enhanced our team's workflows, fostered a culture of innovation and excellence, and expanded my skill set. I look forward to continuing to contribute to our team's success in the future.
Additional Information:
Personal Projects:
* Website: [insert website link]
* Blog: [insert blog link]
* Social Media Channel: [insert social media channel link]
Note: The above document is a draft and may require revisions based on your feedback. Please feel free to provide your inputs and suggestions, and I will be more than happy to incorporate them into the final document.
```

## Todos
- [ ] Add a `edit` subcommand to edit recent entries
- [x] Add a `summarize` subcommand to create a formatted bragging document using LLMs hosted on Ollama
4 changes: 3 additions & 1 deletion cmd/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/bovem/brag/utils"
"github.com/spf13/cobra"
"strings"
"fmt"
)

var timeFrame string
Expand All @@ -21,7 +22,8 @@ The time period has to be specified in any of the following formats
* today/yesterday/last-week/last-month (brag about last-week/brag about yesterday)
`,
Run: func(cmd *cobra.Command, args []string) {
utils.Bragging(strings.Join(args, " "))
brags := utils.Bragging(strings.Join(args, " "))
fmt.Println(brags)
},
}

Expand Down
38 changes: 38 additions & 0 deletions cmd/summarize.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cmd

import (
"github.com/bovem/brag/utils"
"github.com/spf13/cobra"
"strings"
)

var model string
var prompt string

var summarizeCmd = &cobra.Command{
Use: "summarize",
Short: "Summarizes the brags from the specified time period in a draft bragging document.",
Long: `Summarizes brags from the specified time period using Large Language Models hosted on Ollama (https://ollama.ai/)
and generates a draft bragging document.
Requires following environment variable (assuming Ollama is already deployed and the model is downloaded).
$ export OLLAMA_URL="http://localhost:11434"
For Example:
brag summarize --model llama2:latest last-month
brag summarize --model llama2:latest 2-weeks
The time period has to be specified in any of the following formats
* <numeric-time>-<range-of-days> (brag about 2-months/brag about 3-years)
* today/yesterday/last-week/last-month (brag about last-week/brag about yesterday)
`,
Run: func(cmd *cobra.Command, args []string) {
utils.Summarize(strings.Join(args, " "), model, prompt)
},
}

func init() {
rootCmd.AddCommand(summarizeCmd)
summarizeCmd.PersistentFlags().StringVarP(&model, "model", "m", "llama2:latest", "LLM Model to be used while generating the bragging document")
summarizeCmd.PersistentFlags().StringVarP(&prompt, "prompt", "p", utils.BragDocTemplate, "LLM Prompt for generating the bragging document")
}
16 changes: 10 additions & 6 deletions utils/bragAbout.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"io/ioutil"
)

func Bragging(timeFrame string)(){
func Bragging(timeFrame string)(string){
bragDocDirLocation := os.Getenv("BRAG_DOCS_LOC")
currentTime := time.Now()
currentYear := strconv.Itoa(currentTime.Year())
Expand Down Expand Up @@ -56,10 +56,12 @@ func Bragging(timeFrame string)(){
}

startBraggingFrom := currentTime.AddDate(-numYear, -numMonth, -numDay)
LoopOverFileRange(currentYearDir, startBraggingFrom, endBraggingAt)
fileContents := LoopOverFileRange(currentYearDir, startBraggingFrom, endBraggingAt)
return fileContents
}

func LoopOverFileRange(fileDirectory string, startTime time.Time, endTime time.Time)(){
func LoopOverFileRange(fileDirectory string, startTime time.Time, endTime time.Time)(string){
var fileContents string
tomorrow := endTime.AddDate(0, 0, 1)
curDoc:=startTime

Expand All @@ -75,15 +77,17 @@ func LoopOverFileRange(fileDirectory string, startTime time.Time, endTime time.T
documentContent, err := ioutil.ReadFile(currentDocName)
if err!=nil {
fmt.Printf("Failed to open file: %s\n", currentDocName)
return
continue
}
//documentContentStr := strings.Replace(string(documentContent),
// "# Bragging Items", "", -1)
//documentContentStr = strings.Replace(documentContentStr,
// "\n", "", 1)
fmt.Println(currentDateStr)
fmt.Printf("%s\n", string(documentContent))
fileContents += fmt.Sprintf("%s\n", currentDateStr)
fileContents += fmt.Sprintf("%s\n", string(documentContent))
}
curDoc = curDoc.AddDate(0, 0, 1)
}

return fileContents
}
58 changes: 58 additions & 0 deletions utils/bragDocument.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package utils

var BragDocTemplate = `Draft a bragging document from my perspective
using only the journal data provided below.
The document should be written in a formal tone as it has to be shared
with my manager and stakeholders and it impacts my personal growth.
Omit the fields you think don't have enough information in journals.
The document should be in the following format, the project names and content
mentioned in following format is just an example don't use it in the final output
Use the pointers provided in the format below and omit them in the final output:
# Work Accomplishments
Insert the list of personal work done in great detail, mentioning important
hyperlinks like Jira tickets, pull request links, and other relevant document links
. It should be grouped by projects.
Emphasize the following points
* If I designed or built something from scratch
* Useful insights during the design or coding process
* Impact of individual projects
* Using numbers to show impact like reduced response time by X%, decreased cloud costs by X%.
# Collaboration and Mentorship
Write about collaboration and mentorship work done by me in bullet points.
Emphasize the following points
* Write about each point in great detail supporting it with hyperlinks when necessary
* Write about the conclusion from each point. As in the final impact of helping the intern
* Points about helping others with the skills that I know.
* Improving monitoring and logging
* Code reviews and merge request collaborations
* Important questions and meetings attended
* Giving talks or conducting workshops and hackathons internally
# Design and Documentation
Write about design and documentation efforts.
# Company Building
Write in bullet points about the interviewing and recruiting process contributions from my side.
Also write about contributions to the new hire guide, onboarding documents, and Knowledge Transfer sessions
with the new hires.
# Learning
Write about tools and technologies learned throughout the period and how they could be useful in our
current workflows.
# Outside of Work
Write about blog posts, videos, or any other content creation outside the work that is somehow related to
the work. Also, write about
* Talks and event participation
* Contributing to OpenSource projects
* Recognition from any other part of the industry. Like awards.
Additional information about personal projects and blogs will be mentioned after the journal.
Do not add additional information which is not present in the journal.
`
78 changes: 78 additions & 0 deletions utils/bragSummarize.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package utils

import (
"fmt"
"net/http"
"io/ioutil"
"bytes"
"encoding/json"
"os"
)

type ModelResponse struct {
Response string `json:"response"`
}

func Summarize(timeFrame string, model string, prompt string) () {
ollamaUrl := os.Getenv("OLLAMA_URL")
url := fmt.Sprintf("%s/api/generate", ollamaUrl)

bragJournal := Bragging(timeFrame)
prompt += fmt.Sprintf("\nJournal:\ns", bragJournal)

var workProjects string
var personalProjects string
var blogsAndVideos string

fmt.Print("Enter the name of your work projects:")
fmt.Scanf("s", workProjects)
prompt += "\nNames of Work Projects: " + workProjects

fmt.Print("Enter the name of your personal projects:")
fmt.Scanf("s", personalProjects)
prompt += "\nNames of Personal Projects: " + personalProjects

fmt.Print("Enter the name of your blog, youtube or any other content creation channels:")
fmt.Scanf("s", blogsAndVideos)
prompt += "\nNames of blog, youtube channels or any other content creation channels: " + blogsAndVideos

client := &http.Client{}
body, err := json.Marshal(map[string]interface{}{
"model": model,
"prompt": prompt,
"stream": false,
})
if err != nil {
fmt.Println("Error marshaling JSON body")
return
}

req, err := http.NewRequest("POST", url, bytes.NewReader(body))
if err != nil {
fmt.Println("Error creating new HTTP request")
return
}

req.Header.Set("Content-Type", "application/json")

resp, err := client.Do(req)
if err != nil {
fmt.Println("Error making POST request to URL", url)
return
}

body, err = ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body")
return
}

var modelResponse ModelResponse
err = json.Unmarshal(body, &modelResponse)
if err != nil {
fmt.Println("Error unmarshaling JSON response body")
return
}

fmt.Println(modelResponse.Response)
}

0 comments on commit 8289e54

Please sign in to comment.