aurelio-labs / semantic-router

Superfast AI decision making and intelligent processing of multi-modal data.
https://www.aurelio.ai/semantic-router
MIT License
2.13k stars 220 forks source link

Dynamic route function calling - 'HuggingFacePipeline' object has no attribute 'extract_function_inputs' #208

Open mrhimanshu opened 8 months ago

mrhimanshu commented 8 months ago

I encounter an issue with calling function using Mistral 7b model through Huggingface pipeline

AttributeError                            Traceback (most recent call last)
Cell In [57], [line 1](vscode-notebook-cell:?execution_count=57&line=1)
----> [1](vscode-notebook-cell:?execution_count=57&line=1) out = rl("what is the time in new york city?")
      [2](vscode-notebook-cell:?execution_count=57&line=2) # get_time(**out.function_call)

File /usr/local/lib/python3.9/dist-packages/semantic_router/layer.py:262, in RouteLayer.__call__(self, text, vector, simulate_static)
    [260](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/layer.py:260)         else:
    [261](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/layer.py:261)             route.llm = self.llm
--> [262](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/layer.py:262)     return route(text)
    [263](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/layer.py:263) elif passed and route is not None and simulate_static:
    [264](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/layer.py:264)     return RouteChoice(
    [265](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/layer.py:265)         name=route.name,
    [266](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/layer.py:266)         function_call=None,
    [267](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/layer.py:267)         similarity_score=None,
    [268](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/layer.py:268)     )

File /usr/local/lib/python3.9/dist-packages/semantic_router/route.py:70, in Route.__call__(self, query)
     [65](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/route.py:65)         raise ValueError(
     [66](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/route.py:66)             "Query is required for dynamic routes. Please ensure the `query` "
     [67](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/route.py:67)             "argument is passed."
     [68](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/route.py:68)         )
     [69](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/route.py:69)     # if a function schema is provided we generate the inputs
---> [70](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/route.py:70)     extracted_inputs = self.llm.extract_function_inputs(
     [71](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/route.py:71)         query=query, function_schema=self.function_schema
     [72](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/route.py:72)     )
     [73](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/route.py:73)     func_call = extracted_inputs
     [74](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/route.py:74) else:
     [75](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/dist-packages/semantic_router/route.py:75)     # otherwise we just pass None for the call

AttributeError: 'HuggingFacePipeline' object has no attribute 'extract_function_inputs'
ashraq1455 commented 8 months ago

@mrhimanshu, could you please share the code to reproduce this issue? Thanks.

mrhimanshu commented 8 months ago

@ashraq1455 can we use GPTQ based model ?

Above error occurred when I initialized the gptq model and passed it in wrapper class.