forked from phoenix/litellm-mirror
refactor: move all testing to top-level of repo
Closes https://github.com/BerriAI/litellm/issues/486
This commit is contained in:
parent
5403c5828c
commit
3560f0ef2c
213 changed files with 74 additions and 217 deletions
543
tests/local_testing/stream_chunk_testdata.py
Normal file
543
tests/local_testing/stream_chunk_testdata.py
Normal file
|
@ -0,0 +1,543 @@
|
|||
from litellm.types.utils import (
|
||||
ChatCompletionDeltaToolCall,
|
||||
Delta,
|
||||
Function,
|
||||
ModelResponse,
|
||||
StreamingChoices,
|
||||
)
|
||||
|
||||
chunks = [
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content="To answer",
|
||||
role="assistant",
|
||||
function_call=None,
|
||||
tool_calls=None,
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content=" your", role=None, function_call=None, tool_calls=None
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content=" question about",
|
||||
role=None,
|
||||
function_call=None,
|
||||
tool_calls=None,
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content=" how", role=None, function_call=None, tool_calls=None
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content=" many rows are in the ",
|
||||
role=None,
|
||||
function_call=None,
|
||||
tool_calls=None,
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content="'users' table, I",
|
||||
role=None,
|
||||
function_call=None,
|
||||
tool_calls=None,
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content="'ll", role=None, function_call=None, tool_calls=None
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content=" need to", role=None, function_call=None, tool_calls=None
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content=" run", role=None, function_call=None, tool_calls=None
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content=" a SQL query.",
|
||||
role=None,
|
||||
function_call=None,
|
||||
tool_calls=None,
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content=" Let", role=None, function_call=None, tool_calls=None
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content=" me", role=None, function_call=None, tool_calls=None
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content=" ", role=None, function_call=None, tool_calls=None
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content="do that for",
|
||||
role=None,
|
||||
function_call=None,
|
||||
tool_calls=None,
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content=" you.", role=None, function_call=None, tool_calls=None
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content="",
|
||||
role=None,
|
||||
function_call=None,
|
||||
tool_calls=[
|
||||
ChatCompletionDeltaToolCall(
|
||||
id="toolu_01H3AjkLpRtGQrof13CBnWfK",
|
||||
function=Function(arguments="", name="sql_query"),
|
||||
type="function",
|
||||
index=1,
|
||||
)
|
||||
],
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content="",
|
||||
role=None,
|
||||
function_call=None,
|
||||
tool_calls=[
|
||||
ChatCompletionDeltaToolCall(
|
||||
id=None,
|
||||
function=Function(arguments="", name=None),
|
||||
type="function",
|
||||
index=1,
|
||||
)
|
||||
],
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656356,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content="",
|
||||
role=None,
|
||||
function_call=None,
|
||||
tool_calls=[
|
||||
ChatCompletionDeltaToolCall(
|
||||
id=None,
|
||||
function=Function(arguments='{"', name=None),
|
||||
type="function",
|
||||
index=1,
|
||||
)
|
||||
],
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656357,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content="",
|
||||
role=None,
|
||||
function_call=None,
|
||||
tool_calls=[
|
||||
ChatCompletionDeltaToolCall(
|
||||
id=None,
|
||||
function=Function(arguments='query": ', name=None),
|
||||
type="function",
|
||||
index=1,
|
||||
)
|
||||
],
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656357,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content="",
|
||||
role=None,
|
||||
function_call=None,
|
||||
tool_calls=[
|
||||
ChatCompletionDeltaToolCall(
|
||||
id=None,
|
||||
function=Function(arguments='"SELECT C', name=None),
|
||||
type="function",
|
||||
index=1,
|
||||
)
|
||||
],
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656357,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content="",
|
||||
role=None,
|
||||
function_call=None,
|
||||
tool_calls=[
|
||||
ChatCompletionDeltaToolCall(
|
||||
id=None,
|
||||
function=Function(arguments="OUNT(*", name=None),
|
||||
type="function",
|
||||
index=1,
|
||||
)
|
||||
],
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656357,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content="",
|
||||
role=None,
|
||||
function_call=None,
|
||||
tool_calls=[
|
||||
ChatCompletionDeltaToolCall(
|
||||
id=None,
|
||||
function=Function(arguments=") ", name=None),
|
||||
type="function",
|
||||
index=1,
|
||||
)
|
||||
],
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656357,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content="",
|
||||
role=None,
|
||||
function_call=None,
|
||||
tool_calls=[
|
||||
ChatCompletionDeltaToolCall(
|
||||
id=None,
|
||||
function=Function(arguments="FROM use", name=None),
|
||||
type="function",
|
||||
index=1,
|
||||
)
|
||||
],
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656357,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content="",
|
||||
role=None,
|
||||
function_call=None,
|
||||
tool_calls=[
|
||||
ChatCompletionDeltaToolCall(
|
||||
id=None,
|
||||
function=Function(arguments='rs;"}', name=None),
|
||||
type="function",
|
||||
index=1,
|
||||
)
|
||||
],
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656357,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
ModelResponse(
|
||||
id="chatcmpl-634a6ad3-483a-44a1-8cdd-3befbeb4ac2f",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason="tool_calls",
|
||||
index=0,
|
||||
delta=Delta(
|
||||
content=None, role=None, function_call=None, tool_calls=None
|
||||
),
|
||||
logprobs=None,
|
||||
)
|
||||
],
|
||||
created=1722656357,
|
||||
model="claude-3-5-sonnet-20240620",
|
||||
object="chat.completion.chunk",
|
||||
system_fingerprint=None,
|
||||
),
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue