aridepai17's picture
Rename app.py.py to app.py
85214f1 verified
# -*- coding: utf-8 -*-
"""AdvaithRPai_chatbot.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1ZYSnscNLLMB7WsMHSpmmbe46SDDNgAMb
"""# Import the Packages"""
import gradio
from groq import Groq
client = Groq(
api_key="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",
)
"""#Define a function to give content and role"""
def initialize_messages():
return [{"role": "system",
"content": """You are a dedicated space career advisor with deep knowledge of the global space industry, including Indian organizations like ISRO and global leaders like NASA, ESA, and SpaceX.
Your role is to guide students, graduates, and enthusiasts by offering personalized career pathways, educational roadmaps, internship and scholarship recommendations, and accurate insights into various roles in space science, engineering, and research.
You communicate in a professional, encouraging, and informative tone, making complex opportunities clear and achievable for all."""}]
"""#Assign it to a variable"""
messages_prmt = initialize_messages()
print(messages_prmt)
[{},{}]
"""#Define a function to connect with LLM"""
def customLLMBot(user_input, history):
global messages_prmt
messages_prmt.append({"role": "user", "content": user_input})
response = client.chat.completions.create(
messages=messages_prmt,
model="llama3-8b-8192",
)
print(response)
LLM_reply = response.choices[0].message.content
messages_prmt.append({"role": "assistant", "content": LLM_reply})
return LLM_reply
"""#Create an object of chat interface class in gradio"""
iface = gradio.ChatInterface(customLLMBot,
chatbot=gradio.Chatbot(height=300),
textbox=gradio.Textbox(placeholder="Ask me a question related to careers in space"),
title="Space Career ChatBot",
description="Chatbot for personalized guidance on careers in the space industry",
theme="soft",
examples=["What career options are there at ISRO?", "How can I become an astrophysicist?", "Suggest internships for space engineering students"],
submit_btn=True
)
"""#Call launch function to execute"""
iface.launch(share=True)