sachin-philip commited on
Commit
648a915
·
1 Parent(s): 3bdcd4a

temp changes to test

Browse files
Files changed (5) hide show
  1. README.md +48 -3
  2. __pycache__/agent.cpython-311.pyc +0 -0
  3. agent.py +29 -0
  4. app.py +8 -26
  5. requirements.txt +6 -1
README.md CHANGED
@@ -1,12 +1,57 @@
1
  ---
2
- title: Streamlit Panda
3
  emoji: 🐠
4
  colorFrom: green
5
  colorTo: red
6
- sdk: streamlit
7
- sdk_version: 1.28.2
8
  app_file: app.py
9
  pinned: false
10
  ---
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Agentic FLow
3
  emoji: 🐠
4
  colorFrom: green
5
  colorTo: red
6
+ sdk: gradio
7
+ sdk_version: 5.38.0
8
  app_file: app.py
9
  pinned: false
10
  ---
11
 
12
+ # Agentic Assistant
13
+
14
+ A Gradio-based chat interface powered by LangChain and HuggingFace models.
15
+
16
+ ## Setup
17
+
18
+ ### 1. Install Dependencies
19
+ ```bash
20
+ pip install -r requirements.txt
21
+ ```
22
+
23
+ ### 2. Environment Variables
24
+
25
+ Create a `.env` file in the project root with the following variables:
26
+
27
+ ```bash
28
+ # Required: HuggingFace API Token
29
+ # Get your free token from: https://huggingface.co/settings/tokens
30
+ HUGGINGFACEHUB_API_TOKEN=your_huggingface_token_here
31
+
32
+ # Optional: SerpAPI Key (for web search functionality)
33
+ # Get your key from: https://serpapi.com/
34
+ SERPAPI_API_KEY=your_serpapi_key_here
35
+ ```
36
+
37
+ ### 3. Run the Application
38
+ ```bash
39
+ python app.py
40
+ ```
41
+
42
+ ## Features
43
+
44
+ - 🤖 Powered by Google's Flan-T5 model
45
+ - 🔍 Optional web search capability (requires SerpAPI key)
46
+ - 💬 Interactive chat interface with Gradio
47
+ - 🛠️ Built with LangChain for agent capabilities
48
+
49
+ ## Troubleshooting
50
+
51
+ - **Missing API Token**: Make sure you've set the `HUGGINGFACEHUB_API_TOKEN` environment variable
52
+ - **Import Errors**: The code now uses `langchain_community` imports to avoid deprecation warnings
53
+ - **Web Search**: If you don't have a SerpAPI key, the agent will run without web search functionality
54
+
55
+ ---
56
+
57
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
__pycache__/agent.cpython-311.pyc ADDED
Binary file (1.36 kB). View file
 
agent.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain.agents import initialize_agent, Tool
2
+ from langchain.llms import HuggingFaceHub
3
+ from langchain.utilities import SerpAPIWrapper
4
+ import os
5
+
6
+ # Load LLM from Hugging Face Hub
7
+ llm = HuggingFaceHub(
8
+ repo_id="google/flan-t5-large",
9
+ model_kwargs={"temperature": 0.7, "max_length": 512},
10
+ )
11
+
12
+ # Optional: Use web search tool
13
+ search = SerpAPIWrapper() # Requires SERPAPI_API_KEY env var
14
+
15
+ tools = [
16
+ Tool(
17
+ name="Search",
18
+ func=search.run,
19
+ description="Search engine for real-time information.",
20
+ )
21
+ ]
22
+
23
+ agent = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True)
24
+
25
+ def run_agent(prompt: str) -> str:
26
+ try:
27
+ return agent.run(prompt)
28
+ except Exception as e:
29
+ return f"[Agent Error] {str(e)}"
app.py CHANGED
@@ -1,29 +1,11 @@
1
- import streamlit as st
2
- import pandas as pd
3
-
4
- st.write("""
5
- # Personal GPT
6
- """)
7
 
8
- with st.sidebar:
9
- ping = st.text_input("API Key")
 
10
 
 
11
 
12
- tab1, tab2 = st.tabs(["New File", "History"])
13
- # tab1.write("this is tab 1")
14
-
15
- with tab1:
16
- file = st.file_uploader("Upload a CSV to visualise")
17
- # st.button("Click me")
18
- if file:
19
- df = pd.read_csv(file)
20
- st.line_chart(df)
21
-
22
- # st.text_input(ping)
23
- # st.number_input("Pick a number", 0, 10)
24
- # st.text_area("Text to translate")
25
- # st.date_input("Your birthday")
26
- # st.time_input("Meeting time")
27
- # st.file_uploader("Upload a CSV")
28
- # st.camera_input("Take a picture")
29
- # st.color_picker("Pick a color")
 
1
+ import gradio as gr
2
+ from agent import run_agent
 
 
 
 
3
 
4
+ def respond(message, history):
5
+ reply = run_agent(message)
6
+ return reply
7
 
8
+ chat = gr.ChatInterface(respond, title="🧠 Agentic Assistant")
9
 
10
+ if __name__ == "__main__":
11
+ chat.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -1 +1,6 @@
1
- pandas
 
 
 
 
 
 
1
+ gradio
2
+ langchain>=0.1.0
3
+ langchain-community>=0.0.20
4
+ transformers>=4.30.0
5
+ huggingface-hub>=0.16.0
6
+ python-dotenv>=1.0.0