Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: filters url deserializing #311

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/backend/src/checks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const CHECK_RUNNERS: CheckRunner[] = [
},
{
id: "models",
sql: ({ names }) => sql`(name = any(${names}))`,
sql: ({ models }) => sql`(r.name = any(${models}))`,
},
{
id: "tags",
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/components/SmartViewer/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ function ChatMessageContent({
}) {
return (
<Stack gap="xs">
{typeof data?.name === "string" && (
{typeof data?.name === "string" && !compact && (
// used for tools names
<PropEditor
value={data.name}
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/pages/logs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const CHECKS_BY_TYPE = {
],
}

const editCheck = (filters, id, params) => {
function editCheck(filters, id, params) {
if (!params) {
// Remove filter
return filters.filter((f) => f.id !== id)
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/checks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const CHECKS: Check[] = [
{
type: "select",
multiple: true,
id: "names",
id: "models",
width: 100,
options: (type) => `/filters/models`,
},
Expand Down
10 changes: 6 additions & 4 deletions packages/shared/checks/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CHECKS } from "."
// because dots are used to separate filter parameters, we need to encode them
const encode = (str: string) => encodeURIComponent(str).replace(/\./g, "%2E")

const paramSerializer = (param: CheckParam, value: any) => {
function paramSerializer(param: CheckParam, value: any) {
if (value == undefined) {
return undefined
}
Expand Down Expand Up @@ -57,7 +57,7 @@ function deserializeParamValue(
// type=llm&tags=some.tags

export function serializeLogic(logic: CheckLogic): string {
const serializeParamValue = (param: any): string => {
function serializeParamValue(param: any): string {
if (Array.isArray(param)) {
const all = param.map(serializeParamValue)

Expand Down Expand Up @@ -112,9 +112,11 @@ export function deserializeLogic(logicString: string): CheckLogic | undefined {

const paramsData: any = {}

const value = params.split(".")
const values: string[] = params
.split(".")
.map((value) => value.replaceAll("%2C", ","))

for (const [i, v] of value.entries()) {
for (const [i, v] of values.entries()) {
const filterParam = filterParams[i]

if (!filterParam) {
Expand Down
Loading