itsJB commited on
Commit
a7a5ac8
β€’
1 Parent(s): a2c2e19

Upload 9 files

Browse files
.chainlit/config.toml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ # Whether to enable telemetry (default: true). No personal data is collected.
3
+ enable_telemetry = true
4
+
5
+
6
+ # List of environment variables to be provided by each user to use the app.
7
+ user_env = []
8
+
9
+ # Duration (in seconds) during which the session is saved when the connection is lost
10
+ session_timeout = 3600
11
+
12
+ # Enable third parties caching (e.g LangChain cache)
13
+ cache = false
14
+
15
+ # Authorized origins
16
+ allow_origins = ["*"]
17
+
18
+ # Follow symlink for asset mount (see https://github.com/Chainlit/chainlit/issues/317)
19
+ # follow_symlink = false
20
+
21
+ [features]
22
+ # Show the prompt playground
23
+ prompt_playground = true
24
+
25
+ # Process and display HTML in messages. This can be a security risk (see https://stackoverflow.com/questions/19603097/why-is-it-dangerous-to-render-user-generated-html-or-javascript)
26
+ unsafe_allow_html = false
27
+
28
+ # Process and display mathematical expressions. This can clash with "$" characters in messages.
29
+ latex = false
30
+
31
+ # Authorize users to upload files with messages
32
+ multi_modal = true
33
+
34
+ # Allows user to use speech to text
35
+ [features.speech_to_text]
36
+ enabled = false
37
+ # See all languages here https://github.com/JamesBrill/react-speech-recognition/blob/HEAD/docs/API.md#language-string
38
+ # language = "en-US"
39
+
40
+ [UI]
41
+ # Name of the app and chatbot.
42
+ name = "Chatbot"
43
+
44
+ # Show the readme while the thread is empty.
45
+ show_readme_as_default = true
46
+
47
+ # Description of the app and chatbot. This is used for HTML tags.
48
+ # description = ""
49
+
50
+ # Large size content are by default collapsed for a cleaner ui
51
+ default_collapse_content = true
52
+
53
+ # The default value for the expand messages settings.
54
+ default_expand_messages = false
55
+
56
+ # Hide the chain of thought details from the user in the UI.
57
+ hide_cot = false
58
+
59
+ # Link to your github repo. This will add a github button in the UI's header.
60
+ # github = ""
61
+
62
+ # Specify a CSS file that can be used to customize the user interface.
63
+ # The CSS file can be served from the public directory or via an external link.
64
+ # custom_css = "/public/test.css"
65
+
66
+ # Specify a Javascript file that can be used to customize the user interface.
67
+ # The Javascript file can be served from the public directory.
68
+ # custom_js = "/public/test.js"
69
+
70
+ # Specify a custom font url.
71
+ # custom_font = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap"
72
+
73
+ # Override default MUI light theme. (Check theme.ts)
74
+ [UI.theme]
75
+ #font_family = "Inter, sans-serif"
76
+ [UI.theme.light]
77
+ #background = "#FAFAFA"
78
+ #paper = "#FFFFFF"
79
+
80
+ [UI.theme.light.primary]
81
+ #main = "#F80061"
82
+ #dark = "#980039"
83
+ #light = "#FFE7EB"
84
+
85
+ # Override default MUI dark theme. (Check theme.ts)
86
+ [UI.theme.dark]
87
+ #background = "#FAFAFA"
88
+ #paper = "#FFFFFF"
89
+
90
+ [UI.theme.dark.primary]
91
+ #main = "#F80061"
92
+ #dark = "#980039"
93
+ #light = "#FFE7EB"
94
+
95
+
96
+ [meta]
97
+ generated_by = "1.0.401"
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+ RUN useradd -m -u 1000 user
3
+ USER user
4
+ ENV HOME=/home/user \
5
+ PATH=/home/user/.local/bin:$PATH
6
+ WORKDIR $HOME/app
7
+ COPY --chown=user . $HOME/app
8
+ COPY ./requirements.txt ~/app/requirements.txt
9
+ RUN pip install -r requirements.txt
10
+ COPY . .
11
+ CMD ["chainlit", "run", "app.py", "--port", "7860"]
README.md CHANGED
@@ -1,4 +1,19 @@
1
- ---
2
- license: mit
3
- title: Finance Knowledge Bot
4
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ RAG use-case implementation using Llamaindex
2
+
3
+ Supercharge your RAG pipeline with the following:
4
+
5
+ - Framework -> [Llamaindex](https://docs.llamaindex.ai/en/stable/index.html)
6
+ - Loader -> [SimpleDirectoryLoader](https://docs.llamaindex.ai/en/stable/module_guides/loading/simpledirectoryreader.html)
7
+ - Chunking -> [Semantic Chunking](https://docs.llamaindex.ai/en/stable/examples/node_parsers/semantic_chunking.html)
8
+ - Embeddings -> [Gemini Embeddings](https://docs.llamaindex.ai/en/stable/examples/node_parsers/semantic_chunking.html)
9
+ - Reranking -> [Cohere Rerank Model](https://docs.llamaindex.ai/en/stable/examples/node_postprocessor/CohereRerank.html)
10
+ - LLM -> [Groq Mistral](https://docs.llamaindex.ai/en/stable/examples/llm/groq.html#groq)
11
+
12
+ For index creation follow notebook file ```rag.ipynb```
13
+
14
+ To run application:
15
+
16
+ ```
17
+ pip install -r requirements.txt
18
+ chainlit run app.py
19
+ ```
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from llama_index.core import StorageContext, ServiceContext, load_index_from_storage
2
+ from llama_index.core.callbacks.base import CallbackManager
3
+ from llama_index.embeddings.huggingface import HuggingFaceEmbedding
4
+ from llama_index.llms.groq import Groq
5
+ import os
6
+ from dotenv import load_dotenv
7
+ load_dotenv()
8
+ import chainlit as cl
9
+
10
+ GROQ_API_KEY = os.getenv("GROQ_API_KEY")
11
+
12
+ @cl.on_chat_start
13
+ async def factory():
14
+ storage_context = StorageContext.from_defaults(persist_dir="./storage_mini")
15
+
16
+ embed_model = HuggingFaceEmbedding(model_name="sentence-transformers/all-MiniLM-L6-v2")
17
+
18
+ llm = Groq(model="llama3-70b-8192", api_key=GROQ_API_KEY)
19
+
20
+ service_context = ServiceContext.from_defaults(embed_model=embed_model, llm=llm,
21
+ callback_manager=CallbackManager([cl.LlamaIndexCallbackHandler()]),
22
+ )
23
+
24
+ index = load_index_from_storage(storage_context, service_context=service_context)
25
+
26
+ chat_engine = index.as_chat_engine(service_context=service_context)
27
+
28
+ cl.user_session.set("chat_engine", chat_engine)
29
+
30
+ @cl.on_message
31
+ async def main(message: cl.Message):
32
+ chat_engine = cl.user_session.get("chat_engine")
33
+ response = await cl.make_async(chat_engine.chat)(message.content)
34
+
35
+ response_message = cl.Message(content="")
36
+
37
+ for token in response.response:
38
+ await response_message.stream_token(token=token)
39
+
40
+ await response_message.send()
chainlit.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Welcome to Chainlit! πŸš€πŸ€–
2
+
3
+ Hi there, Developer! πŸ‘‹ We're excited to have you on board. Chainlit is a powerful tool designed to help you prototype, debug and share applications built on top of LLMs.
4
+
5
+ ## Useful Links πŸ”—
6
+
7
+ - **Documentation:** Get started with our comprehensive [Chainlit Documentation](https://docs.chainlit.io) πŸ“š
8
+ - **Discord Community:** Join our friendly [Chainlit Discord](https://discord.gg/k73SQ3FyUh) to ask questions, share your projects, and connect with other developers! πŸ’¬
9
+
10
+ We can't wait to see what you create with Chainlit! Happy coding! πŸ’»πŸ˜Š
11
+
12
+ ## Welcome screen
13
+
14
+ To modify the welcome screen, edit the `chainlit.md` file at the root of your project. If you do not want a welcome screen, just leave this file empty.
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ llama-index==0.10.18
2
+ llama-index-llms-groq==0.1.3
3
+ chainlit==1.0.401
4
+ groq==0.4.2
5
+ python-dotenv==1.0.1
6
+ llama-index-embeddings-gemini==0.1.4
7
+ llama-index-postprocessor-cohere-rerank==0.1.2
storage_mini/default__vector_store.json ADDED
The diff for this file is too large to render. See raw diff
 
storage_mini/docstore.json ADDED
The diff for this file is too large to render. See raw diff
 
storage_mini/index_store.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"index_store/data": {"f42a6af7-0775-453f-9b3b-3a2ae2f23eab": {"__type__": "vector_store", "__data__": "{\"index_id\": \"f42a6af7-0775-453f-9b3b-3a2ae2f23eab\", \"summary\": null, \"nodes_dict\": {\"f719fbb6-e0ed-40ac-839a-c0d6a6505b4c\": \"f719fbb6-e0ed-40ac-839a-c0d6a6505b4c\", \"9c3dc423-ed76-48d2-b81c-0590b366d4ea\": \"9c3dc423-ed76-48d2-b81c-0590b366d4ea\", \"e8dc3a2b-45e9-4a4d-968f-df887afb4193\": \"e8dc3a2b-45e9-4a4d-968f-df887afb4193\", \"36830b4c-c762-45dc-bb77-2693fc244f1d\": \"36830b4c-c762-45dc-bb77-2693fc244f1d\", \"15b83726-755a-4f0c-b035-fe7b7be94d29\": \"15b83726-755a-4f0c-b035-fe7b7be94d29\", \"9c3c3031-2dfe-4b0c-ae9a-ec6fa4178520\": \"9c3c3031-2dfe-4b0c-ae9a-ec6fa4178520\", \"1e00f16c-0f83-4d24-9122-0e3c5dd43381\": \"1e00f16c-0f83-4d24-9122-0e3c5dd43381\", \"18302cce-5e0a-4808-8d63-8eab892c9136\": \"18302cce-5e0a-4808-8d63-8eab892c9136\", \"eb32dd9c-263c-4b5a-a3f1-2090aad558ce\": \"eb32dd9c-263c-4b5a-a3f1-2090aad558ce\", \"95fe93ab-e60b-471d-b80a-4dfa7d35d665\": \"95fe93ab-e60b-471d-b80a-4dfa7d35d665\", \"b3546102-2e25-4f07-a23b-a78da158ae34\": \"b3546102-2e25-4f07-a23b-a78da158ae34\", \"647ce2bb-cd94-42c8-b4c5-0f81509da4fb\": \"647ce2bb-cd94-42c8-b4c5-0f81509da4fb\", \"e8cff6e2-bd24-4282-b4e1-a22b95a53fd1\": \"e8cff6e2-bd24-4282-b4e1-a22b95a53fd1\", \"cd3b0c9a-43e9-482c-af84-493f6b5b98bb\": \"cd3b0c9a-43e9-482c-af84-493f6b5b98bb\", \"fd5d33a1-5db8-4f5f-991d-b54f13243cfe\": \"fd5d33a1-5db8-4f5f-991d-b54f13243cfe\", \"91bac189-20cf-4e89-bcd1-f9112e6b23f3\": \"91bac189-20cf-4e89-bcd1-f9112e6b23f3\", \"5b749bb1-b495-4f9b-9633-c5766aaff86f\": \"5b749bb1-b495-4f9b-9633-c5766aaff86f\", \"139a71be-fecd-4dfb-ad7a-96c5c73bbd13\": \"139a71be-fecd-4dfb-ad7a-96c5c73bbd13\", \"2812354c-1a5b-4d5a-9c70-26c5778bea37\": \"2812354c-1a5b-4d5a-9c70-26c5778bea37\", \"ac0adedf-2f5c-4dbb-8c37-cc3157afed4c\": \"ac0adedf-2f5c-4dbb-8c37-cc3157afed4c\", \"af88595e-fbc6-4b03-8bd1-f4f8e0eaacc3\": \"af88595e-fbc6-4b03-8bd1-f4f8e0eaacc3\", \"9467763a-ab87-450f-a2f6-2a3f29f4b3d0\": \"9467763a-ab87-450f-a2f6-2a3f29f4b3d0\", \"b8778ed1-69a6-486a-a6f9-6598ab89d0f2\": \"b8778ed1-69a6-486a-a6f9-6598ab89d0f2\", \"8a0938fe-5c32-428e-a07a-a327cee6ba9d\": \"8a0938fe-5c32-428e-a07a-a327cee6ba9d\", \"c7d5aa44-17ed-49cf-87df-ac9d21424f00\": \"c7d5aa44-17ed-49cf-87df-ac9d21424f00\", \"48dbadb9-f968-456f-abd6-c6dbfcc05af2\": \"48dbadb9-f968-456f-abd6-c6dbfcc05af2\", \"2a5d0268-38a3-4ae6-bd4a-a0b7d618a8b7\": \"2a5d0268-38a3-4ae6-bd4a-a0b7d618a8b7\", \"b256ea12-a69a-4aa7-9d82-8ad303f3def5\": \"b256ea12-a69a-4aa7-9d82-8ad303f3def5\", \"cc95ab32-410b-4556-a1f9-736e34e6224a\": \"cc95ab32-410b-4556-a1f9-736e34e6224a\", \"52bcb311-a69f-4c04-8cb7-b228d5967004\": \"52bcb311-a69f-4c04-8cb7-b228d5967004\", \"df0fdc8f-c6aa-4f17-a07a-4ea94ee15f5f\": \"df0fdc8f-c6aa-4f17-a07a-4ea94ee15f5f\", \"d10de204-884e-4e17-bbb1-878d487ae62b\": \"d10de204-884e-4e17-bbb1-878d487ae62b\", \"ff107060-ec0c-4609-b181-e3a3b57910b8\": \"ff107060-ec0c-4609-b181-e3a3b57910b8\", \"41a3320c-fc40-4e81-bef2-88c34b84b83a\": \"41a3320c-fc40-4e81-bef2-88c34b84b83a\", \"100de5f1-2721-44fb-b0fe-ecd640a54aca\": \"100de5f1-2721-44fb-b0fe-ecd640a54aca\", \"69fed107-290b-43a9-981c-043aab1d04ec\": \"69fed107-290b-43a9-981c-043aab1d04ec\", \"58d09af6-0af0-4e8f-bd66-b55d7b90082f\": \"58d09af6-0af0-4e8f-bd66-b55d7b90082f\", \"9e42dc7d-25c1-43b7-bf7e-1fdee1019e1a\": \"9e42dc7d-25c1-43b7-bf7e-1fdee1019e1a\", \"81d298c7-edda-410b-bb03-8802a18c5b86\": \"81d298c7-edda-410b-bb03-8802a18c5b86\", \"6e826612-dc68-4a98-9558-f8361108f178\": \"6e826612-dc68-4a98-9558-f8361108f178\", \"7ffbc337-6667-4c61-95a3-5b797123e5d2\": \"7ffbc337-6667-4c61-95a3-5b797123e5d2\", \"8b06e867-10ed-4cd8-ba0c-a94b88d73bfb\": \"8b06e867-10ed-4cd8-ba0c-a94b88d73bfb\", \"5461bd27-e097-49dc-b58e-530fe60a89e0\": \"5461bd27-e097-49dc-b58e-530fe60a89e0\", \"a6d784e3-cf5d-4b6a-ba9c-ec9c3a6cad30\": \"a6d784e3-cf5d-4b6a-ba9c-ec9c3a6cad30\", \"5b0a4e27-8f6b-40c6-9ad9-b7f09d653460\": \"5b0a4e27-8f6b-40c6-9ad9-b7f09d653460\", \"bff67aa8-cc12-4bc4-980e-bb45daed6560\": \"bff67aa8-cc12-4bc4-980e-bb45daed6560\", \"000d2343-ddea-45c1-a806-73a83c9f92f7\": \"000d2343-ddea-45c1-a806-73a83c9f92f7\", \"04acb165-b69a-4940-ba82-9affe6fcbcb7\": \"04acb165-b69a-4940-ba82-9affe6fcbcb7\", \"0b47d871-4134-404b-9b70-2ff8f888a887\": \"0b47d871-4134-404b-9b70-2ff8f888a887\", \"189d8c40-7d88-429f-89b1-d02354f18d8b\": \"189d8c40-7d88-429f-89b1-d02354f18d8b\", \"94a5d3bd-7f93-404e-a21d-3b34af89c622\": \"94a5d3bd-7f93-404e-a21d-3b34af89c622\", \"2ee8190e-003e-47e2-b3f9-11aa768559ce\": \"2ee8190e-003e-47e2-b3f9-11aa768559ce\", \"48a819d4-e040-4801-a003-6bd8077b43ad\": \"48a819d4-e040-4801-a003-6bd8077b43ad\", \"d561a2d0-8d62-43d4-aa05-3b9c9401d490\": \"d561a2d0-8d62-43d4-aa05-3b9c9401d490\", \"8ba8d825-e588-4909-865d-6e53f79d9fab\": \"8ba8d825-e588-4909-865d-6e53f79d9fab\", \"0af23475-0461-48f6-9845-9634d2fd30bf\": \"0af23475-0461-48f6-9845-9634d2fd30bf\", \"ca52491b-16c3-4c72-9699-37b1472443eb\": \"ca52491b-16c3-4c72-9699-37b1472443eb\", \"9a09946c-02f3-4f3d-b1f3-64f9e59d142c\": \"9a09946c-02f3-4f3d-b1f3-64f9e59d142c\", \"a702db54-ac43-452a-afc9-d2225d0e26ce\": \"a702db54-ac43-452a-afc9-d2225d0e26ce\", \"15f333b0-1ea8-4fc4-8554-09cd1587e42a\": \"15f333b0-1ea8-4fc4-8554-09cd1587e42a\", \"e6b8a52f-d0ac-42f0-8848-a499c359b5f5\": \"e6b8a52f-d0ac-42f0-8848-a499c359b5f5\", \"00dfc6ed-879f-4dfc-b3b9-2426d514a8d2\": \"00dfc6ed-879f-4dfc-b3b9-2426d514a8d2\", \"f7ee6304-f742-4583-93df-7d650bd51ec2\": \"f7ee6304-f742-4583-93df-7d650bd51ec2\", \"b21e8060-a593-444b-8b26-d9b49188ca63\": \"b21e8060-a593-444b-8b26-d9b49188ca63\", \"d538a328-8f77-4921-9b28-de7abe7405a2\": \"d538a328-8f77-4921-9b28-de7abe7405a2\", \"f362deff-e7a2-428f-9e0d-01d769ae16e1\": \"f362deff-e7a2-428f-9e0d-01d769ae16e1\", \"bc3b6df4-3140-4824-829f-cd3e614a5a11\": \"bc3b6df4-3140-4824-829f-cd3e614a5a11\", \"b93f1306-641d-4d02-b329-7ce6056646f4\": \"b93f1306-641d-4d02-b329-7ce6056646f4\", \"9a551eb1-05a3-4def-9ceb-5f137869efab\": \"9a551eb1-05a3-4def-9ceb-5f137869efab\", \"76cd02b4-85bc-4d6e-8e61-1446722e8649\": \"76cd02b4-85bc-4d6e-8e61-1446722e8649\", \"11a0886f-1d48-4f81-97ac-76d850ffc7b0\": \"11a0886f-1d48-4f81-97ac-76d850ffc7b0\", \"0e769f56-20ce-4b8e-8b1a-0f267b9fc806\": \"0e769f56-20ce-4b8e-8b1a-0f267b9fc806\", \"f90f8e75-8e99-42e9-b0c4-965389a7f205\": \"f90f8e75-8e99-42e9-b0c4-965389a7f205\", \"7450a420-5b0a-4fc8-9db8-1a900295f084\": \"7450a420-5b0a-4fc8-9db8-1a900295f084\", \"51b44fdd-9994-489d-9a44-50f2ff305d29\": \"51b44fdd-9994-489d-9a44-50f2ff305d29\", \"f8cf5a7b-6e73-47d3-8e68-497201fd7496\": \"f8cf5a7b-6e73-47d3-8e68-497201fd7496\", \"1dadcc93-645d-4e92-8587-73595a882f06\": \"1dadcc93-645d-4e92-8587-73595a882f06\", \"8e80dfd3-5774-4a52-ae0e-14c068b91047\": \"8e80dfd3-5774-4a52-ae0e-14c068b91047\", \"75851282-14cc-4073-962a-7a29cad95540\": \"75851282-14cc-4073-962a-7a29cad95540\", \"85b2d6d5-6af5-4971-b228-94c2d73fc2b7\": \"85b2d6d5-6af5-4971-b228-94c2d73fc2b7\", \"386d6c1a-4414-45b9-9102-58ecb7671cf5\": \"386d6c1a-4414-45b9-9102-58ecb7671cf5\", \"50256f45-02a3-4bd1-87fc-b1e841fb7750\": \"50256f45-02a3-4bd1-87fc-b1e841fb7750\", \"b42fffd1-bfd6-4e9b-9f9f-6a8b92ed3e92\": \"b42fffd1-bfd6-4e9b-9f9f-6a8b92ed3e92\", \"aba0ee12-426e-40fd-93a9-4d1a0996d9ab\": \"aba0ee12-426e-40fd-93a9-4d1a0996d9ab\", \"4ec8b241-2e4e-41e0-b30e-28b1b61d7778\": \"4ec8b241-2e4e-41e0-b30e-28b1b61d7778\", \"bcba2bc2-e4d1-44b3-8c8d-1489c2e93b90\": \"bcba2bc2-e4d1-44b3-8c8d-1489c2e93b90\"}, \"doc_id_dict\": {}, \"embeddings_dict\": {}}"}}}