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

Update test_apis.py to implement rag-completion test #81

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion example/test_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,32 @@ def test_inference_by_request_stream(self):
}
res=requests.post(url=self.base_url+"/v1/chat/completions", json=data,headers={"Content-Type": "application/json", "Authorization":"Bearer no-key"},)
self.assertEqual(res.status_code, 200)

def test_rag_completion(self):
#Load the dataset
dataset = {
"name": "aisuko/squad01-v2",
"url": "https://datasets-server.huggingface.co/rows?dataset=aisuko%2Fsquad01-v2&config=default&split=validation&offset=0&length=100"
}
loadDataset = requests.post(url=self.base_url+"/v1/embeddings/dataset", json=dataset, headers={"Content-Type": "application/json", "Authorization":"Bearer no-key"})
self.assertEqual(loadDataset.status_code, 200)

#Test RAG completions
data = {
"messages": [
{
"role": "system",
"content": "You are a helpful assistant who helps users solve their questions."
},
{
"role": "user",
"content": "tell me something interest about massachusetts"
}
],
"dataset_name": "aisuko/squad01-v2"
}
res = requests.post(url=self.base_url+"/v1/chat/rag-completions", json=data, headers={"Content-Type": "application/json", "Authorization":"Bearer no-key"})
self.assertEqual(res.status_code, 200)

def test_embedding_api(self):
data = {
Expand All @@ -101,4 +127,4 @@ def test_version_api(self):
res = requests.get(url=self.base_url+"/v1/version")
self.assertEqual(res.status_code, 200)
data = res.json().get("inference_engine_version")
self.assertEqual('server--b1-2321a5e', data)
self.assertEqual('server--b1-27d4b7c', data)
Loading