LordFarquaad42 commited on
Commit
250dba9
1 Parent(s): 12ff168

added gpt to groovy

Browse files
app.py CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
2
  import chromadb
3
  from chromadb.utils import embedding_functions
4
  from sentence_transformers import SentenceTransformer
 
5
 
6
  client = chromadb.PersistentClient(path="./chromadb/")
7
  MODEL_NAME: str = "mixedbread-ai/mxbai-embed-large-v1" # ~ 0.5 gb
@@ -19,15 +20,26 @@ st.write("Data Avaliable: ", DATA_AVAL)
19
  user_question: str = st.text_area("Enter your groovy questions here")
20
  access_key: str = st.text_input("Enter your gpt key here", type="password")
21
 
22
- if st.button('Query Database'):
23
- if (user_question == ""):
24
- st.stop()
25
- else:
26
- st.header("Results")
27
- # Perform the Chromadb query.
28
- results = schemer.query(
29
- query_texts=[user_question],
30
- n_results=10,
31
- include = ['documents']
32
- )
33
- st.write(results["documents"])
 
 
 
 
 
 
 
 
 
 
 
 
2
  import chromadb
3
  from chromadb.utils import embedding_functions
4
  from sentence_transformers import SentenceTransformer
5
+ from openai import OpenAI
6
 
7
  client = chromadb.PersistentClient(path="./chromadb/")
8
  MODEL_NAME: str = "mixedbread-ai/mxbai-embed-large-v1" # ~ 0.5 gb
 
20
  user_question: str = st.text_area("Enter your groovy questions here")
21
  access_key: str = st.text_input("Enter your gpt key here", type="password")
22
 
23
+ if st.button('Query Database') & (access_key != "") & (user_question != ""):
24
+ openai_client = OpenAI(api_key=access_key)
25
+
26
+ st.header("Results")
27
+ # Perform the Chromadb query.
28
+ results = schemer.query(
29
+ query_texts=[user_question],
30
+ n_results=10,
31
+ include = ['documents']
32
+ )
33
+ documents = results["documents"]
34
+ response = openai_client.chat.completions.create(
35
+ model="gpt-3.5-turbo",
36
+ messages=[
37
+ {"role": "system", "content": "You are an expert in functional programming in Scheme, with great knowledge on programming paradigms."},
38
+ {"role": "user", "content": user_question},
39
+ {"role": "assistant", "content": str(documents)},
40
+ ]
41
+ )
42
+
43
+ st.write(response.choices[0].message.content)
44
+
45
+
chromadb/a81ece71-a3dd-473b-b74b-da3ab01ee2b8/data_level0.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:aead1bd9ef8ff975d543d56114a7c2d52ca5dcd57c8300e28505f18a10fe4a7c
3
  size 4236000
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8c78a24459aa9faddf76eeaabb412def3088a28fdb0e22eb84e18899ab90349b
3
  size 4236000
chromadb/a81ece71-a3dd-473b-b74b-da3ab01ee2b8/length.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:fc19b1997119425765295aeab72d76faa6927d4f83985d328c26f20468d6cc76
3
  size 4000
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1e7ebe78920ea8d3b0bcef3e4faefbe339db32201ec703c45b22300c77aeea7e
3
  size 4000