CoolFace
Apppublic

Elafqattan/TelecomCS

sourceHugging Facemitupdated 11mo agoView on Hugging Face
0likes
app.py43 linesDownload Raw Back to root
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