-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
310 additions
and
123 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
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,57 @@ | ||
package chain | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hupe1980/golc" | ||
"github.com/hupe1980/golc/memory" | ||
"github.com/hupe1980/golc/prompt" | ||
"github.com/hupe1980/golc/schema" | ||
) | ||
|
||
type ConversationChainOptions struct { | ||
*callbackOptions | ||
Memory schema.Memory | ||
OutputParser schema.OutputParser[any] | ||
} | ||
|
||
type ConversationChain struct { | ||
*baseChain | ||
llm schema.LLM | ||
prompt *prompt.Template | ||
opts ConversationChainOptions | ||
} | ||
|
||
func NewConversationChain(llm schema.LLM, prompt *prompt.Template, optFns ...func(o *ConversationChainOptions)) (*ConversationChain, error) { | ||
opts := ConversationChainOptions{ | ||
Memory: memory.NewConversationBuffer(), | ||
callbackOptions: &callbackOptions{ | ||
Verbose: golc.Verbose, | ||
}, | ||
} | ||
|
||
for _, fn := range optFns { | ||
fn(&opts) | ||
} | ||
|
||
conversationChain := &ConversationChain{ | ||
prompt: prompt, | ||
llm: llm, | ||
opts: opts, | ||
} | ||
|
||
conversationChain.baseChain = &baseChain{ | ||
chainName: "ConversationChain", | ||
callFunc: conversationChain.call, | ||
inputKeys: []string{"input"}, | ||
outputKeys: []string{"response"}, | ||
memory: opts.Memory, | ||
callbackOptions: opts.callbackOptions, | ||
} | ||
|
||
return conversationChain, nil | ||
} | ||
|
||
func (c *ConversationChain) call(ctx context.Context, inputs schema.ChainValues) (schema.ChainValues, error) { | ||
return nil, nil | ||
} |
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
Oops, something went wrong.