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

docs: add feedback to experiments #487

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
17 changes: 16 additions & 1 deletion docs/how_to_guides/evaluation/run_evals_api_only.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ resp = requests.get(
examples = resp.json()
```

Next, we'll define a method that will create a run for a single example.
Next, we'll define a method that will create a run for a single example, and also evaluate that run with a feedback key and score.

```python
os.environ["OPENAI_API_KEY"] = "sk-..."
Expand Down Expand Up @@ -117,6 +117,21 @@ def run_completion_on_example(example, model_name, experiment_id):
headers=headers,
)
resp.raise_for_status()

def _evaluate_run(run_id, inputs, outputs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we call this anywhere in the guide?

"""Function to add feedback to a run."""
feedback = {
"score": 1, # We are always leaving a score of 1, but you could dynamically compute this based on the inputs/outputs
"run_id": str(run_id),
"key": "example_feedback",
}
# Visit https://api.smith.langchain.com/redoc#tag/feedback/operation/create_feedback_api_v1_feedback_post for the full API spec
resp = requests.post(
"https://api.smith.langchain.com/api/v1/feedback",
json=feedback,
headers={"x-api-key": os.environ["LANGSMITH_API_KEY"]}
)
resp.raise_for_status()

# Send your API Key in the request headers
headers = {"x-api-key": os.environ["LANGSMITH_API_KEY"]}
Expand Down
Loading