Feat: bot failed state to show/hide llm restart btn
This commit is contained in:
		| @@ -188,6 +188,11 @@ func (b *Bot) BotMove() { | ||||
| 		b.log.Error("bot loop", "error", err) | ||||
| 		return | ||||
| 	} | ||||
| 	if room.BotFailed { | ||||
| 		if err := repo.RoomUnSetBotFailed(context.Background(), room.ID); err != nil { | ||||
| 			b.log.Error("failed to unset bot failed bool", "error", err) | ||||
| 		} | ||||
| 	} | ||||
| 	// eventName := models.NotifyBacklogPrefix + room.ID | ||||
| 	eventName := models.NotifyRoomUpdatePrefix + room.ID | ||||
| 	eventPayload := "" | ||||
| @@ -231,6 +236,9 @@ func (b *Bot) BotMove() { | ||||
| 			b.log.Warn("failed to write to journal", "entry", lj) | ||||
| 		} | ||||
| 		b.log.Error("bot loop", "error", err) | ||||
| 		if err := repo.RoomSetBotFailed(context.Background(), room.ID); err != nil { | ||||
| 			b.log.Error("failed to set bot failed bool", "error", err) | ||||
| 		} | ||||
| 		return | ||||
| 	} | ||||
| 	tempMap, err := b.LLMParser.ParseBytes(llmResp) | ||||
| @@ -666,16 +674,5 @@ func (b *Bot) CallLLM(prompt string) ([]byte, error) { | ||||
| 		b.log.Debug("llm resp", "body", string(body), "url", b.cfg.LLMConfig.URL, "attempt", attempt) | ||||
| 		return body, nil | ||||
| 	} | ||||
| 	entry := fmt.Sprintf("bot '%s' exceeded attempts to call llm;", b.BotName) | ||||
| 	lj := models.Journal{ | ||||
| 		Entry:    entry, | ||||
| 		Username: b.BotName, | ||||
| 		RoomID:   b.RoomID, | ||||
| 	} | ||||
| 	if err := repo.JournalCreate(context.Background(), &lj); err != nil { | ||||
| 		b.log.Warn("failed to write to journal", "entry", lj) | ||||
| 	} | ||||
| 	// notify room | ||||
| 	// This line should not be reached because each error path returns in the loop. | ||||
| 	return nil, errors.New("unknown error in retry loop") | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder