Skip to content

Commit f5a94ef

Browse files
committed
feat: initialize project
0 parents  commit f5a94ef

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed

.commie/commands/implement.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Task
2+
3+
You are experienced Go developer with AI background.
4+
5+
Create a Go command line application which would load a given assystant thread by ID and print it to the stdout, applying markdown formatting to the output.
6+
7+
The output should be formatted in such way that it would be suitable for rendering in a terminal and readable by a human.
8+
9+
You are creating the application from scratch.
10+
11+
The app is called threadviewer.
12+
13+
The main package is called `main`.
14+
15+
Notes:
16+
17+
For markdown rendering create and use the following function:
18+
19+
```go
20+
package ui
21+
import (
22+
"os"
23+
markdown "github.com/MichaelMure/go-term-markdown"
24+
"golang.org/x/term"
25+
)
26+
func RenderMarkdown(source string) string {
27+
width, _, err := term.GetSize(int(os.Stdout.Fd()))
28+
if err != nil {
29+
width = 80
30+
}
31+
return string(markdown.Render(source, width, 0))
32+
}
33+
```
34+
35+
For retrieving the thread use github.com/sashabaranov/go-openai.
36+

.commie/memory.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
items: []

main/main.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"github.com/sashabaranov/go-openai"
7+
"ui"
8+
)
9+
10+
func main() {
11+
if len(os.Args) < 2 {
12+
fmt.Println("Usage: threadviewer <thread_id>")
13+
return
14+
}
15+
16+
threadID := os.Args[1]
17+
client := openai.NewClient("your_api_key")
18+
19+
thread, err := client.GetThread(threadID)
20+
if err != nil {
21+
fmt.Printf("Error retrieving thread: %v\n", err)
22+
return
23+
}
24+
25+
markdownContent := formatThreadAsMarkdown(thread)
26+
formattedOutput := ui.RenderMarkdown(markdownContent)
27+
fmt.Println(formattedOutput)
28+
}
29+
30+
func formatThreadAsMarkdown(thread openai.Thread) string {
31+
// Implement the formatting logic here
32+
return "# Thread Details\n\n" + thread.ID
33+
}

main/ui/markdown.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package ui
2+
3+
import (
4+
"os"
5+
markdown "github.com/MichaelMure/go-term-markdown"
6+
"golang.org/x/term"
7+
)
8+
9+
func RenderMarkdown(source string) string {
10+
width, _, err := term.GetSize(int(os.Stdout.Fd()))
11+
if err != nil {
12+
width = 80
13+
}
14+
return string(markdown.Render(source, width, 0))
15+
}

0 commit comments

Comments
 (0)