Spaces:
Runtime error
Runtime error
updated redis client
Browse files
.env
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
OPENAI_API_KEY=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
|
2 |
-
ELEVEN_API_KEY=5db7eb7ac620c89ec32e72de98128417
|
3 |
-
REDIS_HOST=localhost
|
4 |
-
REDIS_PORT=6379
|
5 |
-
GRADIO_PASSWORD=oscepal
|
|
|
|
|
|
|
|
|
|
|
|
db.py
CHANGED
@@ -25,6 +25,7 @@ def get_client() -> Redis:
|
|
25 |
client = Redis(
|
26 |
host=os.environ["REDIS_HOST"],
|
27 |
port=os.environ["REDIS_PORT"],
|
|
|
28 |
decode_responses=True,
|
29 |
)
|
30 |
return client
|
@@ -57,14 +58,14 @@ def add_chat_by_uid(client: Redis, chat: Chat, uid: str):
|
|
57 |
client.json().arrappend(f"chats:by-user-uid:{uid}", "$", chat)
|
58 |
|
59 |
|
60 |
-
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
25 |
client = Redis(
|
26 |
host=os.environ["REDIS_HOST"],
|
27 |
port=os.environ["REDIS_PORT"],
|
28 |
+
password=os.environ["REDIS_PASSWORD"],
|
29 |
decode_responses=True,
|
30 |
)
|
31 |
return client
|
|
|
58 |
client.json().arrappend(f"chats:by-user-uid:{uid}", "$", chat)
|
59 |
|
60 |
|
61 |
+
if __name__ == "__main__":
|
62 |
|
63 |
+
client = get_client()
|
64 |
+
user = User(username="foo", uid="afa03747-a9ce-4200-964c-7816ec381fa9")
|
65 |
+
chat = Chat(patient="foo", messages=[("a", "b"), ("c", "d")])
|
66 |
|
67 |
+
create_user(client, user)
|
68 |
+
user = get_user_by_username(client, user['username'])
|
69 |
+
add_chat_by_uid(client, chat, user['uid'])
|
70 |
+
chats = get_user_chat_by_uid(client, user['uid'])
|
71 |
+
print(chats)
|