Skip to content

Issue on page /notebooks/tool_usage/query_analysis.html #214

@komikndr

Description

@komikndr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions