This guide provides a quick overview for getting started with the LangSmith document loader. For detailed documentation of all LangSmithLoader features and configurations head to the API reference.
For this example, we’ll clone and load a public LangSmith dataset. Cloning creates a copy of this dataset on our personal LangSmith account. You can only load datasets that you have a personal copy of.
Copy
Ask AI
from langsmith import Client as LangSmithClientls_client = LangSmithClient()dataset_name = "LangSmith Few Shot Datasets Notebook"dataset_public_url = ( "https://smith.langchain.com/public/55658626-124a-4223-af45-07fb774a6212/d")ls_client.clone_public_dataset(dataset_public_url)
Show me an example using Weaviate, but customizing the vectorStoreRetriever to return the top 10 k nearest neighbors.
Copy
Ask AI
print(docs[0].metadata["inputs"])
Copy
Ask AI
{'question': 'Show me an example using Weaviate, but customizing the vectorStoreRetriever to return the top 10 k nearest neighbors. '}
Copy
Ask AI
print(docs[0].metadata["outputs"])
Copy
Ask AI
{'answer': 'To customize the Weaviate client and return the top 10 k nearest neighbors, you can utilize the `as_retriever` method with the appropriate parameters. Here\'s how you can achieve this:\n\n\`\`\`python\n# Assuming you have imported the necessary modules and classes\n\n# Create the Weaviate client\nclient = weaviate.Client(url=os.environ["WEAVIATE_URL"], ...)\n\n# Initialize the Weaviate wrapper\nweaviate = Weaviate(client, index_name, text_key)\n\n# Customize the client to return top 10 k nearest neighbors using as_retriever\ncustom_retriever = weaviate.as_retriever(\n search_type="similarity",\n search_kwargs={\n \'k\': 10 # Customize the value of k as needed\n }\n)\n\n# Now you can use the custom_retriever to perform searches\nresults = custom_retriever.search(query, ...)\n\`\`\`'}
page = []for doc in loader.lazy_load(): page.append(doc) if len(page) >= 10: # do some paged operation, e.g. # index.upsert(page) # page = [] breaklen(page)