setEditedContent(e.target.value)}
- autoGrow
- maxHeight={160}
+ startHeight={320}
/>
{/* 6px vs. 8px to make up for extra padding from textarea field */}
diff --git a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/StyledTextarea.tsx b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/StyledTextarea.tsx
index 14a5b121da5..97d6aa7d39b 100644
--- a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/StyledTextarea.tsx
+++ b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/StyledTextarea.tsx
@@ -8,11 +8,12 @@ import React, {forwardRef} from 'react';
type TextAreaProps = React.TextareaHTMLAttributes & {
autoGrow?: boolean;
maxHeight?: string | number;
+ startHeight?: string | number;
reset?: boolean;
};
export const StyledTextArea = forwardRef(
- ({className, autoGrow, maxHeight, reset, ...props}, ref) => {
+ ({className, autoGrow, maxHeight, startHeight, reset, ...props}, ref) => {
const textareaRef = React.useRef(null);
React.useEffect(() => {
@@ -26,11 +27,22 @@ export const StyledTextArea = forwardRef(
return;
}
- // Disable resize when autoGrow is true
- textareaElement.style.resize = 'none';
+ // Only disable resize when autoGrow is true
+ textareaElement.style.resize = autoGrow ? 'none' : 'vertical';
+
+ // Set initial height if provided
+ if (startHeight && textareaElement.value === '') {
+ textareaElement.style.height =
+ typeof startHeight === 'number' ? `${startHeight}px` : startHeight;
+ return;
+ }
if (reset || textareaElement.value === '') {
- textareaElement.style.height = 'auto';
+ textareaElement.style.height = startHeight
+ ? typeof startHeight === 'number'
+ ? `${startHeight}px`
+ : startHeight
+ : 'auto';
return;
}
@@ -63,7 +75,7 @@ export const StyledTextArea = forwardRef(
return () =>
textareaRefElement.removeEventListener('input', adjustHeight);
- }, [autoGrow, maxHeight, reset]);
+ }, [autoGrow, maxHeight, reset, startHeight]);
return (
@@ -86,6 +98,7 @@ export const StyledTextArea = forwardRef(
'focus:outline-none',
'relative bottom-0 top-0 items-center rounded-sm',
'outline outline-1 outline-moon-250',
+ !autoGrow && 'resize-y',
props.disabled
? 'opacity-50'
: 'hover:outline hover:outline-2 hover:outline-teal-500/40 focus:outline-2',
@@ -94,6 +107,14 @@ export const StyledTextArea = forwardRef(
'placeholder-moon-500 dark:placeholder-moon-600',
className
)}
+ style={{
+ height: startHeight
+ ? typeof startHeight === 'number'
+ ? `${startHeight}px`
+ : startHeight
+ : undefined,
+ ...props.style,
+ }}
{...props}
/>
From 32fc0da84fad70530da0156348c80ac77969d36b Mon Sep 17 00:00:00 2001
From: Andrew Truong
Date: Thu, 12 Dec 2024 14:53:57 -0500
Subject: [PATCH 9/9] chore(weave): Better error message for scorer signature
validation (#3115)
---
tests/trace/test_evaluations.py | 12 +++++++++---
weave/scorers/base_scorer.py | 9 ++++++++-
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/tests/trace/test_evaluations.py b/tests/trace/test_evaluations.py
index e5c38ef0140..ab74d4c0c0b 100644
--- a/tests/trace/test_evaluations.py
+++ b/tests/trace/test_evaluations.py
@@ -1021,13 +1021,19 @@ def my_second_scorer(text, output, model_output):
ds = [{"text": "hello"}]
- with pytest.raises(ValueError, match="Both 'output' and 'model_output'"):
+ with pytest.raises(
+ ValueError, match="cannot include both `output` and `model_output`"
+ ):
scorer = MyScorer()
- with pytest.raises(ValueError, match="Both 'output' and 'model_output'"):
+ with pytest.raises(
+ ValueError, match="cannot include both `output` and `model_output`"
+ ):
evaluation = weave.Evaluation(dataset=ds, scorers=[MyScorer()])
- with pytest.raises(ValueError, match="Both 'output' and 'model_output'"):
+ with pytest.raises(
+ ValueError, match="cannot include both `output` and `model_output`"
+ ):
evaluation = weave.Evaluation(dataset=ds, scorers=[my_second_scorer])
diff --git a/weave/scorers/base_scorer.py b/weave/scorers/base_scorer.py
index 5a19adcd04f..4ac27f1a76b 100644
--- a/weave/scorers/base_scorer.py
+++ b/weave/scorers/base_scorer.py
@@ -1,4 +1,5 @@
import inspect
+import textwrap
from collections.abc import Sequence
from numbers import Number
from typing import Any, Callable, Optional, Union
@@ -45,7 +46,13 @@ def _validate_scorer_signature(scorer: Union[Callable, Op, Scorer]) -> bool:
params = inspect.signature(scorer).parameters
if "output" in params and "model_output" in params:
raise ValueError(
- "Both 'output' and 'model_output' cannot be in the scorer signature; prefer just using `output`."
+ textwrap.dedent(
+ """
+ The scorer signature cannot include both `output` and `model_output` at the same time.
+
+ To resolve, rename one of the arguments to avoid conflict. Prefer using `output` as the model's output.
+ """
+ )
)
return True