feat: Add support for Vision and Search in Assistant API
- Introduced Vision and Search capabilities in the Assistant API, enhancing its functionality. - Updated the Context struct to include Vision and Search fields for better context management. - Added a new Search type to facilitate search engine integration. - Adjusted the execute method to handle the new features appropriately.
This commit is contained in:
parent
51cb155d73
commit
aca3014167
4 changed files with 20 additions and 9 deletions
|
|
@ -87,9 +87,10 @@ func (ast *Assistant) execute(c *gin.Context, ctx chatctx.Context, userInput int
|
||||||
}
|
}
|
||||||
options := ast.withOptions(userOptions)
|
options := ast.withOptions(userOptions)
|
||||||
|
|
||||||
// Add RAG and Version support
|
// Add RAG、Vision and Search support
|
||||||
ctx.RAG = rag != nil
|
ctx.RAG = rag != nil
|
||||||
ctx.Version = ast.vision
|
ctx.Vision = ast.vision
|
||||||
|
ctx.Search = ast.search && search != nil
|
||||||
|
|
||||||
// Run init hook
|
// Run init hook
|
||||||
res, err := ast.HookCreate(c, ctx, input, options, contents)
|
res, err := ast.HookCreate(c, ctx, input, options, contents)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import (
|
||||||
var loaded = NewCache(200) // 200 is the default capacity
|
var loaded = NewCache(200) // 200 is the default capacity
|
||||||
var storage store.Store = nil
|
var storage store.Store = nil
|
||||||
var rag *RAG = nil
|
var rag *RAG = nil
|
||||||
|
var search *Search = nil
|
||||||
var connectorSettings map[string]ConnectorSetting = map[string]ConnectorSetting{}
|
var connectorSettings map[string]ConnectorSetting = map[string]ConnectorSetting{}
|
||||||
var vision *neovision.Vision = nil
|
var vision *neovision.Vision = nil
|
||||||
var defaultConnector string = "" // default connector
|
var defaultConnector string = "" // default connector
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,12 @@ type RAG struct {
|
||||||
Setting RAGSetting
|
Setting RAGSetting
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Search the search interface
|
||||||
|
// @todo: add search engine
|
||||||
|
type Search struct {
|
||||||
|
Engine interface{}
|
||||||
|
}
|
||||||
|
|
||||||
// RAGSetting the RAG setting
|
// RAGSetting the RAG setting
|
||||||
type RAGSetting struct {
|
type RAGSetting struct {
|
||||||
IndexPrefix string `json:"index_prefix" yaml:"index_prefix"`
|
IndexPrefix string `json:"index_prefix" yaml:"index_prefix"`
|
||||||
|
|
@ -129,6 +135,7 @@ type Assistant struct {
|
||||||
UpdatedAt int64 `json:"updated_at"` // Last update timestamp
|
UpdatedAt int64 `json:"updated_at"` // Last update timestamp
|
||||||
openai *api.OpenAI // OpenAI API
|
openai *api.OpenAI // OpenAI API
|
||||||
vision bool // Whether this assistant supports vision
|
vision bool // Whether this assistant supports vision
|
||||||
|
search bool // Whether this assistant supports search
|
||||||
toolCalls bool // Whether this assistant supports tool_calls
|
toolCalls bool // Whether this assistant supports tool_calls
|
||||||
initHook bool // Whether this assistant has an init hook
|
initHook bool // Whether this assistant has an init hook
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,11 @@ type Context struct {
|
||||||
Retry bool `json:"retry,omitempty"` // Retry mode
|
Retry bool `json:"retry,omitempty"` // Retry mode
|
||||||
RetryTimes uint8 `json:"retry_times,omitempty"` // Retry times
|
RetryTimes uint8 `json:"retry_times,omitempty"` // Retry times
|
||||||
Upload *FileUpload `json:"upload,omitempty"`
|
Upload *FileUpload `json:"upload,omitempty"`
|
||||||
Version bool `json:"version,omitempty"` // Version support
|
Vision bool `json:"vision,omitempty"` // Vision support
|
||||||
RAG bool `json:"rag,omitempty"` // RAG support
|
Search bool `json:"search,omitempty"` // Search support
|
||||||
Args []interface{} `json:"args,omitempty"` // Arguments for call
|
RAG bool `json:"rag,omitempty"` // RAG support
|
||||||
SharedSpace plan.Space `json:"-"` // Shared space
|
Args []interface{} `json:"args,omitempty"` // Arguments for call
|
||||||
|
SharedSpace plan.Space `json:"-"` // Shared space
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field the context field
|
// Field the context field
|
||||||
|
|
@ -181,9 +182,10 @@ func (ctx *Context) Release() {
|
||||||
// Map the context to a map
|
// Map the context to a map
|
||||||
func (ctx *Context) Map() map[string]interface{} {
|
func (ctx *Context) Map() map[string]interface{} {
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"sid": ctx.Sid,
|
"sid": ctx.Sid,
|
||||||
"rag": ctx.RAG,
|
"rag": ctx.RAG,
|
||||||
"version": ctx.Version,
|
"vision": ctx.Vision,
|
||||||
|
"search": ctx.Search,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.ChatID != "" {
|
if ctx.ChatID != "" {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue