fromcarlostocosta commited on
Commit
b741ab2
1 Parent(s): 7db8d0a

Initial commit

Browse files
Files changed (5) hide show
  1. README.md +1 -12
  2. faiss_index/index.faiss +0 -0
  3. faiss_index/index.pkl +0 -0
  4. main.py +73 -0
  5. requirements.txt +8 -0
README.md CHANGED
@@ -1,12 +1 @@
1
- ---
2
- title: Mc Poc Gen Ai
3
- emoji: ⚡
4
- colorFrom: red
5
- colorTo: blue
6
- sdk: streamlit
7
- sdk_version: 1.29.0
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ # Mastercard Documentation Genius
 
 
 
 
 
 
 
 
 
 
 
faiss_index/index.faiss ADDED
Binary file (461 kB). View file
 
faiss_index/index.pkl ADDED
Binary file (82.7 kB). View file
 
main.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ import time
4
+
5
+ import InstructorEmbedding
6
+ import pandas as pd
7
+ import qdrant_client
8
+ import streamlit as st
9
+ from langchain.chains import RetrievalQA
10
+ from langchain.embeddings import HuggingFaceInstructEmbeddings
11
+ from langchain.llms import HuggingFaceHub
12
+ from langchain.text_splitter import (
13
+ CharacterTextSplitter,
14
+ RecursiveCharacterTextSplitter,
15
+ )
16
+ from langchain.vectorstores import Qdrant
17
+ from langchain_community.document_loaders import TextLoader
18
+ from langchain_community.vectorstores import FAISS, Chroma
19
+ from langchain_openai import OpenAIEmbeddings
20
+ from qdrant_client.http import models
21
+
22
+ from settings import SETTINGS
23
+
24
+ for setting, value in SETTINGS.items():
25
+ os.environ[setting] = value
26
+
27
+ client = qdrant_client.QdrantClient(
28
+ os.getenv("qdrant_host"), api_key=os.getenv("qdrant_key")
29
+ )
30
+
31
+
32
+ def main():
33
+ # st.set_page_config(page_title="Chat with multiple PDFs",
34
+ # page_icon=":books:")
35
+ # st.write(css, unsafe_allow_html=True)
36
+
37
+ st.set_page_config(page_title="Ask Qdrant", page_icon=":books:")
38
+ st.header("Ask your remote database 💬")
39
+
40
+ embeddings = OpenAIEmbeddings()
41
+
42
+ db = FAISS.load_local("faiss_index", embeddings)
43
+
44
+ llm = HuggingFaceHub(
45
+ repo_id="bigscience/bloom",
46
+ model_kwargs={"temperature": 0.2, "max_length": 512, "max_new_tokens": 100},
47
+ )
48
+
49
+ qa = RetrievalQA.from_chain_type(
50
+ llm=llm, chain_type="stuff", retriever=db.as_retriever()
51
+ )
52
+
53
+ # show user input
54
+ user_question = st.text_input("Ask a question Mastercard's available APIs:")
55
+ if user_question:
56
+ answer = qa.invoke(user_question)
57
+ st.write(f"Question: {answer['query']}")
58
+ st.write(f"Answer: {answer['result']}")
59
+
60
+ col1, col2, col3 = st.columns([1, 6, 1])
61
+
62
+ with col1:
63
+ st.write("")
64
+
65
+ with col2:
66
+ st.write("")
67
+
68
+ with col3:
69
+ st.image("mc_symbol_opt_73_3x.png")
70
+
71
+
72
+ if __name__ == "__main__":
73
+ main()
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ InstructorEmbedding==1.0.1
2
+ langchain==0.1.0
3
+ langchain_community==0.0.11
4
+ langchain_openai==0.0.2
5
+ pandas==2.1.4
6
+ qdrant_client==1.7.0
7
+ Requests==2.31.0
8
+ streamlit==1.18.1