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

Add Content-Type #249

Merged
merged 3 commits into from
Oct 16, 2023
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 js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "langsmith",
"version": "0.0.42",
"version": "0.0.43",
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
"files": [
"dist/",
Expand Down
2 changes: 1 addition & 1 deletion js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ export class Client {
datasetId?: string;
datasetName?: string;
}): Promise<any[]> {
let path = "/datasets";
const path = "/datasets";
if (datasetId !== undefined) {
// do nothing
} else if (datasetName !== undefined) {
Expand Down
32 changes: 23 additions & 9 deletions python/langsmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,14 +584,14 @@ def upload_csv(
file_ = {"file": f}
response = self.session.post(
self.api_url + "/datasets/upload",
headers=self._headers,
headers={**self._headers, "Content-Type": "application/json"},
data=data,
files=file_,
)
elif isinstance(csv_file, tuple):
response = self.session.post(
self.api_url + "/datasets/upload",
headers=self._headers,
headers={**self._headers, "Content-Type": "application/json"},
data=data,
files={"file": csv_file},
)
Expand Down Expand Up @@ -662,7 +662,11 @@ def create_run(
runtime = run_extra.setdefault("runtime", {})
runtime_env = ls_env.get_runtime_and_metrics()
run_extra["runtime"] = {**runtime_env, **runtime}
headers = {**self._headers, "Accept": "application/json"}
headers = {
**self._headers,
"Accept": "application/json",
"Content-Type": "application/json",
}
self.request_with_retries(
"post",
f"{self.api_url}/runs",
Expand Down Expand Up @@ -703,7 +707,11 @@ def update_run(
**kwargs : Any
Kwargs are ignored.
"""
headers = {**self._headers, "Accept": "application/json"}
headers = {
**self._headers,
"Accept": "application/json",
"Content-Type": "application/json",
}
data: Dict[str, Any] = {}
if end_time is not None:
data["end_time"] = end_time.isoformat()
Expand Down Expand Up @@ -999,7 +1007,7 @@ def create_project(
body["reference_dataset_id"] = reference_dataset_id
response = self.session.post(
endpoint,
headers=self._headers,
headers={**self._headers, "Content-Type": "application/json"},
data=json.dumps(body, default=_serialize_json),
)
ls_utils.raise_for_status_with_text(response)
Expand Down Expand Up @@ -1166,7 +1174,7 @@ def create_dataset(
)
response = self.session.post(
self.api_url + "/datasets",
headers=self._headers,
headers={**self._headers, "Content-Type": "application/json"},
data=dataset.json(),
)
ls_utils.raise_for_status_with_text(response)
Expand Down Expand Up @@ -1542,7 +1550,9 @@ def create_example(
data["id"] = example_id
example = ls_schemas.ExampleCreate(**data)
response = self.session.post(
f"{self.api_url}/examples", headers=self._headers, data=example.json()
f"{self.api_url}/examples",
headers={**self._headers, "Content-Type": "application/json"},
data=example.json(),
)
ls_utils.raise_for_status_with_text(response)
result = response.json()
Expand Down Expand Up @@ -1634,7 +1644,7 @@ def update_example(
)
response = self.session.patch(
f"{self.api_url}/examples/{example_id}",
headers=self._headers,
headers={**self._headers, "Content-Type": "application/json"},
data=example.json(exclude_none=True),
)
ls_utils.raise_for_status_with_text(response)
Expand Down Expand Up @@ -1902,7 +1912,11 @@ def create_feedback(
"data": json.dumps(
feedback.dict(exclude_none=True), default=_serialize_json
),
"headers": {**self._headers, "Content-Type": "application/json"},
"headers": {
**self._headers,
"Content-Type": "application/json",
"Accept": "application/json",
},
"timeout": self.timeout_ms / 1000,
},
)
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langsmith"
version = "0.0.43"
version = "0.0.44"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
authors = ["LangChain <support@langchain.dev>"]
license = "MIT"
Expand Down
Loading