| 2009 | } |
| 2010 | |
| 2011 | func AIBridgeToolUsage(t testing.TB, db database.Store, seed database.InsertAIBridgeToolUsageParams) database.AIBridgeToolUsage { |
| 2012 | serverURL := sql.NullString{} |
| 2013 | if seed.ServerUrl.Valid { |
| 2014 | serverURL = seed.ServerUrl |
| 2015 | } |
| 2016 | invocationError := sql.NullString{} |
| 2017 | if seed.InvocationError.Valid { |
| 2018 | invocationError = seed.InvocationError |
| 2019 | } |
| 2020 | toolUsage, err := db.InsertAIBridgeToolUsage(genCtx, database.InsertAIBridgeToolUsageParams{ |
| 2021 | ID: takeFirst(seed.ID, uuid.New()), |
| 2022 | InterceptionID: takeFirst(seed.InterceptionID, uuid.New()), |
| 2023 | ProviderResponseID: takeFirst(seed.ProviderResponseID, "provider_response_id"), |
| 2024 | ProviderToolCallID: takeFirst(seed.ProviderToolCallID), |
| 2025 | Tool: takeFirst(seed.Tool, "tool"), |
| 2026 | ServerUrl: serverURL, |
| 2027 | Input: takeFirst(seed.Input, "input"), |
| 2028 | Injected: takeFirst(seed.Injected, false), |
| 2029 | InvocationError: invocationError, |
| 2030 | Metadata: takeFirstSlice(seed.Metadata, json.RawMessage("{}")), |
| 2031 | CreatedAt: takeFirst(seed.CreatedAt, dbtime.Now()), |
| 2032 | }) |
| 2033 | require.NoError(t, err, "insert aibridge tool usage") |
| 2034 | return toolUsage |
| 2035 | } |
| 2036 | |
| 2037 | func AIBridgeModelThought(t testing.TB, db database.Store, seed database.InsertAIBridgeModelThoughtParams) database.AIBridgeModelThought { |
| 2038 | thought, err := db.InsertAIBridgeModelThought(genCtx, database.InsertAIBridgeModelThoughtParams{ |