Spaces:
Sleeping
Sleeping
Commit
·
6b8cb8c
1
Parent(s):
a060213
temp changes
Browse files
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title: Agentic
|
3 |
emoji: 🐠
|
4 |
colorFrom: green
|
5 |
colorTo: red
|
|
|
1 |
---
|
2 |
+
title: Agentic Assistant
|
3 |
emoji: 🐠
|
4 |
colorFrom: green
|
5 |
colorTo: red
|
agent.py
CHANGED
@@ -1,17 +1,19 @@
|
|
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 |
-
huggingfacehub_api_token=os.environ["HUGGINGFACEHUB_API_TOKEN"],
|
10 |
-
model_kwargs={"temperature": 0.7, "max_length": 512},
|
11 |
-
)
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
# Optional: Use web search tool
|
14 |
-
search = SerpAPIWrapper()
|
|
|
|
|
15 |
|
16 |
tools = [
|
17 |
Tool(
|
@@ -27,4 +29,6 @@ def run_agent(prompt: str) -> str:
|
|
27 |
try:
|
28 |
return agent.run(prompt)
|
29 |
except Exception as e:
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
+
from langchain.agents import initialize_agent, Tool
|
3 |
+
from langchain_community.utilities import SerpAPIWrapper
|
4 |
+
from langchain_huggingface import HuggingFaceEndpoint
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
llm = HuggingFaceEndpoint(
|
8 |
+
repo_id="microsoft/DialoGPT-small",
|
9 |
+
huggingfacehub_api_token='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',
|
10 |
+
task="text-generation",
|
11 |
+
temperature=0.7
|
12 |
+
)
|
13 |
# Optional: Use web search tool
|
14 |
+
# search = SerpAPIWrapper(api_key=os.environ["SERPAPI_API_KEY"])
|
15 |
+
search = SerpAPIWrapper(serpapi_api_key="308082f0c98a96a1b8dac63242122d5df8a96b65678b17cee9e8462c857ec5c8")
|
16 |
+
# # Requires SERPAPI_API_KEY env var
|
17 |
|
18 |
tools = [
|
19 |
Tool(
|
|
|
29 |
try:
|
30 |
return agent.run(prompt)
|
31 |
except Exception as e:
|
32 |
+
import traceback
|
33 |
+
error_details = traceback.format_exc()
|
34 |
+
return f"[Agent Error] {str(e)}\n\nDetails: {error_details}"
|
app.py
CHANGED
@@ -5,7 +5,7 @@ def respond(message, history):
|
|
5 |
reply = run_agent(message)
|
6 |
return reply
|
7 |
|
8 |
-
chat = gr.ChatInterface(respond, title="
|
9 |
|
10 |
if __name__ == "__main__":
|
11 |
chat.launch()
|
|
|
5 |
reply = run_agent(message)
|
6 |
return reply
|
7 |
|
8 |
+
chat = gr.ChatInterface(respond, title="🤖 Agentic Helper")
|
9 |
|
10 |
if __name__ == "__main__":
|
11 |
chat.launch()
|
requirements.txt
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
gradio
|
2 |
langchain-core
|
3 |
langchain-community
|
4 |
-
|
5 |
transformers
|
6 |
serpapi
|
|
|
|
1 |
gradio
|
2 |
langchain-core
|
3 |
langchain-community
|
4 |
+
langchain_huggingface
|
5 |
transformers
|
6 |
serpapi
|
7 |
+
google-search-results
|