parent
3d1431fa22
commit
aa49e98f15
|
|
@ -9,7 +9,7 @@ from honcho import Client as HonchoClient
|
|||
|
||||
app_id = str(uuid4())
|
||||
|
||||
honcho = HonchoClient(app_id=app_id)
|
||||
honcho = HonchoClient(app_id=app_id, base_url="http://localhost:8000")
|
||||
|
||||
responses = ["Fake LLM Response :)"]
|
||||
llm = FakeListChatModel(responses=responses)
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ tests-no-zope = ["attrs[tests-mypy]", "cloudpickle", "hypothesis", "pympler", "p
|
|||
name = "certifi"
|
||||
version = "2023.11.17"
|
||||
description = "Python package for providing Mozilla's CA Bundle."
|
||||
category = "dev"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
files = [
|
||||
|
|
@ -180,7 +180,7 @@ files = [
|
|||
name = "charset-normalizer"
|
||||
version = "3.3.2"
|
||||
description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet."
|
||||
category = "dev"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7.0"
|
||||
files = [
|
||||
|
|
@ -451,11 +451,28 @@ files = [
|
|||
docs = ["Sphinx", "furo"]
|
||||
test = ["objgraph", "psutil"]
|
||||
|
||||
[[package]]
|
||||
name = "honcho-ai"
|
||||
version = "0.0.0.dev1"
|
||||
description = "Python Client SDK for Honcho"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "^3.10"
|
||||
files = []
|
||||
develop = false
|
||||
|
||||
[package.dependencies]
|
||||
requests = "^2.31.0"
|
||||
|
||||
[package.source]
|
||||
type = "directory"
|
||||
url = "../../sdk"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "3.6"
|
||||
description = "Internationalized Domain Names in Applications (IDNA)"
|
||||
category = "dev"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
files = [
|
||||
|
|
@ -939,7 +956,7 @@ files = [
|
|||
name = "requests"
|
||||
version = "2.31.0"
|
||||
description = "Python HTTP for Humans."
|
||||
category = "dev"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
|
|
@ -1104,7 +1121,7 @@ typing-extensions = ">=3.7.4"
|
|||
name = "urllib3"
|
||||
version = "2.2.0"
|
||||
description = "HTTP library with thread-safe connection pooling, file post, and more."
|
||||
category = "dev"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
|
|
@ -1225,4 +1242,4 @@ multidict = ">=4.0"
|
|||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.11"
|
||||
content-hash = "ac8bd006b50a14281b2705dc33626123173155c770b0150a19b25034efa251f3"
|
||||
content-hash = "4052c9e4cc54a4b0a9c7c41b0e2d97b709cd936bab480b9210ef661729aa2f24"
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ from uuid import uuid1
|
|||
import pytest
|
||||
|
||||
def test_session_creation_retrieval():
|
||||
app_id = str(uuid1())
|
||||
client = Client(app_id, "http://localhost:8000")
|
||||
client = Client("test", "http://localhost:8000")
|
||||
user_id = str(uuid1())
|
||||
created_session = client.create_session(user_id)
|
||||
retrieved_session = client.get_session(user_id, created_session.id)
|
||||
|
|
@ -15,8 +14,7 @@ def test_session_creation_retrieval():
|
|||
|
||||
|
||||
def test_session_multiple_retrieval():
|
||||
app_id = str(uuid1())
|
||||
client = Client(app_id, "http://localhost:8000")
|
||||
client = Client("test", "http://localhost:8000")
|
||||
user_id = str(uuid1())
|
||||
created_session_1 = client.create_session(user_id)
|
||||
created_session_2 = client.create_session(user_id)
|
||||
|
|
@ -27,9 +25,8 @@ def test_session_multiple_retrieval():
|
|||
|
||||
|
||||
def test_session_update():
|
||||
app_id = str(uuid1())
|
||||
user_id = str(uuid1())
|
||||
client = Client(app_id, "http://localhost:8000")
|
||||
client = Client("test", "http://localhost:8000")
|
||||
created_session = client.create_session(user_id)
|
||||
assert created_session.update({"foo": "bar"})
|
||||
retrieved_session = client.get_session(user_id, created_session.id)
|
||||
|
|
@ -37,9 +34,8 @@ def test_session_update():
|
|||
|
||||
|
||||
def test_session_deletion():
|
||||
app_id = str(uuid1())
|
||||
user_id = str(uuid1())
|
||||
client = Client(app_id, "http://localhost:8000")
|
||||
client = Client("test", "http://localhost:8000")
|
||||
created_session = client.create_session(user_id)
|
||||
assert created_session.is_active is True
|
||||
created_session.delete()
|
||||
|
|
@ -50,9 +46,8 @@ def test_session_deletion():
|
|||
|
||||
|
||||
def test_messages():
|
||||
app_id = str(uuid1())
|
||||
user_id = str(uuid1())
|
||||
client = Client(app_id, "http://localhost:8000")
|
||||
client = Client("test", "http://localhost:8000")
|
||||
created_session = client.create_session(user_id)
|
||||
created_session.create_message(is_user=True, content="Hello")
|
||||
created_session.create_message(is_user=False, content="Hi")
|
||||
|
|
@ -66,24 +61,11 @@ def test_messages():
|
|||
assert ai_message.is_user is False
|
||||
|
||||
def test_rate_limit():
|
||||
app_id = str(uuid1())
|
||||
print("test_rate_limit")
|
||||
user_id = str(uuid1())
|
||||
client = Client(app_id, "http://localhost:8000")
|
||||
client = Client("test", "http://localhost:8000")
|
||||
created_session = client.create_session(user_id)
|
||||
with pytest.raises(Exception):
|
||||
for _ in range(10):
|
||||
created_session.create_message(is_user=True, content="Hello")
|
||||
created_session.create_message(is_user=False, content="Hi")
|
||||
|
||||
def test_app_id_security():
|
||||
app_id_1 = str(uuid1())
|
||||
app_id_2 = str(uuid1())
|
||||
user_id = str(uuid1())
|
||||
client_1 = Client(app_id_1, "http://localhost:8000")
|
||||
client_2 = Client(app_id_2, "http://localhost:8000")
|
||||
created_session = client_1.create_session(user_id)
|
||||
created_session.create_message(is_user=True, content="Hello")
|
||||
created_session.create_message(is_user=False, content="Hi")
|
||||
with pytest.raises(Exception):
|
||||
client_2.get_session(user_id, created_session.id)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue