small fixups
This commit is contained in:
@@ -91,6 +91,10 @@ func (a *Agent) Context() 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.
|
||||
// It discards any other computation.
|
||||
func (a *Agent) Ask(opts ...JobOption) *JobResult {
|
||||
|
||||
@@ -33,6 +33,7 @@ type AgentConfig struct {
|
||||
Debug bool `json:"debug" form:"debug"`
|
||||
StandaloneJob bool `json:"standalone_job" form:"standalone_job"`
|
||||
RandomIdentity bool `json:"random_identity" form:"random_identity"`
|
||||
InitiateConversations bool `json:"initiate_conversations" form:"initiate_conversations"`
|
||||
IdentityGuidance string `json:"identity_guidance" form:"identity_guidance"`
|
||||
PeriodicRuns string `json:"periodic_runs" form:"periodic_runs"`
|
||||
PermanentGoal string `json:"permanent_goal" form:"permanent_goal"`
|
||||
@@ -260,6 +261,9 @@ func (a *AgentPool) startAgentWithConfig(name string, config *AgentConfig) error
|
||||
if config.StandaloneJob {
|
||||
opts = append(opts, EnableStandaloneJob)
|
||||
}
|
||||
if config.InitiateConversations {
|
||||
opts = append(opts, EnableInitiateConversations)
|
||||
}
|
||||
if config.RandomIdentity {
|
||||
if config.IdentityGuidance != "" {
|
||||
opts = append(opts, WithRandomIdentity(config.IdentityGuidance))
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
type Telegram struct {
|
||||
Token string
|
||||
Conttext context.Context
|
||||
lastChatID int64
|
||||
}
|
||||
|
||||
// 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,
|
||||
Text: res.Response,
|
||||
})
|
||||
t.lastChatID = update.Message.Chat.ID
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -53,6 +54,18 @@ func (t *Telegram) Start(a *agent.Agent) {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,9 @@
|
||||
<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">
|
||||
|
||||
<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>
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user