Skip to content

Commit

Permalink
Merge branch 'master' into feature/modules
Browse files Browse the repository at this point in the history
  • Loading branch information
vanpelt committed Dec 18, 2024
2 parents 7f7519c + a24512a commit b1d6845
Show file tree
Hide file tree
Showing 13 changed files with 2,209 additions and 108 deletions.
46 changes: 46 additions & 0 deletions weave-js/src/common/components/elements/ModifiedDropdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ describe('testing simple search', () => {
value: '_step',
key: '_step',
},
{
icon: 'wbic-ic-up-arrow',
text: 'Stepperoni',
value: '_stepperoni',
key: '_stepperoni',
},
{
icon: 'wbic-ic-up-arrow',
text: '99',
value: 99,
key: '_99',
},
{
icon: 'calendar',
text: 'Relative Time (Wall)',
Expand Down Expand Up @@ -137,6 +149,40 @@ describe('testing simple search', () => {
expect(results.every(r => (r.value as string).includes('loss'))).toBe(true);
});

it('simpleSearch matches case-insensitive regex strings', () => {
const results = simpleSearch(options, 'LOSS', {
allowRegexSearch: true,
});
expect(results.every(r => (r.value as string).includes('loss'))).toBe(true);
});

it('simpleSearch matches case-insensitive regex strings', () => {
const results = simpleSearch(options, 'tep$', {
allowRegexSearch: true,
});
expect(results.length).toBe(1);
expect(results.every(r => (r.value as string).includes('_step'))).toBe(
true
);
});

it('simpleSearch matches options with number values', () => {
const results = simpleSearch(options, '99$', {
allowRegexSearch: true,
});
expect(results.length).toBe(1);
results.forEach(r => {
expect(r.value).toEqual(99);
});
});

it('simpleSearch matches all results on * regex string', () => {
const results = simpleSearch(options, '*', {
allowRegexSearch: true,
});
expect(results.length).toBe(options.length);
});

it('simpleSearch can disallow matching regex patterns', () => {
const results = simpleSearch(options, '.*s.*s.*');
expect(results.length).toBe(0);
Expand Down
40 changes: 29 additions & 11 deletions weave-js/src/common/components/elements/ModifiedDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,23 @@ type LabelCoord = {

const ITEM_LIMIT_VALUE = '__item_limit';

/**
* The functionality here is similar to `searchRegexFromQuery` in `panelbank.ts`
*/
export function getAsValidRegex(s: string): RegExp | null {
let cleanS = s.trim();

// if the query is a single '*', match everything (even though * isn't technically a valid regex)
if (cleanS === '*') {
cleanS = '.*';
}

if (cleanS.length === 0) {
return null;
}

try {
return new RegExp(s);
return new RegExp(cleanS, 'i');
} catch (e) {
return null;
}
Expand All @@ -64,14 +78,18 @@ export const simpleSearch = (

return _.chain(options)
.filter(o => {
const text = JSON.stringify(o.text).toLowerCase();
return regex ? regex.test(text) : _.includes(text, query.toLowerCase());
const t = typeof o.text === 'string' ? o.text : JSON.stringify(o.text);

return regex
? regex.test(t)
: _.includes(t.toLowerCase(), query.toLowerCase());
})
.sortBy(o => {
const valJSON = typeof o.text === 'string' ? `"${query}"` : query;
return JSON.stringify(o.text).toLowerCase() === valJSON.toLowerCase()
? 0
: 1;
const oString =
typeof o.text === 'string' ? o.text : JSON.stringify(o.text);
const qString = typeof query === 'string' ? query : JSON.stringify(query);

return oString.toLowerCase() === qString.toLowerCase() ? 0 : 1;
})
.value();
};
Expand Down Expand Up @@ -148,10 +166,10 @@ const ModifiedDropdown: FC<ModifiedDropdownProps> = React.memo(
_.concat(currentOptions, search(propsOptions, query) as Option[])
);
} else {
const updatedOptions = currentOptions.concat(
simpleSearch(propsOptions, query, {allowRegexSearch}) as Option[]
);
setOptions(updatedOptions);
const matchedOptions = simpleSearch(propsOptions, query, {
allowRegexSearch,
}) as Option[];
setOptions([...currentOptions, ...matchedOptions]);
}
}, debounceTime || 400),
[allowRegexSearch, debounceTime, multiple, propsOptions, search, value]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,98 @@ export const LLM_MAX_TOKENS = {
max_tokens: 16384,
supports_function_calling: true,
},
'gpt-3.5-turbo-0125': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-3.5-turbo-1106': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4-1106-preview': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4-32k-0314': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: false,
},
'gpt-4-turbo-2024-04-09': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4-turbo-preview': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4-turbo': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4o-2024-05-13': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4o-2024-08-06': {
provider: 'openai',
max_tokens: 16384,
supports_function_calling: true,
},
'gpt-4o-mini-2024-07-18': {
provider: 'openai',
max_tokens: 16384,
supports_function_calling: true,
},
'gpt-4o': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4o-2024-11-20': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'o1-mini-2024-09-12': {
provider: 'openai',
max_tokens: 65536,
supports_function_calling: true,
},
'o1-mini': {
provider: 'openai',
max_tokens: 65536,
supports_function_calling: true,
},
'o1-preview-2024-09-12': {
provider: 'openai',
max_tokens: 32768,
supports_function_calling: true,
},
'o1-preview': {
provider: 'openai',
max_tokens: 32768,
supports_function_calling: true,
},
'o1-2024-12-17': {
provider: 'openai',
max_tokens: 100000,
supports_function_calling: true,
},

// Anthropic models
'claude-3-5-sonnet-20240620': {
provider: 'anthropic',
max_tokens: 8192,
Expand All @@ -32,6 +124,8 @@ export const LLM_MAX_TOKENS = {
max_tokens: 4096,
supports_function_calling: true,
},

// Gemini models
'gemini/gemini-1.5-flash-001': {
provider: 'gemini',
max_tokens: 8192,
Expand Down Expand Up @@ -102,71 +196,8 @@ export const LLM_MAX_TOKENS = {
max_tokens: 8192,
supports_function_calling: true,
},
'gpt-3.5-turbo-0125': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-3.5-turbo-1106': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4-1106-preview': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4-32k-0314': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: false,
},
'gpt-4-turbo-2024-04-09': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4-turbo-preview': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4-turbo': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4o-2024-05-13': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4o-2024-08-06': {
provider: 'openai',
max_tokens: 16384,
supports_function_calling: true,
},
'gpt-4o-mini-2024-07-18': {
provider: 'openai',
max_tokens: 16384,
supports_function_calling: true,
},
'gpt-4o': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},
'gpt-4o-2024-11-20': {
provider: 'openai',
max_tokens: 4096,
supports_function_calling: true,
},

// Groq models
'groq/gemma-7b-it': {
provider: 'groq',
max_tokens: 8192,
Expand Down Expand Up @@ -202,27 +233,8 @@ export const LLM_MAX_TOKENS = {
max_tokens: 32768,
supports_function_calling: true,
},
'o1-mini-2024-09-12': {
provider: 'openai',
max_tokens: 65536,
supports_function_calling: true,
},
'o1-mini': {
provider: 'openai',
max_tokens: 65536,
supports_function_calling: true,
},
'o1-preview-2024-09-12': {
provider: 'openai',
max_tokens: 32768,
supports_function_calling: true,
},
'o1-preview': {
provider: 'openai',
max_tokens: 32768,
supports_function_calling: true,
},

// Bedrock models
'ai21.j2-mid-v1': {
provider: 'bedrock',
max_tokens: 8191,
Expand Down Expand Up @@ -369,6 +381,7 @@ export const LLM_MAX_TOKENS = {
supports_function_calling: true,
},

// xAI models
'xai/grok-beta': {
max_tokens: 131072,
provider: 'xai',
Expand Down
3 changes: 3 additions & 0 deletions weave-js/src/components/Tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export type TagProps = {
color?: TagColorName;
showIcon?: boolean;
iconName?: IconName;
endIconName?: IconName;
// Wrapping the Tag in Tailwind can be a problem if the Tailwind wrapper is supplied higher up
// and there is a need to position the Tag as a direct child for something like flexbox
Wrapper?: React.ComponentType<any> | null;
Expand All @@ -64,6 +65,7 @@ export const Tag: FC<TagProps> = ({
color,
showIcon = false,
iconName,
endIconName,
Wrapper = Tailwind,
isInteractive = false,
}) => {
Expand All @@ -79,6 +81,7 @@ export const Tag: FC<TagProps> = ({
<span className="max-w-[24ch] overflow-hidden text-ellipsis whitespace-nowrap">
{label}
</span>
{endIconName && <Icon className="ml-4 h-14 w-14" name={endIconName} />}
</div>
);
if (Wrapper) {
Expand Down
6 changes: 5 additions & 1 deletion weave-js/src/core/model/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,14 @@ export function isObjectTypeLike(t: any): t is ObjectType | Union {
);
}

export function typedDict(propertyTypes: {[key: string]: Type}): TypedDictType {
export function typedDict(
propertyTypes: {[key: string]: Type},
notRequiredKeys?: string[]
): TypedDictType {
return {
type: 'typedDict',
propertyTypes,
notRequiredKeys,
};
}

Expand Down
Loading

0 comments on commit b1d6845

Please sign in to comment.