You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import ell
from model import deepseek
ell.init(verbose=True)
ell.config.register_model(deepseek.model, deepseek.client)
@ell.complex(model=deepseek.model, temperature=0.7)
def chat_bot(message_history: list[ell.Message]) -> list[ell.Message]:
msg = [
ell.system("You are a friendly chatbot. Engage in casual conversation."),
] + message_history
for m in msg:
print(f"msg: {m}")
return msg
message_history = []
while True:
user_input = input("You: ")
message_history.append(ell.user(user_input))
print(message_history)
response = chat_bot(message_history)
print("Bot:", response.text)
message_history.append(response)
print(message_history)
log:
ell python exp.py
You: hi
[Message(role='user', content=[ContentBlock(text=hi)])]
msg: role='system' content=[ContentBlock(text=You are a friendly chatbot. Engage in casual conversation.)]
msg: role='user' content=[ContentBlock(text=hi)]
╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ chat_bot([Message..)
╠═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ Prompt:
╟───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
│ system: You are a friendly chatbot. Engage in casual conversation.
│
│ user: hi
╟───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
║ Output:
╟───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
│ assistant: Hello! How are you doing today? 😊
╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
Bot: Hello! How are you doing today? 😊
[Message(role='user', content=[ContentBlock(text=hi)]), Message(role='assistant', content=[ContentBlock(text=Hello! How are you doing today? 😊)])]
You: who are you?
[Message(role='user', content=[ContentBlock(text=hi)]), Message(role='assistant', content=[ContentBlock(text=Hello! How are you doing today? 😊)]), Message(role='user', content=[ContentBlock(text=who are you?)])]
msg: role='system' content=[ContentBlock(text=You are a friendly chatbot. Engage in casual conversation.)]
msg: role='user' content=[ContentBlock(text=hi)]
msg: role='assistant' content=[ContentBlock(text=Hello! How are you doing today? 😊)]
msg: role='user' content=[ContentBlock(text=who are you?)]
╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ chat_bot([Message..)
╠═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ Prompt:
╟───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
│ system: You are a friendly chatbot. Engage in casual conversation.
│
│ user: hi
│
│ assistant: Hello! How are you doing today? 😊
│
│ user: who are you?
╟───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
║ Output:
╟───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
│ assistant: Traceback (most recent call last):
File "/Users/x/work/AI/agent/ell/exp.py", line 21, in <module>
response = chat_bot(message_history)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/x/.pyenv/versions/3.12.4/lib/python3.12/site-packages/ell/lmp/_track.py", line 70, in tracked_func
res = func_to_track(
^^^^^^^^^^^^^^
File "/Users/x/.pyenv/versions/3.12.4/lib/python3.12/site-packages/ell/lmp/complex.py", line 68, in model_call
(result, final_api_params, metadata) = provider.call(ell_call, origin_id=_invocation_origin, logger=_logger if should_log else None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/x/.pyenv/versions/3.12.4/lib/python3.12/site-packages/ell/provider.py", line 125, in call
provider_resp = call(**final_api_call_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/x/.pyenv/versions/3.12.4/lib/python3.12/site-packages/openai/_utils/_utils.py", line 279, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/x/.pyenv/versions/3.12.4/lib/python3.12/site-packages/openai/resources/chat/completions.py", line 859, in create
return self._post(
^^^^^^^^^^^
File "/Users/x/.pyenv/versions/3.12.4/lib/python3.12/site-packages/openai/_base_client.py", line 1283, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/x/.pyenv/versions/3.12.4/lib/python3.12/site-packages/openai/_base_client.py", line 960, in request
return self._request(
^^^^^^^^^^^^^^
File "/Users/x/.pyenv/versions/3.12.4/lib/python3.12/site-packages/openai/_base_client.py", line 1064, in _request
raise self._make_status_error_from_response(err.response) from None
openai.UnprocessableEntityError: Failed to deserialize the JSON body into the target type: messages[2]: invalid type: sequence, expected a string at line 1 column 280
➜ ell
I report an error every time I enter it for the second time.
The text was updated successfully, but these errors were encountered:
I want try the exmple:https://docs.ell.so/core_concepts/ell_complex.html#chat-based-use-cases
But, I have some troubles.
This is my code
log:
I report an error every time I enter it for the second time.
The text was updated successfully, but these errors were encountered: