KURUPRASATH-J commited on
Commit
78816cc
·
verified ·
1 Parent(s): e26da7a

Upload 4 files

Browse files
Files changed (4) hide show
  1. branding.json +26 -0
  2. requirements.txt +3 -0
  3. text_rag.py +42 -0
  4. ui-project-3.py +30 -0
branding.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "brand":
3
+ {
4
+ "organizationName": "HERE AND NOW AI",
5
+ "website": "https://hereandnowai.com",
6
+ "email": "info@hereandnowai.com",
7
+ "mobile": "+91 996 296 1000",
8
+ "slogan": "designed with passion for innovation",
9
+ "colors": {"primary": "#FFDF00", "secondary": "#004040"},
10
+ "logo":
11
+ {
12
+ "title": "https://raw.githubusercontent.com/hereandnowai/images/refs/heads/main/logos/logo-of-here-and-now-ai.png",
13
+ "favicon": "https://raw.githubusercontent.com/hereandnowai/images/refs/heads/main/logos/favicon-logo-with-name.png"}, "chatbot": {"avatar": "https://raw.githubusercontent.com/hereandnowai/images/refs/heads/main/logos/caramel.jpeg", "face": "https://raw.githubusercontent.com/hereandnowai/images/refs/heads/main/logos/caramel-face.jpeg"
14
+ },
15
+
16
+ "socialMedia":
17
+ {
18
+ "blog": "https://hereandnowai.com/blog",
19
+ "linkedin": "https://www.linkedin.com/company/hereandnowai/",
20
+ "instagram": "https://instagram.com/hereandnow_ai",
21
+ "github": "https://github.com/hereandnowai",
22
+ "x": "https://x.com/hereandnow_ai",
23
+ "youtube": "https://youtube.com/@hereandnow_ai"
24
+ }
25
+ }
26
+ }
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ openai
2
+ python-dotenv
3
+ gradio
text_rag.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from openai import OpenAI
2
+ from dotenv import load_dotenv
3
+ import os
4
+ import requests
5
+
6
+ load_dotenv()
7
+ api_key = os.getenv("GEMINI_API_KEY")
8
+ model = "gemini-2.5-flash-lite"
9
+ base_url = "https://generativelanguage.googleapis.com/v1beta/openai/"
10
+
11
+ client = OpenAI(base_url=base_url, api_key=api_key)
12
+
13
+ url="https://raw.githubusercontent.com/hereandnowai/vac/refs/heads/master/prospectus-context.txt"
14
+ response = requests.get(url)
15
+
16
+ script_dir = os.path.dirname(os.path.abspath(__file__))
17
+ file_path = os.path.join(script_dir, "profile-of-hereandnowai.txt")
18
+
19
+ with open(file_path, "wb") as f:
20
+ f.write(response.content)
21
+
22
+ text_path =file_path
23
+
24
+ try:
25
+ with open(text_path, "r",encoding="utf-8") as file:
26
+ text_lines = file.readlines()
27
+ text_content = "\n".join([line.strip() for line in text_lines if line.strip()])
28
+ except Exception as e:
29
+ print(f"Error reading the text file: {e}")
30
+ text_content = "Error extracting text from text file."
31
+
32
+ system_prompt =f"""You are Caramel AI, ai assistant build by Here and Now AI.Answer the user's question based only on the following context:\n\n{text_content}"""
33
+
34
+ def get_response(message, history):
35
+ messages = [{"role": "system", "content": system_prompt}]
36
+ messages.extend(history)
37
+ messages.append({"role": "user", "content": message})
38
+ response = client.chat.completions.create(model=model, messages=messages)
39
+ ai_response = response.choices[0].message.content
40
+ return ai_response
41
+
42
+ print(get_response("who is the ceo of here and now ai?", []))
ui-project-3.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from text_rag import get_response
3
+ import json
4
+ import os
5
+
6
+ with open(os.path.abspath(os.path.join(os.path.dirname(__file__), "branding.json"))) as f:
7
+ brand_info = json.load(f)["brand"]
8
+
9
+ with gr.Blocks(theme="default", title=brand_info["organizationName"]) as rag_bot:
10
+ gr.HTML(f"""
11
+ <div style="display: flex; justify-content:center; margin-bottom:20px">
12
+ <img src="{brand_info["logo"]["title"]}" alt="{brand_info["organizationName"]} Logo" style="width:200px;height:40px">
13
+ </div> """)
14
+
15
+ gr.ChatInterface(
16
+ fn=get_response,
17
+ chatbot=gr.Chatbot(height=500, avatar_images=(None, brand_info["chatbot"]["avatar"]), type="messages"),
18
+ title=brand_info["organizationName"],
19
+ description=brand_info["slogan"],
20
+ type="messages",
21
+ examples=[
22
+ ["Who is the CEO of Here and Now AI?"],
23
+ ["What is the mission of Here and Now AI?"],
24
+ ["Tell me about the team behind Here and Now AI."]
25
+
26
+ ]
27
+ )
28
+
29
+ if __name__ == "__main__":
30
+ rag_bot.launch()