File size: 4,144 Bytes
a625e7e
 
 
 
ef8059b
a625e7e
ef8059b
 
 
 
9089911
ef8059b
9089911
ef8059b
9089911
ef8059b
9089911
8d1be1f
a625e7e
 
 
 
 
 
 
 
 
 
 
 
 
8d1be1f
 
 
 
 
 
 
 
 
 
 
 
 
ef8059b
b1d0b0e
 
ef8059b
b1a1fd2
b1d0b0e
ef8059b
8d1be1f
 
 
 
a625e7e
 
 
 
 
 
 
 
 
 
8d1be1f
a625e7e
 
 
 
 
 
 
 
 
8d1be1f
db1c826
 
b1d0b0e
 
 
 
 
d0fed0f
b1d0b0e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import streamlit as st
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
from datetime import datetime

now = datetime.now() # current date and time
year = now.strftime("%Y")
st.write("year:", year)
month = now.strftime("%m")
st.write("month:", month)
day = now.strftime("%d")
st.write("day:", day)
time = now.strftime("%H:%M:%S")
st.write("time:", time)
date_time = now.strftime("%m/%d/%Y, %H:%M:%S")
st.write("date and time:",date_time)	

@st.experimental_singleton
def get_db_firestore():
    cred = credentials.Certificate('test.json')
    firebase_admin.initialize_app(cred, {'projectId': u'clinical-nlp-b9117',})
    db = firestore.client()
    return db

#add data to the beastie with a generic reusable upsert function
def upsert(collection, document, firefield, first, last, born):
    doc_ref = db.collection(collection).document(document)
    doc_ref.set({u'firefield': firefield, u'first': first, u'last': last, u'born': born
})

#read data back in firecollection
def selectCollection(collection):
    users_ref = db.collection(collection)
    docs = users_ref.stream()
    for doc in docs:
        st.write(f'{doc.id} => {doc.to_dict()}')
        
def selectCollectionDocument(collection, document):
    doc_ref = db.collection(collection).document(document)
    doc = doc_ref.get()
    st.write("The id is: ", doc.id)
    st.write("The contents are: ", doc.to_dict())
    
#add data to the beastie with a generic reusable upsert function
def upsertoftheminute(collection, document, firefield, first, last, born):
    date_time = now.strftime("%m/%d/%Y, %H:%M")
    doc_ref = db.collection(collection).document(document)
    doc_ref.set({u'firefield': firefield, u'first': first, u'last': last, u'born': date_time,})
 
 
st.write("singleton stateful connection to cloud firestore")
st.write(u"spin up some awesome 🤯 - episodic and semantic memory 🧠 for AI - here we come")
db = get_db_firestore()

# perceptual system processing agent that can store model 
upsert(u'firecollection', u'firedocument', u'users1', u'Ada', u'Lovelace', 1815)
upsert(u'firecollection', u'firedocument', u'users2', u'Aaron', u'Wacker', 1971)
upsert(u'firecollection1', u'firedocument3', u'users1', u'2022 - AI, Cognitive and Neuroscience to Assist and Augment Behavioral and Medical Health', u'https://www.youtube.com/watch?v=lvh3g7eszVQ&list=PLHgX2IExbFouJoqEr8JMF5MbZSbyC91-L', 2022)
upsert(u'firecollection2', u'firedocument2', u'users2', u'2022 - AI art sci-fi movies and stories 🎭🎞️🍿 by Aaron Wacker 🎬 🧠 🎨', u'https://www.youtube.com/playlist?list=PLHgX2IExbFotUCOCZgpj-5HZBzXOpFMYc', 2022)
upsert(u'firecollection3', u'firedocument3', u'users3', u'😶‍🌫️ 🤯Engineering Consciousness🧠  😶‍🌫️', u'https://youtu.be/rIpUf-Vy2JA?list=PLHgX2IExbFouJoqEr8JMF5MbZSbyC91-L&t=3622', 2022)
upsert(u'firecollection4', u'firedocument4', u'users4', u'🧠🌳Yggdrasil🌳🧠', u'https://github.com/AaronCWacker/Yggdrasil', 2022)

# its all stored here: https://console.firebase.google.com/u/0/project/clinical-nlp-b9117/firestore/data/~2FStreamlitSpaces


selectCollection(u'firecollection')
selectCollection(u'firecollection1')
selectCollection(u'firecollection2')
selectCollection(u'firecollection3')
selectCollection(u'firecollection4')
selectCollectionDocument(u"firecollection", u"firedocument")
selectCollectionDocument(u"firecollection1", u"firedocument3")
selectCollectionDocument(u"firecollection3", u"firedocument3")


# from https://huggingface.co/spaces/awacke1/RealTimeVoiceASR
selectCollectionDocument(u"ASRCollection", u"ASRDocument")


upsert(u'firecollection4', u'firedocument4', u'users4', u'🧠🌳Yggdrasil🌳🧠', u'https://github.com/AaronCWacker/Yggdrasil', 2022)

# intent - upsert at granularity of minute an aggregate document representing fields used in recent activity to replay shared state memory events
upsertoftheminute(u'TimeSeries', u'DocumentofMinute', u'TestUser1', u'🧠🌳Yggdrasil🌳🧠', u'https://huggingface.co/spaces/awacke1/FirestorePersistence', 2022)
selectCollectionDocument(u"TimeSeries", u"DocumentofMinute")