vnoelifant / cozmo-companion

1 stars 0 forks source link

Marvin tools #26

Closed vnoelifant closed 11 months ago

vnoelifant commented 1 year ago

Implementation for #25.

Video: https://www.youtube.com/watch?v=KcylvOvTT5Q

It works a lot better, but noted that there are times when the bot will repeat the feedback inquiry (i.e. saying "Did the response help"). I am suspecting this might have to do with the model's Pre-Trained Behavior: If the chatbot is using a pre-trained model, it might have been trained on data where user feedback was often sought after certain types of responses, like jokes. As a result, when the model generates a joke or a motivational message, it might also generate a feedback inquiry as part of its response. One thing that GPT suggested to help fix this is with the following logic, but I haven't yet tested it:

if feedback_inquiry and feedback_inquiry not in gpt_response:
    gpt_response += feedback_inquiry

There is a bug with Marvin's tool decorator in assistant.py, as per error message below. When implementing this as a Marvin tool, the following error is received. When commenting out the tool decorator, the function runs just fine. In addition, I tried modifying/removing the type hints and ensuring the Marvin library is up to date, and looking at Marvin tool examples, but the issue persists. The error message suggests a configuration setting arbitrary_types_allowed. While this is a Pydantic setting, it's possible Marvin has a way to set or influenc this. I plan to consult Marvin's community to further investigate.

Traceback:

Traceback (most recent call last):
  File "C:\Users\veron\cozmo-companion\src\cozmo_companion\assistant.py", line 152, in _generate_response
    gpt_response_content = self.chatbot(gpt_prompt).content
  File "C:\Users\veron\cozmo-companion\venv\lib\site-packages\marvin\components\ai_application.py", line 255, in __call__
    return run_sync(self.run(input_text=input_text, model=model))
  File "C:\Users\veron\cozmo-companion\venv\lib\site-packages\marvin\utilities\async_utils.py", line 69, in run_sync
    return asyncio.run(coroutine)
  File "C:\Python_39\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Python_39\lib\asyncio\base_events.py", line 647, in run_until_complete
    return future.result()
  File "C:\Users\veron\cozmo-companion\venv\lib\site-packages\marvin\components\ai_application.py", line 299, in run
    functions=[t.as_openai_function() for t in tools],
  File "C:\Users\veron\cozmo-companion\venv\lib\site-packages\marvin\components\ai_application.py", line 299, in <listcomp>
    functions=[t.as_openai_function() for t in tools],
  File "C:\Users\veron\cozmo-companion\venv\lib\site-packages\marvin\tools\base.py", line 45, in as_openai_function
    schema = self.argument_schema()
  File "C:\Users\veron\cozmo-companion\venv\lib\site-packages\marvin\tools\base.py", line 40, in argument_schema
    schema = function_to_schema(self.fn or self.run)
  File "C:\Users\veron\cozmo-companion\venv\lib\site-packages\marvin\utilities\types.py", line 75, in function_to_schema
    Model = function_to_model(function, name=name)
  File "C:\Users\veron\cozmo-companion\venv\lib\site-packages\marvin\utilities\types.py", line 60, in function_to_model
    raise ValueError(
ValueError: Error while inspecting get_feedback_inquiry with signature (self, user_text: str) -> Optional[str]: no validator found for <class 'inspect._empty'>, see `arbitrary_types_allowed` in Config
Zaubeerer commented 1 year ago

Message 1:

Dear Marvin people,

I am new to the Discord Server and love MarvinAI.

I have a question regarding marvin-tool.

Not to spam this channel I put details in the thread.

Message 2 (answer to first 1 so it creates a new thread):

Message 2.1:

I created this function and added the tool decorator because I want to use it as a tool as follows:

function with tool decorator:

def function():
   pass

tool usage:

Message 2.2:

However, I get the following error:

SomePythonError

Here is the full error message:

SomePythonError

(Recommended) Message 2.3:

Here is what I already tried:

(Optional) Message 2.4:

Here is some information about my system:

Message 3:

I hope asking this here is appropriate.

Please let me know if another channel is more appropriate or if I should create an issue on GitHub.