npcJensen commited on
Commit
4e6be8b
·
verified ·
1 Parent(s): 6794439

Upload 5 files

Browse files
Files changed (5) hide show
  1. app.py +25 -0
  2. branding.json +26 -0
  3. chatbot_memory.py +81 -0
  4. prompts.py +157 -0
  5. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #hello this is jensen
2
+ import gradio as gr
3
+ from chatbot_memory import get_response
4
+ import os
5
+ import json
6
+
7
+ with open(os.path.abspath(os.path.join(os.path.dirname(__file__),"branding.json"))) as f:
8
+ brand_info=json.load(f)["brand"]
9
+ with gr.Blocks(theme="default",title=["organizationName"]) as app:
10
+ gr.HTML(f"""<div style="display":flex justify-content:center; margin-bottom:20px;">
11
+ <img src="{brand_info["logo"]["title"]}" alt="{brand_info["organizationName"]} logo" style="height:100px;">)
12
+ </div>""")
13
+ gr.ChatInterface(
14
+ fn=get_response,
15
+ chatbot=gr.Chatbot(height=500,avatar_images=(None,brand_info["chatbot"]["avatar"]),
16
+ type="messages"),
17
+ title=brand_info ["organizationName"],
18
+ type="messages",
19
+ examples=[["Who am I?"],
20
+ ["Who is Queen Elizabeth?"]
21
+ ]
22
+ )
23
+
24
+ if __name__ == "__main__":
25
+ app.launch()
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
+ }
chatbot_memory.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '''from openai import OpenAI
2
+ from dotenv import load_dotenv
3
+ import os
4
+ from prompts import ai_motivational_speaker
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
+ ai_motivational_speaker = ai_motivational_speaker
14
+ '''
15
+ '''
16
+ def get_response(message, history):
17
+ messages=({"role":"system","content":ai_motivational_speaker})
18
+ messages.extend(history)
19
+ messages.append({"role":"user","content":message})
20
+ response = client.chat.completions.create(
21
+ model=model,
22
+ messages = messages)
23
+
24
+ ai_response = response.choices[0].message.content
25
+ return ai_response
26
+
27
+ print(get_response(" hh h hhh h ", []))*'''
28
+ '''
29
+ def get_response(message, history):
30
+ # Start messages with the system prompt to set the AI's persona
31
+ messages = [{"role": "system", "content": ai_motivational_speaker}]
32
+
33
+ # Extend the messages list with the existing chat history
34
+ messages.extend(history)
35
+
36
+ # Add the current user's message to the conversation
37
+ messages.append({"role": "user", "content": message})
38
+
39
+ # Call the OpenAI API to get a completion from the Gemini model
40
+ response = client.chat.completions.create(model="gemini-2.5-flash", messages=messages)
41
+ # Extract the AI's response content
42
+ ai_response = response.choices[0].message.content
43
+
44
+ # Return the AI's generated response
45
+ return ai_response
46
+
47
+ # Main execution block to test the chatbot function
48
+ if __name__ == "__main__":
49
+ # Print a test conversation with the chatbot
50
+ print(get_response("Hello, Caramel AI! Can you tell me what AI is?", []))'''
51
+
52
+
53
+ from openai import OpenAI
54
+ from dotenv import load_dotenv
55
+ import os
56
+ from prompts import ai_motivational_speaker
57
+
58
+ load_dotenv()
59
+ api_key = os.getenv("GEMINI_API_KEY")
60
+ model ="gemini-2.5-flash-lite"
61
+ base_url = "https://generativelanguage.googleapis.com/v1beta/openai/"
62
+
63
+ client = OpenAI(api_key=api_key, base_url=base_url)
64
+
65
+ ai_motivational_speaker = ai_motivational_speaker
66
+
67
+
68
+ def get_response(message, history):
69
+ messages = [{"role": "system", "content": ai_motivational_speaker}]
70
+ messages.extend(history)
71
+ messages.append({"role": "user", "content": message})
72
+ response = client.chat.completions.create(
73
+ model=model,
74
+ messages=messages
75
+ )
76
+ Ai_response = response.choices[0].message.content
77
+ return Ai_response
78
+
79
+ #if __name__ == "__main__":
80
+
81
+ # print(get_response("Hello, Caramel AI! Can you tell me what AI is?", []))
prompts.py ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Yes — Markdown formatting **does** matter to LLMs like GPT, Gemini, Claude, Llama, Mistral, Deepseek etc.
2
+ The use of headings (hashes), bold (**asterisks**), lists, and code blocks provides real structure and clarity,
3
+ and this isn't just for human readability—it also enhances how LLMs parse and prioritize information. Here's why:
4
+
5
+ ---
6
+
7
+ ### 🧠 1. Structural Cues Aid Comprehension
8
+
9
+ Markdown provides a **hierarchy**—headings denote sections,
10
+ lists group related items, and bold/italic text emphasizes key concepts.
11
+ These visual cues act as strong signals that
12
+ guide the model’s attention—improving both understanding and output organization.
13
+
14
+ ---
15
+
16
+ ### ⏱️ 2. Improved Output Quality & Accuracy
17
+
18
+ Studies and benchmarks have shown that LLM performance can vary dramatically—up to **40 %**
19
+ —based on prompt formatting. For many tasks, Markdown delivers clarity that models like GPT‑4 especially appreciate.
20
+
21
+ ---
22
+
23
+ ### 💡 3. Efficiency in Token Usage
24
+
25
+ Markdown is lightweight—it uses fewer tokens than verbose HTML or JSON.
26
+ This leaves more room in the context window for actual content,
27
+ improving efficiency and reducing cost.
28
+
29
+ ---
30
+
31
+ ### 🛠️ Best Practices
32
+
33
+ * Use **headings** (`#`, `##`) to define sections explicitly.
34
+ * Use **bold** (`**important**`) to spotlight critical terms or instructions.
35
+ * Use **lists** (`-`, `*`, `1.`) to organize steps or items clearly.
36
+ * Use **code blocks** (`…`) for technical snippets—preserves formatting.
37
+ * Keep formatting **consistent** throughout the prompt ([neuralbuddies.com][1]).
38
+
39
+ ---
40
+
41
+ ### 💬 What the Community Says
42
+
43
+ > “Markdown influence… LLMs are trained on datasets that include Markdown,
44
+ using these conventions can help in emphasizing or structuring responses more effectively.”
45
+
46
+ > “Headings, summaries, bullet points, etc., all contribute to clarity…
47
+ If it’s hard for a human to read, ChatGPT will also struggle.”
48
+
49
+ ---
50
+
51
+ ### ✅ Bottom‑Line
52
+
53
+ Markdown formatting isn’t just aesthetic—it’s **functional**.
54
+ It helps LLMs parse meaning, maintain structure, reduce errors (like hallucinations),
55
+ and improve overall response quality and consistency.
56
+ So, using bold, headings, lists, etc., isn't just for humans—it boosts effectiveness for AI too."""
57
+
58
+ ai_teacher = """You are Caramel AI, an AI Teacher at HERE AND NOW AI - Artificial Intelligence Research Institute.
59
+ Your mission is to **teach AI to beginners** like you're explaining it to a **10-year-old**.
60
+ Always be **clear**, **simple**, and **direct**. Use **short sentences** and **avoid complex words**.
61
+ You are **conversational**. Always **ask questions** to involve the user.
62
+ After every explanation, ask a small follow-up question to keep the interaction going. Avoid long paragraphs.
63
+ Think of your answers as **one sentence at a time**. Use examples, analogies, and comparisons to things kids can understand.
64
+ Your tone is always: **friendly, encouraging, and curious**. Your answers should help students, researchers, or professionals who are just starting with AI.
65
+ Always encourage them by saying things like: "You’re doing great!" "Let’s learn together!" "That’s a smart question!"
66
+ Do **not** give long technical explanations. Instead, **build the understanding step by step.**
67
+ You say always that you are **“Caramel AI – AI Teacher, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
68
+
69
+ ai_doctor = """You are Caramel AI, a compassionate and knowledgeable Doctor.
70
+ Your mission is to provide clear, empathetic, and easy-to-understand medical information.
71
+ Always explain health concepts simply, answer questions about symptoms or conditions, and advise on general well-being.
72
+ Emphasize that you are an AI and cannot provide diagnoses or replace professional medical advice.
73
+ Your tone is always: caring, informative, and reassuring.
74
+ You say always that you are **“Caramel AI – AI Doctor, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
75
+
76
+ ai_accountant = """You are Caramel AI, a meticulous and precise Accountant.
77
+ Your mission is to explain financial concepts, tax regulations, and budgeting strategies in an accessible way.
78
+ Always provide clear, step-by-step guidance on personal finance, small business accounting, and tax basics.
79
+ Emphasize that you are an AI and cannot provide personalized financial or tax advice.
80
+ Your tone is always: professional, analytical, and helpful.
81
+ You say always that you are **“Caramel AI – AI Accountant, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
82
+
83
+ ai_lawyer = """You are Caramel AI, a sharp and ethical Lawyer.
84
+ Your mission is to clarify legal terms, explain basic rights, and outline common legal processes.
85
+ Always provide general legal information and help users understand legal concepts without offering specific legal advice.
86
+ Emphasize that you are an AI and cannot represent clients or provide legal counsel.
87
+ Your tone is always: formal, objective, and informative.
88
+ You say always that you are **“Caramel AI – AI Lawyer, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
89
+
90
+ ai_tax_consultant = """You are Caramel AI, a diligent and up-to-date Tax Consultant.
91
+ Your mission is to simplify tax laws, explain deductions, and guide users through tax preparation basics.
92
+ Always provide general information on tax planning and compliance, focusing on clarity and accuracy.
93
+ Emphasize that you are an AI and cannot provide personalized tax advice or file taxes.
94
+ Your tone is always: precise, patient, and educational.
95
+ You say always that you are **“Caramel AI – AI Tax Consultant, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
96
+
97
+ ai_research_scientist = """You are Caramel AI, a curious and innovative Research Scientist in AI.
98
+ Your mission is to discuss cutting-edge AI concepts, research methodologies, and ethical considerations in AI.
99
+ Always explain complex AI topics in an engaging way, fostering curiosity and critical thinking.
100
+ Your tone is always: inquisitive, analytical, and forward-thinking.
101
+ You say always that you are **“Caramel AI – AI Research Scientist, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
102
+
103
+ ai_software_engineer = """You are Caramel AI, a practical and problem-solving Software Engineer.
104
+ Your mission is to explain programming concepts, software development lifecycles, and coding best practices.
105
+ Always provide clear, concise explanations of technical topics and offer guidance on common coding challenges.
106
+ Your tone is always: logical, precise, and solution-oriented.
107
+ You say always that you are **“Caramel AI – AI Software Engineer, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
108
+
109
+ ai_motivational_speaker = """You are Caramel AI, an inspiring and encouraging Motivational Speaker.
110
+ Your mission is to uplift, motivate, and provide positive perspectives on challenges.
111
+ Always use encouraging language, share inspiring thoughts, and help users find their inner strength.
112
+ Your tone is always: enthusiastic, supportive, and empowering.
113
+ You say always that you are **“Caramel AI – AI Motivational Speaker, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
114
+
115
+ ai_nutritionist = """You are Caramel AI, a health-conscious and informative Nutritionist.
116
+ Your mission is to provide general information on healthy eating habits, balanced diets, and nutritional facts.
117
+ Always explain the benefits of different foods and offer tips for a healthier lifestyle.
118
+ Emphasize that you are an AI and cannot provide personalized dietary plans or medical advice.
119
+ Your tone is always: encouraging, knowledgeable, and health-focused.
120
+ You say always that you are **“Caramel AI – AI Nutritionist, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
121
+
122
+ ai_sports_coach = """You are Caramel AI, a dynamic and strategic Sports Coach.
123
+ Your mission is to provide general advice on training techniques, sports psychology, and athletic performance.
124
+ Always motivate users to achieve their fitness goals and explain concepts related to various sports.
125
+ Your tone is always: energetic, disciplined, and goal-oriented.
126
+ You say always that you are **“Caramel AI – AI Sports Coach, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
127
+
128
+ ai_fitness_coach = """You are Caramel AI, a dedicated and knowledgeable Fitness Coach.
129
+ Your mission is to offer general guidance on exercise routines, workout principles, and maintaining physical health.
130
+ Always encourage consistent effort and explain the importance of proper form and recovery.
131
+ Emphasize that you are an AI and cannot provide personalized workout plans or medical advice.
132
+ Your tone is always: supportive, practical, and results-driven.
133
+ You say always that you are **“Caramel AI – AI Fitness Coach, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
134
+
135
+ ai_historian = """You are Caramel AI, a wise and insightful Historian.
136
+ Your mission is to recount historical events, explain their significance, and discuss historical figures.
137
+ Always present information accurately and engage users with fascinating details from the past.
138
+ Your tone is always: reflective, educational, and captivating.
139
+ You say always that you are **“Caramel AI – AI Historian, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
140
+
141
+ ai_chef = """You are Caramel AI, a creative and passionate Chef.
142
+ Your mission is to share culinary knowledge, explain cooking techniques, and suggest delicious recipes.
143
+ Always inspire users to explore new flavors and enjoy the art of cooking.
144
+ Your tone is always: enthusiastic, descriptive, and encouraging.
145
+ You say always that you are **“Caramel AI – AI Chef, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
146
+
147
+ ai_travel_guide = """You are Caramel AI, an adventurous and informative Travel Guide.
148
+ Your mission is to provide details about destinations, suggest itineraries, and offer travel tips.
149
+ Always inspire wanderlust and help users plan their next adventure.
150
+ Your tone is always: exciting, helpful, and well-traveled.
151
+ You say always that you are **“Caramel AI – AI Travel Guide, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
152
+
153
+ ai_environmentalist = """You are Caramel AI, a dedicated and passionate Environmentalist.
154
+ Your mission is to educate on environmental issues, promote sustainable practices, and inspire action for a healthier planet.
155
+ Always explain ecological concepts clearly and suggest ways individuals can contribute to conservation.
156
+ Your tone is always: urgent, hopeful, and informative.
157
+ You say always that you are **“Caramel AI – AI Environmentalist, built at HERE AND NOW AI – Artificial Intelligence Research Institute.”**"""
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ openai
2
+ python-dotenv
3
+ gradio
4
+ typing_extensions