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

Saved result name in LLMResult #49

Merged
merged 1 commit into from
Jan 29, 2025
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 llmclient/llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ async def call( # noqa: C901, PLR0915
result.seconds_to_last_token = (
asyncio.get_running_loop().time() - start_clock
)

result.name = name
if self.llm_result_callback:
possibly_awaitable_result = self.llm_result_callback(result)
if isawaitable(possibly_awaitable_result):
Expand Down
5 changes: 3 additions & 2 deletions tests/test_llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ async def test_call(self, config: dict[str, Any]) -> None:
Message(role="system", content="Respond with single words."),
Message(role="user", content="What is the meaning of the universe?"),
]
results = await llm.call(messages)
result_name = f"test-{llm.name}"
results = await llm.call(messages, name=result_name)
assert isinstance(results, list)

result = results[0]
Expand All @@ -116,7 +117,7 @@ async def test_call(self, config: dict[str, Any]) -> None:
assert result.prompt[1].content
assert result.text
assert result.logprob is None or result.logprob <= 0

assert result.name == result_name
result = await llm.call_single(messages)
assert isinstance(result, LLMResult)

Expand Down