langchain-benchmarks icon indicating copy to clipboard operation
langchain-benchmarks copied to clipboard

Issue on page /notebooks/tool_usage/query_analysis.html

Open komikndr opened this issue 10 months ago • 0 comments

TLDR : I am trying to implement Semantic Few Shot for Tool calls, but error

Does SemanticSimilarityExampleSelector actually works with using List as one for its "messages"?

based on the Few-Shot code in the query_analysis notebook: few_shot_messages_for_example, is a List

    examples_for_semantic_search.append(
        {
            "question": example.inputs["question"][0]["content"],
            "messages": few_shot_messages_for_example,
        }
    )

But when i am trying to implement this:

examples1 = [
    HumanMessage(
        "What's the weather in Depok", name="example_user"
    ),
    AIMessage(
        "",
        name="assistant",
        tool_calls=[
            {"name": "get_weather", "args": {"city": "depok"}, "id": "1"}
        ],
    ),
    ToolMessage("Depok is sunny", tool_call_id="1"),
    AIMessage(
        "The weather in depok is sunny",
        name="assistant",
    ),
]

to my SemanticSimilarityExampleSelector. It throws TypeError: sequence item 1: expected str instance, List found. Which is correct to be ERROR if i am looking into SemanticSimilarityExampleSelector libs in langchain, since it is asking dict[str, str].

so i dont get it why the code in the query_analysis.html is working.

komikndr avatar Feb 11 '25 05:02 komikndr