small fixups
This commit is contained in:
@@ -91,6 +91,10 @@ func (a *Agent) Context() context.Context {
|
|||||||
return a.context.Context
|
return a.context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Agent) ConversationChannel() chan openai.ChatCompletionMessage {
|
||||||
|
return a.newConversations
|
||||||
|
}
|
||||||
|
|
||||||
// Ask is a pre-emptive, blocking call that returns the response as soon as it's ready.
|
// Ask is a pre-emptive, blocking call that returns the response as soon as it's ready.
|
||||||
// It discards any other computation.
|
// It discards any other computation.
|
||||||
func (a *Agent) Ask(opts ...JobOption) *JobResult {
|
func (a *Agent) Ask(opts ...JobOption) *JobResult {
|
||||||
|
|||||||
@@ -27,15 +27,16 @@ type AgentConfig struct {
|
|||||||
Connector []ConnectorConfig `json:"connectors" form:"connectors" `
|
Connector []ConnectorConfig `json:"connectors" form:"connectors" `
|
||||||
Actions []ActionsConfig `json:"actions" form:"actions"`
|
Actions []ActionsConfig `json:"actions" form:"actions"`
|
||||||
// This is what needs to be part of ActionsConfig
|
// This is what needs to be part of ActionsConfig
|
||||||
Model string `json:"model" form:"model"`
|
Model string `json:"model" form:"model"`
|
||||||
Name string `json:"name" form:"name"`
|
Name string `json:"name" form:"name"`
|
||||||
HUD bool `json:"hud" form:"hud"`
|
HUD bool `json:"hud" form:"hud"`
|
||||||
Debug bool `json:"debug" form:"debug"`
|
Debug bool `json:"debug" form:"debug"`
|
||||||
StandaloneJob bool `json:"standalone_job" form:"standalone_job"`
|
StandaloneJob bool `json:"standalone_job" form:"standalone_job"`
|
||||||
RandomIdentity bool `json:"random_identity" form:"random_identity"`
|
RandomIdentity bool `json:"random_identity" form:"random_identity"`
|
||||||
IdentityGuidance string `json:"identity_guidance" form:"identity_guidance"`
|
InitiateConversations bool `json:"initiate_conversations" form:"initiate_conversations"`
|
||||||
PeriodicRuns string `json:"periodic_runs" form:"periodic_runs"`
|
IdentityGuidance string `json:"identity_guidance" form:"identity_guidance"`
|
||||||
PermanentGoal string `json:"permanent_goal" form:"permanent_goal"`
|
PeriodicRuns string `json:"periodic_runs" form:"periodic_runs"`
|
||||||
|
PermanentGoal string `json:"permanent_goal" form:"permanent_goal"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AgentPool struct {
|
type AgentPool struct {
|
||||||
@@ -260,6 +261,9 @@ func (a *AgentPool) startAgentWithConfig(name string, config *AgentConfig) error
|
|||||||
if config.StandaloneJob {
|
if config.StandaloneJob {
|
||||||
opts = append(opts, EnableStandaloneJob)
|
opts = append(opts, EnableStandaloneJob)
|
||||||
}
|
}
|
||||||
|
if config.InitiateConversations {
|
||||||
|
opts = append(opts, EnableInitiateConversations)
|
||||||
|
}
|
||||||
if config.RandomIdentity {
|
if config.RandomIdentity {
|
||||||
if config.IdentityGuidance != "" {
|
if config.IdentityGuidance != "" {
|
||||||
opts = append(opts, WithRandomIdentity(config.IdentityGuidance))
|
opts = append(opts, WithRandomIdentity(config.IdentityGuidance))
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Telegram struct {
|
type Telegram struct {
|
||||||
Token string
|
Token string
|
||||||
Conttext context.Context
|
lastChatID int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send any text message to the bot after the bot has been started
|
// Send any text message to the bot after the bot has been started
|
||||||
@@ -45,6 +45,7 @@ func (t *Telegram) Start(a *agent.Agent) {
|
|||||||
ChatID: update.Message.Chat.ID,
|
ChatID: update.Message.Chat.ID,
|
||||||
Text: res.Response,
|
Text: res.Response,
|
||||||
})
|
})
|
||||||
|
t.lastChatID = update.Message.Chat.ID
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,6 +54,18 @@ func (t *Telegram) Start(a *agent.Agent) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for m := range a.ConversationChannel() {
|
||||||
|
if t.lastChatID == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
b.SendMessage(ctx, &bot.SendMessageParams{
|
||||||
|
ChatID: t.lastChatID,
|
||||||
|
Text: m.Content,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
b.Start(ctx)
|
b.Start(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,9 @@
|
|||||||
<label for="standalone_job" class="block text-lg font-medium text-gray-400">Standalone Job</label>
|
<label for="standalone_job" class="block text-lg font-medium text-gray-400">Standalone Job</label>
|
||||||
<input type="checkbox" name="standalone_job" id="standalone_job" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md bg-gray-700 text-white">
|
<input type="checkbox" name="standalone_job" id="standalone_job" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md bg-gray-700 text-white">
|
||||||
|
|
||||||
|
<label for="initiate_conversations" class="block text-lg font-medium text-gray-400">Initiate conversations</label>
|
||||||
|
<input type="checkbox" name="random_identity" id="initiate_conversations" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md bg-gray-700 text-white">
|
||||||
|
|
||||||
<label for="random_identity" class="block text-lg font-medium text-gray-400">Random Identity</label>
|
<label for="random_identity" class="block text-lg font-medium text-gray-400">Random Identity</label>
|
||||||
<input type="checkbox" name="random_identity" id="random_identity" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md bg-gray-700 text-white">
|
<input type="checkbox" name="random_identity" id="random_identity" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md bg-gray-700 text-white">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user