Refactor assistant and context types for clarity and compatibility
- Removed commented-out methods from the API interface in assistant types to enhance code cleanliness. - Introduced a new Response type in context types, ensuring compatibility with the OpenAI API.
This commit is contained in:
parent
44d2ba4210
commit
67ec5516e4
5 changed files with 34 additions and 4 deletions
13
agent/assistant/agent.go
Normal file
13
agent/assistant/agent.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package assistant
|
||||
|
||||
import "github.com/yaoapp/yao/agent/context"
|
||||
|
||||
// Stream stream the agent
|
||||
func (ast *Assistant) Stream(ctx context.Context, messages []context.Message, handler context.StreamFunc) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Run run the agent
|
||||
func (ast *Assistant) Run(ctx context.Context, messages []context.Message) (*context.Response, error) {
|
||||
return &context.Response{}, nil
|
||||
}
|
||||
3
agent/assistant/js/js.go
Normal file
3
agent/assistant/js/js.go
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
package js
|
||||
|
||||
// JSAPI Register the JavaScript API
|
||||
|
|
@ -20,10 +20,6 @@ const (
|
|||
// API the assistant API interface
|
||||
type API interface {
|
||||
Chat(ctx context.Context, messages []message.Message, option map[string]interface{}, cb func(data []byte) int) error
|
||||
// Upload(ctx context.Context, file *multipart.FileHeader, reader io.Reader, option map[string]interface{}) (*File, error)
|
||||
// Download(ctx context.Context, fileID string) (*FileResponse, error)
|
||||
// ReadBase64(ctx context.Context, fileID string) (string, error)
|
||||
|
||||
GetPlaceholder(locale string) *store.Placeholder
|
||||
Execute(c *gin.Context, ctx chatctx.Context, input interface{}, options map[string]interface{}, callback ...interface{}) (interface{}, error)
|
||||
Call(c *gin.Context, payload APIPayload) (interface{}, error)
|
||||
|
|
|
|||
14
agent/context/interfaces.go
Normal file
14
agent/context/interfaces.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package context
|
||||
|
||||
// StreamFunc the streaming function
|
||||
type StreamFunc func(data []byte) int
|
||||
|
||||
// Agent the agent interface
|
||||
type Agent interface {
|
||||
|
||||
// Stream stream the agent
|
||||
Stream(ctx Context, messages []Message, handler StreamFunc) error
|
||||
|
||||
// Run run the agent
|
||||
Run(ctx Context, messages []Message) (*Response, error)
|
||||
}
|
||||
|
|
@ -124,6 +124,10 @@ type Context struct {
|
|||
Silent bool `json:"silent,omitempty"` // Silent mode (Deprecated, use Referer instead)
|
||||
}
|
||||
|
||||
// Response the response
|
||||
// 100% compatible with the OpenAI API
|
||||
type Response struct{}
|
||||
|
||||
// Message Structure ( OpenAI Chat Completion Input Message Structure, https://platform.openai.com/docs/api-reference/chat/create#chat/create-messages )
|
||||
// ===============================
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue