Elafqattan/TelecomCS
0
1 2import os3import gradio as gr4from langchain_community.document_loaders import WebBaseLoader5from langchain_text_splitters import RecursiveCharacterTextSplitter6from langchain_community.vectorstores import FAISS7from langchain_openai import OpenAIEmbeddings, ChatOpenAI8from langchain.chains import RetrievalQA9 10 11 12# --- ๐ง Gradio Interface ---13def chatbot(query):14 if not query.strip():15 return "Please enter a question."16 try:17 answer = qa_chain.run(query)18 return answer19 except Exception as e:20 return f"โ Error: {str(e)}"21 22 23demo = gr.Interface(24 fn=chatbot,25 inputs=gr.Textbox(26 label="Ask about Jawwy ๐",27 placeholder="e.g., What are the latest offers or SIM options?",28 lines=229 ),30 outputs=gr.Textbox(31 label="๐ค Jawwy Assistant Response",32 lines=8,33 show_copy_button=True34 ),35 title="๐ฌ Jawwy AI Assistant",36 description="Ask questions about Jawwy services, offers, and SIM details โ powered by LangChain, FAISS, and GPT.",37 theme=gr.themes.Soft()38)39 40# --- ๐ Launch App ---41if __name__ == "__main__":42 demo.launch(server_name="0.0.0.0", server_port=7860)43 