Skip to content
Draft
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
5 changes: 3 additions & 2 deletions elroy/llm/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def generate_chat_completion_message(
if force_tool and not tool_schemas:
raise ValueError(f"Requested tool {force_tool}, but no tools available")

from litellm import completion
from litellm.exceptions import BadRequestError, InternalServerError, RateLimitError

if context_messages[-1].role == ASSISTANT:
Expand Down Expand Up @@ -119,8 +118,10 @@ def generate_chat_completion_message(
tool_choice=tool_choice,
tools=tool_schemas,
)
from litellm import completion

return StreamParser(chat_model, completion(**completion_kwargs)) # type: ignore
stream = completion(**completion_kwargs) # type: ignore
return StreamParser(chat_model, stream)

except Exception as e:
if isinstance(e, BadRequestError):
Expand Down
2 changes: 2 additions & 0 deletions tests/cache/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This directory stores cached LLM responses for tests
# Cache files should be committed to version control to speed up test runs
68 changes: 68 additions & 0 deletions tests/cache/completion_025d43eb41b5d6e2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"content": "",
"tool_calls": [
{
"id": "call_8A5puHZmA2nQ4ErgBZIfkfc1",
"function": {
"arguments": "",
"name": "set_user_preferred_name"
},
"type": "function",
"index": 0
},
{
"id": null,
"function": {
"arguments": "{\"",
"name": null
},
"type": "function",
"index": 0
},
{
"id": null,
"function": {
"arguments": "preferred",
"name": null
},
"type": "function",
"index": 0
},
{
"id": null,
"function": {
"arguments": "_name",
"name": null
},
"type": "function",
"index": 0
},
{
"id": null,
"function": {
"arguments": "\":\"",
"name": null
},
"type": "function",
"index": 0
},
{
"id": null,
"function": {
"arguments": "Jimmy",
"name": null
},
"type": "function",
"index": 0
},
{
"id": null,
"function": {
"arguments": "\"}",
"name": null
},
"type": "function",
"index": 0
}
]
}
4 changes: 4 additions & 0 deletions tests/cache/completion_12204c9286d3b154.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"content": "hello world",
"tool_calls": []
}
6 changes: 6 additions & 0 deletions tests/cache/completion_38adb66f8d77551f.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"content": "",
"tool_calls": [
{
"id": "call_JBg7bbj08qmbfVZMvqrs18lB",
"function":
4 changes: 4 additions & 0 deletions tests/cache/completion_3f7b69b1485c37e9.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"content": "I've created the goal \"Go to the store\" for you! The plan is to create a shopping list and set a date to go, aiming to visit over the weekend. If you need any reminders or support related to this goal, just let me know!",
"tool_calls": []
}
4 changes: 4 additions & 0 deletions tests/cache/completion_40e5f973c0fe84e2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"content": "I've created your goal to \"go to the store.\" You'll need to make a shopping list and plan to visit the local grocery store by this weekend. The goal will be marked complete once you confirm that you've gone to the store. If you need any assistance with this or want to discuss anything else, just let me know!",
"tool_calls": []
}
68 changes: 68 additions & 0 deletions tests/cache/completion_6c9f7565457d239f.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"content": "",
"tool_calls": [
{
"id": "call_MP8bJcAFTdwWLhN9SjCHqxzQ",
"function": {
"arguments": "",
"name": "set_user_preferred_name"
},
"type": "function",
"index": 0
},
{
"id": null,
"function": {
"arguments": "{\"",
"name": null
},
"type": "function",
"index": 0
},
{
"id": null,
"function": {
"arguments": "preferred",
"name": null
},
"type": "function",
"index": 0
},
{
"id": null,
"function": {
"arguments": "_name",
"name": null
},
"type": "function",
"index": 0
},
{
"id": null,
"function": {
"arguments": "\":\"",
"name": null
},
"type": "function",
"index": 0
},
{
"id": null,
"function": {
"arguments": "Jimmy",
"name": null
},
"type": "function",
"index": 0
},
{
"id": null,
"function": {
"arguments": "\"}",
"name": null
},
"type": "function",
"index": 0
}
]
}
4 changes: 4 additions & 0 deletions tests/cache/completion_7604e6a16c02b869.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"content": "I've created a memory titled \"User's experience of swimming on today's date.\" It reflects that you went swimming today. If you'd like to add more details or reflect on your experience, feel free to share!",
"tool_calls": []
}
4 changes: 4 additions & 0 deletions tests/cache/completion_84614030d710cbec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"content": "Hello! It\u2019s great to see you! What\u2019s on your mind today? \ud83c\udf0d\u2728",
"tool_calls": []
}
Loading