├── README.md └── Me.py /README.md: -------------------------------------------------------------------------------- 1 | Overview 2 | This repository contains the code for a conversational chatbot implemented in Langchian, a programming language designed for natural language processing. The chatbot is built to engage in meaningful conversations with users and respond to a variety of queries. 3 | 4 | Features 5 | Natural Language Processing: The chatbot utilizes advanced natural language processing techniques to understand and respond to user input. 6 | 7 | Conversational Logic: Implemented with a robust conversational logic, the chatbot can handle context and maintain a coherent conversation flow. 8 | 9 | Extensible: The code is designed to be easily extendable, allowing users to add new features or modify existing ones. 10 | 11 | Input a message when prompted. 12 | The chatbot will process the input and provide a response. 13 | Example 14 | plaintext 15 | Copy code 16 | User: Hello! 17 | Chatbot: Hi there! How can I help you today? 18 | User: What's the weather like? 19 | Chatbot: I'm sorry, I don't have access to real-time data. However, I can provide general information about weather patterns. 20 | Contributing 21 | If you'd like to contribute to the project, please follow these steps: 22 | 23 | Fork the repository. 24 | Create a new branch for your feature or bug fix. 25 | Make changes and submit a pull request. 26 | Contact 27 | [Muhammad Ahsan] - [muhammadahsan143@gmail.com] 28 | 29 | -------------------------------------------------------------------------------- /Me.py: -------------------------------------------------------------------------------- 1 | from langchain.llms import OpenAI 2 | from langchain.chains import ConversationChain 3 | from langchain.prompts import PromptTemplate 4 | from langchain.memory import ConversationBufferMemory 5 | import openai 6 | from secret_key import Api_keys 7 | import os 8 | os.environ['OPENAI_API_KEY']=Api_keys 9 | llm=OpenAI(temperature=0) 10 | 11 | AboutMe='''I am Muhammad Ahsan student of universty of engineering and technology Mardan 12 | i am from Nowshera Reciently i complete the course of python and Supervised Machine learning from 13 | Coursera website Now i am working on the Langchain So i have Amazing experience in the 14 | Python and machine learning. 15 | Overall, I am grateful for the experience and I am excited to see where my career takes me next, 16 | {history} 17 | Human: {input} 18 | AI Assistant:''' 19 | 20 | myprompt=PromptTemplate( 21 | input_variables=['history','input'], 22 | template=AboutMe 23 | ) 24 | 25 | myconversation=ConversationChain( 26 | prompt=myprompt, 27 | llm=llm, 28 | verbose=False, 29 | memory=ConversationBufferMemory(ai_prefix="Ai assitant") 30 | ) 31 | name="Muhammd Ahsan" 32 | food_choices="kfc,foods" 33 | fitness_level="50 percent " 34 | daily_activity="5 time prayer" 35 | mood="positive" 36 | goals="improved AI skill" 37 | 38 | 39 | # ai_response = myconversation.predict(input=f""" 40 | # Here is user data: 41 | # "user name is {name}, and their food choices include {food_choices}. 42 | # This user is actively pursuing a fitness journey, and they've provided insightful details: 43 | # - Fitness Level: {fitness_level} 44 | # - Daily Activity: {daily_activity} 45 | # - Mood: {mood} 46 | 47 | # Furthermore, they have set specific fitness goals, and their current 48 | # goals are as follows: {goals}. 49 | 50 | # # """) 51 | 52 | # print(response) 53 | while True: 54 | user_input = input("You: ") 55 | ai_response = myconversation.predict(input=user_input) 56 | print(f"Ahsan: {ai_response}") 57 | --------------------------------------------------------------------------------