Skip to content

Commit 3fc246b

Browse files
committed
Updated LLM
1 parent 40ee5b3 commit 3fc246b

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

agent.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ type Agent interface {
1212
// Return the models
1313
Models(context.Context) ([]Model, error)
1414

15-
// Generate a response from a prompt
16-
Generate(context.Context, Model, Context, ...Opt) (Context, error)
17-
1815
// Embedding vector generation
1916
Embedding(context.Context, Model, string, ...Opt) ([]float64, error)
2017
}

context.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
package llm
22

3+
import "context"
4+
35
//////////////////////////////////////////////////////////////////
46
// TYPES
57

68
// Context is fed to the agent to generate a response
79
type Context interface {
8-
// Return the role, which can be assistant, user, tool, tool_result, ...
9-
Role() string
10-
11-
// Return the text of the context
12-
Text() string
10+
// Generate a response from the context
11+
Generate(context.Context, Model) (Context, error)
1312

1413
// Append user prompt (and attachments) to a context
1514
AppendUserPrompt(string, ...Opt) error
1615

1716
// Append the result of calling a tool to a context
1817
AppendToolResult(string, ...Opt) error
18+
19+
// Return the role, which can be assistant, user, tool, tool_result, ...
20+
Role() string
21+
22+
// Return the text of the context
23+
Text() string
1924
}

model.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package llm
22

3-
// An Model can be used to generate a response
3+
// An Model can be used to generate a response to a user prompt,
4+
// which is passed to an agent. The interaction occurs through
5+
// a session context object.
46
type Model interface {
57
// Return the name of the model
68
Name() string
79

8-
// Return a context object, and set options
10+
// Return am empty session context object for the model,
11+
// setting session options
912
Context(...Opt) (Context, error)
1013
}

opt.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ package llm
33
///////////////////////////////////////////////////////////////////////////////
44
// TYPES
55

6+
// A generic option type, which can set options on an agent or session
67
type Opt func(any) error

pkg/agent/opt.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package agent
22

33
import (
4-
// Packages
54
"fmt"
65

6+
// Packages
77
client "github.com/mutablelogic/go-client"
88
llm "github.com/mutablelogic/go-llm"
99
anthropic "github.com/mutablelogic/go-llm/pkg/anthropic"
@@ -81,10 +81,10 @@ func WithTools(tools ...llm.Tool) llm.Opt {
8181
func WithStream(v bool) llm.Opt {
8282
return func(o any) error {
8383
o.(*opt).ollama = append(o.(*opt).ollama, ollama.WithStream(func(r *ollama.Response) {
84-
fmt.Println(r)
84+
fmt.Println("OLLAMA STREAM", r)
8585
}))
8686
o.(*opt).anthropic = append(o.(*opt).anthropic, anthropic.WithStream(func(r *anthropic.Response) {
87-
fmt.Println(r)
87+
fmt.Println("ANTHROPIC STREAM", r)
8888
}))
8989
return nil
9090
}

0 commit comments

Comments
 (0)