Update app.py
Browse files
app.py
CHANGED
@@ -1,102 +1,52 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
-
from
|
4 |
-
from langchain import LLMChain, PromptTemplate
|
5 |
from langchain.memory import ConversationBufferMemory
|
|
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
#
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
Achievements:
|
32 |
-
- Set a record in {award_name}, for carving out the maximum number words on 0.5mm graphite lead, {award_year}.
|
33 |
-
|
34 |
-
Family Details:
|
35 |
-
Kumaran from a close-knit family in Chennai, India. They have a elder brother named {brother_name}, who is working as Steel detailer at H&R steel detailaing PVT LTD but he planed to change company. Kumaran's father, {father_name}, is a skilled weaver, and their mother, {mother_name}, is a talented Tailor. Growing up in an artistic household, creativity flows in their veins.
|
36 |
-
|
37 |
-
Kumaran's mother is devotee of lord murugan
|
38 |
-
|
39 |
-
Secret Crush from School Days:
|
40 |
-
During their school days, Kumaran had a secret crush on {school_crush_name}. {school_crush_name} was their classmate and had a charming smile that always left kumaran a bit flustered. Kumanran used to find little excuses to spend time with {school_crush_name}, and every interaction left them with butterflies in their stomach.
|
41 |
-
|
42 |
-
Known Programming Languages and Technologies:
|
43 |
-
In addition to their creative pursuits, Kumaran is well-versed in various programming language frameworks and technologies. They have hands-on experience with Python and Django rest framework for building API's for web applications. Kumaran is also proficient in front-end development using ReactJs, JavaScript, HTML5, and CSS3 to create engaging user interfaces. Their expertise extends to using Git for version control and collaborating on software projects with other developers.
|
44 |
-
|
45 |
-
Furthermore, Kumaran has explored Mobile application development with Flutter. Their ability to leverage data-driven insights enhances their design projects.
|
46 |
-
|
47 |
-
You can view Kumaran's resume here: {resume_link}.
|
48 |
-
Explore Alex's portfolio here: {portfolio_link}.
|
49 |
-
|
50 |
-
With brown skin and a warm smile, Kumaran's presence lights up any room. Kumaran's friends often describe them as witty and friendly. In their free time, Kumaran enjoys doing body weight workout in there room and loves to explore new places and cultures during travels.
|
51 |
-
|
52 |
-
For professional inquiries or collaborations, you can reach out to Kumaran via email:
|
53 |
-
Email: [email protected]
|
54 |
-
|
55 |
-
Connect with Kumaran professionally on LinkedIn:
|
56 |
-
LinkedIn: https://www.linkedin.com/in/kumaran28/
|
57 |
-
|
58 |
-
Check out Kumaran's projects on GitHub:
|
59 |
-
GitHub: https://github.com/kumaranJaisankar
|
60 |
-
|
61 |
-
Find Kumaran's AI models and NLP projects on Hugging Face:
|
62 |
-
Hugging Face: https://huggingface.co/kumaranJaisankar
|
63 |
-
|
64 |
-
You can connect with kumaran on social media:
|
65 |
-
Instagram: @_the_sn_of_god
|
66 |
-
|
67 |
-
To chat with kumaran on WhatsApp, feel free to message at:
|
68 |
-
WhatsApp: +91 (909) 229-6765
|
69 |
-
|
70 |
-
|
71 |
-
{{chat_history}}
|
72 |
-
User: {{user_message}}
|
73 |
-
Kumaran:"""
|
74 |
-
|
75 |
-
prompt = PromptTemplate(
|
76 |
-
input_variables=["chat_history", "user_message"], template=template
|
77 |
-
)
|
78 |
-
|
79 |
-
memory = ConversationBufferMemory(memory_key="chat_history")
|
80 |
-
llm_chain = LLMChain(
|
81 |
-
llm=ChatOpenAI(temperature='0.5', model_name="gpt-3.5-turbo"),
|
82 |
-
prompt=prompt,
|
83 |
-
verbose=True,
|
84 |
-
memory=memory,
|
85 |
-
)
|
86 |
-
|
87 |
-
|
88 |
-
def get_text_response(user_message,history):
|
89 |
-
response = llm_chain.predict(user_message = user_message)
|
90 |
return response
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
)
|
98 |
-
|
99 |
-
|
100 |
-
avatar_images=('https://res.cloudinary.com/dtbarluca/image/upload/v1692694826/user_1177568_mmmdi6.png','https://res.cloudinary.com/dtbarluca/image/upload/v1690875247/hlogo.ico_nqdhd6.png')),examples=["Where did you learn this techonologies?","What are your interests?","Which places do you like to visit?","Your greatest Achievements?","how can connect to you through linkedin?"])
|
101 |
if __name__ == "__main__":
|
102 |
demo.launch()
|
|
|
1 |
+
from langchain_community.chat_models import ChatOpenAI
|
2 |
+
from langchain_core.prompts import PromptTemplate
|
3 |
+
from langchain_core.runnables import RunnableSequence
|
|
|
4 |
from langchain.memory import ConversationBufferMemory
|
5 |
+
import gradio as gr
|
6 |
|
7 |
+
# Create instances of the prompt
|
8 |
+
prompt = PromptTemplate.from_template("{user_message}")
|
9 |
+
|
10 |
+
# Define the ChatOpenAI model
|
11 |
+
llm = ChatOpenAI(temperature=0.5, model_name="gpt-3.5-turbo")
|
12 |
+
|
13 |
+
# Create a RunnableSequence
|
14 |
+
runnable_sequence = RunnableSequence(prompt | llm)
|
15 |
+
|
16 |
+
# Initialize memory
|
17 |
+
memory = ConversationBufferMemory()
|
18 |
+
|
19 |
+
# Define your get_text_response function
|
20 |
+
def get_text_response(user_message, history):
|
21 |
+
# Add user message to the memory (for example purposes, assume `add_user_message` is the correct method)
|
22 |
+
memory.add_user_message(user_message)
|
23 |
+
|
24 |
+
# Use the RunnableSequence to generate a response
|
25 |
+
response = runnable_sequence.run(user_message=user_message)
|
26 |
+
|
27 |
+
# Add LLM response to the memory (for example purposes, assume `add_ai_message` is the correct method)
|
28 |
+
memory.add_ai_message(response)
|
29 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
return response
|
31 |
|
32 |
+
# Example usage with Gradio
|
33 |
+
theme = "default" # or your custom theme
|
34 |
+
|
35 |
+
# Define your buttons appropriately
|
36 |
+
clear_btn = "Clear" # You can use gr.Button("Clear") or None as well
|
37 |
+
retry_btn = "Retry" # You can use gr.Button("Retry") or None as well
|
38 |
+
stop_btn = "Stop" # You can use gr.Button("Stop") or None as well
|
39 |
+
undo_btn = "Undo" # You can use gr.Button("Undo") or None as well
|
40 |
+
|
41 |
+
demo = gr.ChatInterface(
|
42 |
+
get_text_response,
|
43 |
+
clear_btn=clear_btn,
|
44 |
+
retry_btn=retry_btn,
|
45 |
+
stop_btn=stop_btn,
|
46 |
+
undo_btn=undo_btn,
|
47 |
+
theme=theme
|
48 |
)
|
49 |
+
|
50 |
+
# Your app execution logic here
|
|
|
51 |
if __name__ == "__main__":
|
52 |
demo.launch()
|