Skip to content

Commit

Permalink
chore: files added
Browse files Browse the repository at this point in the history
  • Loading branch information
nuffin committed Oct 16, 2024
1 parent 0838ce0 commit dacc13b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
Empty file added llmsearch/clients/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion llmsearch/clients/localai.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def embedding(self, model: str, text: str) -> Optional[List[float]]:
# Example usage:
if __name__ == "__main__":
# Initialize the client
client = LocalAIClient(base_url="http://localhost:8080", model="your-model-name")
client = LocalAIClient(base_url="http://localhost:8080")

# Example 1: Generating text
prompt = "Tell me a story about a brave knight."
Expand Down
37 changes: 37 additions & 0 deletions llmsearch/tests/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import unittest
import json
from app import app # Assuming your Flask app is in app.py

class FlaskAppTestCase(unittest.TestCase):
def setUp(self):
# Set up the test client
self.app = app.test_client()
self.app.testing = True

def test_hello(self):
# Test the /api/hello route
response = self.app.get('/api/hello')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json, {'message': 'Hello, World!'})

def test_greet_default(self):
# Test the /api/greet route with default name
response = self.app.post('/api/greet', json={})
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json, {'message': 'Hello, Guest!'})

def test_greet_with_name(self):
# Test the /api/greet route with a name
response = self.app.post('/api/greet', json={'name': 'Alice'})
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json, {'message': 'Hello, Alice!'})

def test_greet_with_empty_name(self):
# Test the /api/greet route with an empty name
response = self.app.post('/api/greet', json={'name': ''})
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json, {'message': 'Hello, !'})

if __name__ == '__main__':
unittest.main()

2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ alembic==1.13.3
black==24.10.0
Flask-SQLAlchemy==3.1.1
bcrypt==4.2.0
tensorflow==2.17.0
transformers==4.45.2

0 comments on commit dacc13b

Please sign in to comment.