-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from bovem/dev
Added subcommand summarize to generate a draft for bragging document using the information stored in BRAG_DOCS_LOC
- Loading branch information
Showing
6 changed files
with
279 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |