Skip to content

Commit

Permalink
Removed unused/leftover functions, config attributes, and outdated FI…
Browse files Browse the repository at this point in the history
…XMEs
  • Loading branch information
arcward committed Sep 14, 2024
1 parent ac78e14 commit 20a32a9
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 106 deletions.
8 changes: 2 additions & 6 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func TestUnmarshalConfig(t *testing.T) {
envPrefix,
): "Content-Type Authorization",

fmt.Sprintf("%s_OPENAI_VECTOR_STORE_ID", envPrefix): "vs-foo",
fmt.Sprintf("%s_API_SECRET", envPrefix): "somesecret",
fmt.Sprintf("%s_API_MAX_MULTIPART_MEMORY", envPrefix): "256",

Expand Down Expand Up @@ -138,8 +137,7 @@ func TestUnmarshalConfig(t *testing.T) {
assert.Equal(t, 200, viper.GetInt("queue.size"))
assert.Equal(t, "5m", viper.GetString("queue.max_age"))
assert.Equal(t, "test-token", viper.GetString("openai.token"))
assert.Equal(t, "assistant-id", viper.GetString("openai.assistant.id"))
assert.Equal(t, "vs-foo", viper.GetString("openai.vector_store_id"))
assert.Equal(t, "assistant-id", viper.GetString("openai.assistant_id"))
assert.Equal(t, "discord-token", viper.GetString("discord.token"))
assert.Equal(t, "somesecret", viper.GetString("api.secret"))
assert.ElementsMatch(
Expand Down Expand Up @@ -296,7 +294,6 @@ openai:
token: your_openai_token_here
log_level: INFO
assistant_id: your_assistant_id_here
vector_store_id: your_vector_store_id_here
discord:
token: your_discord_token_here
application_id: your_discord_application_id_here
Expand Down Expand Up @@ -330,6 +327,7 @@ api:
secret: your_api_secret_here
log_level: INFO
cors:
max_age: 12h
allow_origins: []
allow_methods:
- GET
Expand Down Expand Up @@ -359,8 +357,6 @@ api:
- Authorization
- Last-Modified
allow_credentials: true
max_age: 12h
max_multipart_memory: 33554432
read_timeout: 5s
read_header_timeout: 5s
write_timeout: 10s
Expand Down
1 change: 0 additions & 1 deletion disconcierge/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,6 @@ func (h *APIHandlers) reloadUsers(c *gin.Context) {
// - 400 Bad Request: If the query parameters are invalid.
// - 500 Internal Server Error: If there is an error retrieving the users.
func (h *APIHandlers) getUsers(c *gin.Context) {
// TODO: Paginate this on the backend and frontend
var pagination GetUsersQuery
if c.ShouldBindQuery(&pagination) != nil {
c.JSON(http.StatusBadRequest, httpError{Error: "invalid pagination"})
Expand Down
1 change: 1 addition & 0 deletions disconcierge/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2149,6 +2149,7 @@ func TestAPI_UpdateConfig_DiscordGateway(t *testing.T) {
expectedCalls: []string{"SetIdentify", "Open"},
},
{
// FIXME This test is flaky (fails intermittently)
name: "Update Custom Status",
initialState: func() RuntimeConfig {
cfg := baseConfig
Expand Down
5 changes: 1 addition & 4 deletions disconcierge/command_chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,6 @@ func (c *ChatCommand) newDMReport(
// any non-nil buttons. Nil buttons indicate the button should not be included in the
// final message components.
func (c *ChatCommand) discordUserFeedbackComponents() []discordgo.MessageComponent {
// TODO check if BOT_DM or home guild
buttons := make([]discordgo.MessageComponent, 0, discordMaxButtonsPerActionRow)

goodButton := c.GoodButton()
Expand Down Expand Up @@ -1992,9 +1991,7 @@ func (c *ChatCommand) finalizeExpiredButtons(ctx context.Context, db DBI) {
} else {
if err := c.setExpiredButtonStatesFromDB(ctx, db.DB()); err != nil {
logger.ErrorContext(
ctx,
"error setting expired buttons",
tint.Err(err),
ctx, "error setting expired buttons", tint.Err(err),
)
return
}
Expand Down
9 changes: 2 additions & 7 deletions disconcierge/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,8 @@ func (d *database) GetOrCreateUser(
}

if user, cachedUser := d.userCache[u.ID]; cachedUser {
// FIXME this is fine for a single bot instance, but if multiple
// instances are running, this can result in multiple updates
// to the same user record as instances find their cached user
// details are out of date. This also isn't particularly
// concurrency-safe, as the cached record may be read by another
// goroutine while we're updating it.

// FIXME This isn't particularly concurrency-safe, as the cached
// record may be read by another goroutine while we're updating it.
log.InfoContext(ctx, "found existing user", "user", user)
user.LastSeen = time.Now().UTC().UnixMilli()
updates := map[string]any{columnUserLastSeen: user.LastSeen}
Expand Down
2 changes: 0 additions & 2 deletions disconcierge/disconcierge.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,6 @@ func (d *DisConcierge) discordInit(
}

func (d *DisConcierge) startWebhookServer(ctx context.Context, runtimeWG *sync.WaitGroup) {
// TODO set up a run mode where only the API and database
// are enabled (ex: for 'offline' bot config)
runtimeWG.Add(1)
go func() {
defer runtimeWG.Done()
Expand Down
85 changes: 0 additions & 85 deletions disconcierge/openai_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,22 +639,6 @@ func (m *mockOpenAIPollingClient) RetrieveRun(
//
// - ListRunStepsError: Map of run IDs to errors for ListRunSteps calls.
//
// - RetrieveVectorStoreFileResponse: Map of file IDs to mock VectorStoreFile responses.
//
// - RetrieveVectorStoreFileError: Map of file IDs to errors for RetrieveVectorStoreFile calls.
//
// - DeleteVectorStoreFileResponse: Map of file IDs to errors for DeleteVectorStoreFile calls.
//
// - DeleteFileResponse: Map of file IDs to errors for DeleteFile calls.
//
// - CreateVectorStoreFileResponse: Map of file IDs to mock VectorStoreFile responses.
//
// - CreateVectorStoreFileError: Map of file IDs to errors for CreateVectorStoreFile calls.
//
// - RetrieveVectorStoreResponse: Map of vector store IDs to mock VectorStore responses.
//
// - RetrieveVectorStoreError: Map of vector store IDs to errors for RetrieveVectorStore calls.
//
// - PromptResponses: Map of prompts to predefined responses.
//
// - ids: Pointer to commandData for generating unique IDs.
Expand Down Expand Up @@ -1440,75 +1424,6 @@ func (m *mockOpenAIClientServer) newRun(
return run
}

func (*mockOpenAIClientServer) CreateFileBytes(
_ context.Context,
_ openai.FileBytesRequest,
) (file openai.File, err error) {
return file, err
}

func (*mockOpenAIClientServer) CreateVectorStoreFile(
_ context.Context,
_ string,
_ openai.VectorStoreFileRequest,
) (response openai.VectorStoreFile, err error) {
return response, err
}

func (*mockOpenAIClientServer) DeleteVectorStoreFile(
_ context.Context,
_ string,
_ string,
) (err error) {
return err
}

func (*mockOpenAIClientServer) ListVectorStoreFiles(
_ context.Context,
_ string,
_ openai.Pagination,
) (response openai.VectorStoreFilesList, err error) {
return response, err
}

func (*mockOpenAIClientServer) ListVectorStores(
_ context.Context,
_ openai.Pagination,
) (response openai.VectorStoresList, err error) {
return response, err
}

func (*mockOpenAIClientServer) DeleteFile(
_ context.Context,
_ string,
) (err error) {
// TODO implement me
return err
}

func (*mockOpenAIClientServer) RetrieveVectorStoreFile(
_ context.Context,
_ string,
_ string,
) (response openai.VectorStoreFile, err error) {
return response, err
}

func (*mockOpenAIClientServer) RetrieveVectorStore(
_ context.Context,
_ string,
) (response openai.VectorStore, err error) {
// TODO implement me
panic("implement me")
}

func (*mockOpenAIClientServer) CreateFile(
_ context.Context,
_ openai.FileRequest,
) (file openai.File, err error) {
return file, err
}

func newOpenAIMessageList(
t testing.TB,
text string,
Expand Down
2 changes: 1 addition & 1 deletion disconcierge/runtime_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type RuntimeConfig struct {

// OpenAIMaxRequestsPerSecond is the rate limit for how many OpenAI "Create Run"
// API requests can be made per second
// TODO give this a clearer name
// TODO give this a clearer name, as it only applies to 'Create Run' requests
OpenAIMaxRequestsPerSecond int `gorm:"column:openai_max_requests_per_second;default:1" json:"openai_max_requests_per_second" binding:"min=1"`

// Limits the number of ChatCommands requests per user per 6-hour window
Expand Down

0 comments on commit 20a32a9

Please sign in to comment.