Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -4,24 +4,22 @@
|
|
| 4 |
import gradio as gr
|
| 5 |
from datetime import datetime
|
| 6 |
from typing import Dict, List
|
|
|
|
|
|
|
| 7 |
|
| 8 |
from mem0 import MemoryClient
|
| 9 |
from langchain_core.prompts import ChatPromptTemplate
|
| 10 |
from langchain.agents import create_tool_calling_agent, AgentExecutor
|
| 11 |
from langchain.chat_models import ChatOpenAI
|
| 12 |
-
import json
|
| 13 |
|
| 14 |
# Load config from local JSON file
|
| 15 |
with open("/content/drive/MyDrive/Generative AI/Project 3/config.json") as f:
|
| 16 |
config = json.load(f)
|
| 17 |
|
| 18 |
-
# Optional: If agentic_rag is in a separate file, import it
|
| 19 |
-
# from agentic_rag_workflow import agentic_rag
|
| 20 |
-
|
| 21 |
# ------------------------ Define NutritionBot ------------------------
|
| 22 |
class NutritionBot:
|
| 23 |
def __init__(self):
|
| 24 |
-
self.memory = MemoryClient(api_key=
|
| 25 |
|
| 26 |
self.client = ChatOpenAI(
|
| 27 |
model_name="gpt-4o-mini",
|
|
@@ -32,8 +30,7 @@ class NutritionBot:
|
|
| 32 |
|
| 33 |
tools = [agentic_rag] # Make sure agentic_rag is defined or imported
|
| 34 |
|
| 35 |
-
system_prompt = """You are a caring and knowledgeable Medical Support Agent, specializing in nutrition disorder-related guidance. Your goal is to provide accurate, empathetic, and tailored nutritional recommendations while ensuring a seamless customer experience.
|
| 36 |
-
"""
|
| 37 |
|
| 38 |
prompt = ChatPromptTemplate.from_messages([
|
| 39 |
("system", system_prompt),
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
from datetime import datetime
|
| 6 |
from typing import Dict, List
|
| 7 |
+
import os
|
| 8 |
+
import json
|
| 9 |
|
| 10 |
from mem0 import MemoryClient
|
| 11 |
from langchain_core.prompts import ChatPromptTemplate
|
| 12 |
from langchain.agents import create_tool_calling_agent, AgentExecutor
|
| 13 |
from langchain.chat_models import ChatOpenAI
|
|
|
|
| 14 |
|
| 15 |
# Load config from local JSON file
|
| 16 |
with open("/content/drive/MyDrive/Generative AI/Project 3/config.json") as f:
|
| 17 |
config = json.load(f)
|
| 18 |
|
|
|
|
|
|
|
|
|
|
| 19 |
# ------------------------ Define NutritionBot ------------------------
|
| 20 |
class NutritionBot:
|
| 21 |
def __init__(self):
|
| 22 |
+
self.memory = MemoryClient(api_key=os.getenv("MEM0_API_KEY", "m0-qYbYxa325DtWw8cJoEZyWivE9HMPY74hfX5UHdVl"))
|
| 23 |
|
| 24 |
self.client = ChatOpenAI(
|
| 25 |
model_name="gpt-4o-mini",
|
|
|
|
| 30 |
|
| 31 |
tools = [agentic_rag] # Make sure agentic_rag is defined or imported
|
| 32 |
|
| 33 |
+
system_prompt = """You are a caring and knowledgeable Medical Support Agent, specializing in nutrition disorder-related guidance. Your goal is to provide accurate, empathetic, and tailored nutritional recommendations while ensuring a seamless customer experience."""
|
|
|
|
| 34 |
|
| 35 |
prompt = ChatPromptTemplate.from_messages([
|
| 36 |
("system", system_prompt),
|