Skip to content

Support pre-serialized funcs in tool calling#67

Merged
jph00 merged 5 commits intomainfrom
erikgaas/support_pre_serialized_funcs
Mar 16, 2025
Merged

Support pre-serialized funcs in tool calling#67
jph00 merged 5 commits intomainfrom
erikgaas/support_pre_serialized_funcs

Conversation

@erikgaas
Copy link
Contributor

In solveit I want to be able to send a request to claudette to perform a tool request, but I cannot send a raw function reference over a server call, so I'm allowing client to take in the schema-fied functions directly so they can be passed over a post request call.

https://github.com/AnswerDotAI/solveit/pull/352

@gitnotebooks
Copy link

gitnotebooks bot commented Mar 10, 2025

Found 1 changed notebook. Review the changes at https://app.gitnotebooks.com/AnswerDotAI/claudette/pull/67

@erikgaas erikgaas marked this pull request as draft March 10, 2025 06:22
@johnowhitaker
Copy link

johnowhitaker commented Mar 12, 2025

I think this does an either-or. If we pass both some tools and some tools_serialized it'll only get tools_serialized I think... Maybe something like this:

if tools or tools_serialized: kwargs['tools'] = [get_schema(o) for o in listify(tools)] + listify(tools_serialized)

Not sure what we want or if I'm right, just flagging before I forget!

@austinvhuang
Copy link
Contributor

austinvhuang commented Mar 12, 2025

In most cases if both are passed in there's probably a bug elsewhere so one solution is to encode that invariant (do something like only having a tools argument and faking type dispatch by doing isinstance(tools, List[str]) vs isinstance(tools, List[Dict]) and i except that isinstance doesn't play well with generics.).

Keeping this as is, I think your suggestion is a reasonable behavior for that case.

@austinvhuang austinvhuang marked this pull request as ready for review March 12, 2025 20:55
@erikgaas erikgaas requested review from comhar and jph00 March 13, 2025 02:24
@jph00
Copy link
Contributor

jph00 commented Mar 13, 2025

Thanks @erikgaas -- nice idea! How about, instead of having a separate param, we instead treat any str tools as pre-serialized?

Also, could you see whether we can use reclm from @comhar to have cached AI outputs, so that we don't have such big diffs in the future?

@erikgaas
Copy link
Contributor Author

Thanks @erikgaas -- nice idea! How about, instead of having a separate param, we instead treat any str tools as pre-serialized?

Also, could you see whether we can use reclm from @comhar to have cached AI outputs, so that we don't have such big diffs in the future?

Ooo good idea.

@erikgaas
Copy link
Contributor Author

@jph00 I tried reclm but there is an issue with streaming responses. I want to go into reclm and fix this. I'm hoping to just make it work for streaming, but I also think it would be good to have a disable_reclm function too.

As for your suggestion above, what do you think about serializing if the tool is callable else passing it through?
The other way of doing it would be if dict pass through else run schema.

@comhar
Copy link
Contributor

comhar commented Mar 13, 2025

@jph00 I tried reclm but there is an issue with streaming responses. I want to go into reclm and fix this. I'm hoping to just make it work for streaming, but I also think it would be good to have a disable_reclm function too.

As for your suggestion above, what do you think about serializing if the tool is callable else passing it through? The other way of doing it would be if dict pass through else run schema.

Adding streaming support to reclm is proving to be a little tricky. Rather than rushing a solution, let's hold off on integrating reclm into claudette for now.

@jph00
Copy link
Contributor

jph00 commented Mar 13, 2025 via email

@austinvhuang
Copy link
Contributor

With b0e0e66 + holding off on reclm for now, can we merge this?

@erikgaas
Copy link
Contributor Author

I think it's ready to merge. Will add reclm in a followup if I'm the first to it.

@jph00 jph00 merged commit 548f3e8 into main Mar 16, 2025
@ncoop57 ncoop57 added the enhancement New feature or request label May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants