Skip to content

Commit

Permalink
refactor: gragp & workflow (#29)
Browse files Browse the repository at this point in the history
* refactor: runner & gragp & workflow

* chore: optimiz comment,error report,variable name

* feat: modify the mothod of setting state in graph
  • Loading branch information
meguminnnnnnnnn authored Jan 17, 2025
1 parent f5ec8bc commit 289ba9c
Show file tree
Hide file tree
Showing 25 changed files with 1,963 additions and 536 deletions.
9 changes: 9 additions & 0 deletions components/prompt/chat_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,12 @@ func TestDocumentFormat(t *testing.T) {
assert.Nil(t, err)
t.Log(msgs)
}

func TestFString(t *testing.T) {
template := FromMessages(schema.FString,
schema.SystemMessage("{{all:{all_docs}"),
)
r, err := template.Format(context.Background(), map[string]any{"all_docs": "123"})
assert.Nil(t, err)
println(r[0].Content)
}
14 changes: 14 additions & 0 deletions compose/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ func (c *Chain[I, O]) addEndIfNeeded() error {
return nil
}

func (c *Chain[I, O]) inputConverter() handlerPair {
return handlerPair{
invoke: defaultValueChecker[I],
transform: defaultStreamConverter[I],
}
}

func (c *Chain[I, O]) inputFieldMappingConverter() handlerPair {
return handlerPair{
invoke: buildFieldMappingConverter[I](),
transform: buildStreamFieldMappingConverter[I](),
}
}

// inputType returns the input type of the chain.
// implements AnyGraph.
func (c *Chain[I, O]) inputType() reflect.Type {
Expand Down
9 changes: 3 additions & 6 deletions compose/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,11 @@ func (ch *dagChannel) get(ctx context.Context) (any, error) {
if ch.value == nil {
return nil, fmt.Errorf("dag channel not ready, value is nil")
}
return ch.value, nil
v := ch.value
ch.value = nil
return v, nil
}

func (ch *dagChannel) ready(ctx context.Context) bool {
return ch.value != nil
}

func (ch *dagChannel) clear(ctx context.Context) {
ch.values = make(map[string]any)
ch.values = nil
}
Loading

0 comments on commit 289ba9c

Please sign in to comment.