-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Sawra/llamaindex extension #121
Conversation
Your free trial has expired. To keep using Ellipsis, sign up at https://app.ellipsis.dev for $20/seat/month or reach us at help@ellipsis.dev |
composio/tools/__init__.py
Outdated
@@ -53,6 +53,14 @@ def __init__( | |||
) | |||
self.runtime = runtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How was this working earlier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not see it to be used anywhere...it was just being set, so I just added proper setter, cause when we inherit from a child class, like from langchain for llamaindex, it was not possible to set that externally.
def _wrap_tool( | ||
self, | ||
schema: t.Dict[str, t.Any], | ||
entity_id: t.Optional[str] = None, | ||
) -> FunctionTool: | ||
"""Wraps composio tool as LlamaIndex FunctionTool object.""" | ||
app = schema["appName"] | ||
action = schema["name"] | ||
description = schema["description"] | ||
schema_params = schema["parameters"] | ||
|
||
action_func = self.prepare_python_function( | ||
app=app, | ||
action=action, | ||
description=description, | ||
schema_params=schema_params, | ||
entity_id=entity_id, | ||
) | ||
return FunctionTool.from_defaults( | ||
action_func, | ||
name=action, | ||
description=description, | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to pass the function params as pydantic fields in the llamaindex.
Otherwise, the param descriptions won't go the LLM.
https://docs.llamaindex.ai/en/latest/module_guides/deploying/agents/tools/#functiontool
from pydantic import Field
def get_weather(
location: str = Field(
description="A city name and state, formatted like '<name>, <state>'"
),
) -> str:
"""Usfeful for getting the weather for a given location."""
...
tool = FunctionTool.from_defaults(get_weather)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
composio/utils/shared.py
Outdated
Example Output: | ||
{ | ||
'owner': (<class 'str'>, FieldInfo(default=Ellipsis, description='The account owner of the repository.', extra={'examples': ([],)})), | ||
'repo': (<class 'str'>, FieldInfo(default=Ellipsis, description='The name of the repository without the `.git` extension.', extra={'examples': ([],)}))} | ||
} | ||
|
||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example Output: | |
{ | |
'owner': (<class 'str'>, FieldInfo(default=Ellipsis, description='The account owner of the repository.', extra={'examples': ([],)})), | |
'repo': (<class 'str'>, FieldInfo(default=Ellipsis, description='The name of the repository without the `.git` extension.', extra={'examples': ([],)}))} | |
} | |
""" | |
Example: | |
```python | |
>>> json_schema_to_fields_dict() | |
{ | |
'owner': (<class 'str'>, FieldInfo(default=Ellipsis, description='The account owner of the repository.', extra={'examples': ([],)})), | |
'repo': (<class 'str'>, FieldInfo(default=Ellipsis, description='The name of the repository without the `.git` extension.', extra={'examples': ([],)}))} | |
} | |
``` | |
""" |
(This is just a suggested format for writing docstring, you can ignore if you want to)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taken into consideration and modified.
plugins/autogen/setup.py
Outdated
@@ -9,7 +9,7 @@ | |||
|
|||
setup( | |||
name="composio_autogen", | |||
version="0.3.9-rc.3", | |||
version="0.3.9rc4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the version bump, we don't want perform a release with every single change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, how to proceed with this, should I match all the versions with master? master contains 0.3.9
everywhere I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you print and test the Llamaindex tools? Let's double check and post here the output to know all the descriptions are going.
composio/utils/shared.py
Outdated
), | ||
) | ||
|
||
|
||
def json_schema_to_fields_dict(json_schema: t.Dict[str, t.Any]) -> t.Type[BaseModel]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add UT for this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added UT.
composio/utils/shared.py
Outdated
@@ -258,3 +288,45 @@ def get_signature_format_from_schema_params(schema_params: t.Dict) -> t.List[Par | |||
else: | |||
optional_parameters.append(param) | |||
return required_parameters + optional_parameters | |||
|
|||
|
|||
def get_pydantic_signature_format_from_schema_params(schema_params: t.Dict) -> t.List[Parameter]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added UT.
Waiting for railway fix. |
Checked. |
@@ -78,16 +78,14 @@ def __init__( | |||
output_in_file=output_in_file, | |||
) | |||
|
|||
def _wrap_tool( | |||
def prepare_python_function( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def prepare_python_function( | |
def _prepare_python_function( |
If a user is not supposed to use a method directly define them as private methods
) | ||
self.runtime = "llamaindex" | ||
|
||
def prepare_python_function( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
@angrybayblade Fixed. |
Added composio-llamaindex plugin