summaryrefslogtreecommitdiffhomepage
path: root/internal/llm/agent
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-03-24 11:47:39 +0100
committerKujtim Hoxha <[email protected]>2025-03-24 11:47:39 +0100
commit005b8ac16776512b2d4b1f22bd989da162ca1bad (patch)
treecfe0d1da344ac31a467f1bea788ce80c723cd980 /internal/llm/agent
parente7258e38aeb46281fda474b8b7fcc3eee35edd9f (diff)
downloadopencode-005b8ac16776512b2d4b1f22bd989da162ca1bad.tar.gz
opencode-005b8ac16776512b2d4b1f22bd989da162ca1bad.zip
initial working agent
Diffstat (limited to 'internal/llm/agent')
-rw-r--r--internal/llm/agent/title.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/llm/agent/title.go b/internal/llm/agent/title.go
new file mode 100644
index 000000000..1b9840cc2
--- /dev/null
+++ b/internal/llm/agent/title.go
@@ -0,0 +1,31 @@
+package agent
+
+import (
+ "context"
+
+ "github.com/cloudwego/eino/schema"
+ "github.com/kujtimiihoxha/termai/internal/llm/models"
+ "github.com/spf13/viper"
+)
+
+func GenerateTitle(ctx context.Context, content string) (string, error) {
+ model, err := models.GetModel(ctx, models.ModelID(viper.GetString("models.small")))
+ if err != nil {
+ return "", err
+ }
+ out, err := model.Generate(
+ ctx,
+ []*schema.Message{
+ schema.SystemMessage(`- you will generate a short title based on the first message a user begins a conversation with
+ - ensure it is not more than 80 characters long
+ - the title should be a summary of the user's message
+ - do not use quotes or colons
+ - the entire text you return will be used as the title`),
+ schema.UserMessage(content),
+ },
+ )
+ if err != nil {
+ return "", err
+ }
+ return out.Content, nil
+}