-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
1. This should be marked as a `pass: None` to not factor into aggregate score 2. The run shouldn't be marked as an error The changes in this PR reflect these desiderata
- Loading branch information
Showing
7 changed files
with
205 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "langsmith" | ||
version = "0.1.49" | ||
version = "0.1.50" | ||
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform." | ||
authors = ["LangChain <[email protected]>"] | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from enum import Enum | ||
from itertools import product | ||
from typing import Literal | ||
|
||
import instructor # type: ignore | ||
import pytest | ||
from anthropic import AsyncAnthropic # type: ignore | ||
from openai import AsyncOpenAI | ||
from pydantic import BaseModel | ||
|
||
from langsmith import unit | ||
|
||
|
||
class Models(str, Enum): | ||
GPT35TURBO = "gpt-3.5-turbo" | ||
GPT4TURBO = "gpt-4-turbo" | ||
CLAUDE3_SONNET = "claude-3-sonnet-20240229" | ||
CLAUDE3_OPUS = "claude-3-opus-20240229" | ||
CLAUDE3_HAIKU = "claude-3-haiku-20240307" | ||
|
||
|
||
clients = ( | ||
instructor.from_openai( | ||
AsyncOpenAI(), | ||
model=Models.GPT35TURBO, | ||
), | ||
instructor.from_openai( | ||
AsyncOpenAI(), | ||
model=Models.GPT4TURBO, | ||
), | ||
instructor.from_anthropic( | ||
AsyncAnthropic(), | ||
model=Models.CLAUDE3_OPUS, | ||
max_tokens=4000, | ||
), | ||
instructor.from_anthropic( | ||
AsyncAnthropic(), | ||
model=Models.CLAUDE3_SONNET, | ||
max_tokens=4000, | ||
), | ||
instructor.from_anthropic( | ||
AsyncAnthropic(), | ||
model=Models.CLAUDE3_HAIKU, | ||
max_tokens=4000, | ||
), | ||
) | ||
|
||
|
||
class ClassifySpam(BaseModel): | ||
label: Literal["spam", "not_spam"] | ||
|
||
|
||
data = [ | ||
("I am a spammer who sends many emails every day", "spam"), | ||
("I am a responsible person who does not spam", "not_spam"), | ||
] | ||
d = list(product(clients, data)) | ||
|
||
|
||
@pytest.mark.asyncio_cooperative | ||
@unit() | ||
@pytest.mark.parametrize("client, data", d[:3]) | ||
async def test_classification(client, data): | ||
input, expected = data | ||
prediction = await client.create( | ||
response_model=ClassifySpam, | ||
messages=[ | ||
{ | ||
"role": "system", | ||
"content": "Classify this text as 'spam' or 'not_spam'.", | ||
}, | ||
{ | ||
"role": "user", | ||
"content": input, | ||
}, | ||
], | ||
) | ||
assert prediction.label == expected |