Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add testing in the folder test #142

Open
jayendra-ram opened this issue Jun 2, 2023 · 2 comments
Open

add testing in the folder test #142

jayendra-ram opened this issue Jun 2, 2023 · 2 comments
Labels

Comments

@jayendra-ram
Copy link
Collaborator

No description provided.

@sweep-ai
Copy link
Contributor

sweep-ai bot commented Jun 2, 2023

Here is a draft response:

@jayendra-ram I have started working on adding testing to the plugnplai repo. My plan is to:

  1. Add unit tests for the PluginObject class in plugnplai/plugins.py using the unittest module. I will test the describe_api(), call_operation(), and count_tokens() methods.

  2. Create a tests package by adding an init.py file.

  3. Add a test_plugins.py file to the tests package to contain the unit tests.

Give me a minute!


I'm a bot that handles simple bugs and feature requests but I might make mistakes. Please be kind!

@sweep-ai sweep-ai bot mentioned this issue Jun 2, 2023
@edreisMD edreisMD changed the title add testing add testing in the folder test Jun 15, 2023
@edreisMD edreisMD added sweep and removed sweep labels Jun 15, 2023
@sweep-ai
Copy link
Contributor

sweep-ai bot commented Jun 15, 2023

Hey @jayendra-ram,

I've started working on this PR. The plan is to add unit tests for the functions in plugnplai/embeddings.py and update the Makefile with a new command to run these tests.

Give me a minute!

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description.

def __init__(self, manifests, returnList=None):
"""Initialize the PluginRetriever.
Parameters
----------
manifests : list
List of manifest objects.
returnList : list, optional
List of objects to be returned. Can be a list of URLs or a list of
objects like LangChain AIPluging object. Defaults to None.
"""
self.returnList = returnList
if self.returnList:
# add urls to manifests
for i in range(len(manifests)):
manifests[i]["plugin_object"] = self.returnList[i]
self.docs = [
Document(
page_content=manifest["description_for_model"],
metadata={
"plugin_name": manifest["name_for_model"],
"plugin_object": manifest.get("plugin_object", None),
},
)
for manifest in manifests
]
# Initialize embeddings
self.embeddings = OpenAIEmbeddings()
# Create vector store from documents
self.vector_store = FAISS.from_documents(self.docs, self.embeddings)
# Create a retriever
self.retriever = self.vector_store.as_retriever()
@classmethod
def from_urls(cls, urls):
"""Create a PluginRetriever object from a list of URLs.
Parameters
----------
urls : list
List of URLs.
Returns
-------
PluginRetriever
Initialized PluginRetriever object.
"""
manifests = [get_plugin_manifest(url) for url in urls]
return cls(manifests, urls)
@classmethod
def from_directory(cls, provider='plugnplai'):
"""Create a PluginRetriever object from a directory.
Parameters
----------
provider : str, optional
Provider name. Defaults to 'plugnplai'.
Returns
-------
PluginRetriever
Initialized PluginRetriever object.
"""
urls = get_plugins(filter = 'working', provider = provider)
manifests = [get_plugin_manifest(url) for url in urls]
return cls(manifests)
def retrieve_names(self, query):
"""Retrieve plugin names based on a query.
Parameters
----------
query :
Query string.
Returns
-------
list
List of plugin names.
"""
# Get relevant documents based on query
docs = self.retriever.get_relevant_documents(query)
# Get toolkits based on relevant documents
plugin_names = [d.metadata["plugin_name"] for d in docs]
return plugin_names

plugnplai/Makefile

Lines 1 to 25 in c4e932a

autoformat:
set -e
isort .
black --config pyproject.toml .
flake8
lint:
set -e
isort -c .
black --check --config pyproject.toml .
flake8
dev-lint:
pip install --upgrade black==22.8.0 coverage isort flake8 flake8-bugbear flake8-comprehensions pre-commit pooch
build-docs:
set -e
mkdir -p docs/source/_static
rm -rf docs/build
rm -rf docs/source/generated
cd docs && make html
all: autoformat build-docs
# Docs
watch-docs: ## Build and watch documentation

"\u001b[?25h"
]
}
],
"source": [
"!pip install plugnplai -q"
]

"\u001b[?25h"
]
}
],
"source": [
"!pip install plugnplai -q"
]

Embeddings
==============================
.. automodule:: plugnplai.embeddings
:members:
:inherited-members:
:undoc-members:


I'm a bot that handles simple bugs and feature requests but I might make mistakes. Please be kind!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants