Abraham E. Tavarez
commited on
Commit
Β·
10e34ce
1
Parent(s):
37ae348
done
Browse files- llama_agent.py +4 -6
llama_agent.py
CHANGED
|
@@ -3,11 +3,9 @@ from llama_index.llms.anthropic import Anthropic
|
|
| 3 |
from llama_index.core.tools import FunctionTool
|
| 4 |
from llama_index.core.agent import ReActAgent
|
| 5 |
|
| 6 |
-
|
| 7 |
-
# π Import from your existing Gradio app
|
| 8 |
from tools import compare_faces, compare_voices, scan_video
|
| 9 |
|
| 10 |
-
#
|
| 11 |
face_tool = FunctionTool.from_defaults(
|
| 12 |
fn=compare_faces,
|
| 13 |
name="Compare_Faces",
|
|
@@ -26,10 +24,10 @@ video_tool = FunctionTool.from_defaults(
|
|
| 26 |
description="Analyze a video using a reference image and optionally a YouTube link to detect face swaps."
|
| 27 |
)
|
| 28 |
|
| 29 |
-
#
|
| 30 |
llm = Anthropic(model="claude-3-opus-20240229")
|
| 31 |
|
| 32 |
-
#
|
| 33 |
agent = ReActAgent.from_tools(
|
| 34 |
tools=[face_tool, voice_tool, video_tool],
|
| 35 |
llm=llm,
|
|
@@ -37,7 +35,7 @@ agent = ReActAgent.from_tools(
|
|
| 37 |
)
|
| 38 |
|
| 39 |
|
| 40 |
-
#
|
| 41 |
def chat_with_agent(user_input, img1=None, img2=None, audio1=None, audio2=None, video=None, ref_img=None):
|
| 42 |
context = "You are an AI assistant. Use the following tools ONLY:\n\n"
|
| 43 |
context += "- 'Compare Faces' to compare two face images (requires img1_path, img2_path).\n"
|
|
|
|
| 3 |
from llama_index.core.tools import FunctionTool
|
| 4 |
from llama_index.core.agent import ReActAgent
|
| 5 |
|
|
|
|
|
|
|
| 6 |
from tools import compare_faces, compare_voices, scan_video
|
| 7 |
|
| 8 |
+
# Wrap functions as tools
|
| 9 |
face_tool = FunctionTool.from_defaults(
|
| 10 |
fn=compare_faces,
|
| 11 |
name="Compare_Faces",
|
|
|
|
| 24 |
description="Analyze a video using a reference image and optionally a YouTube link to detect face swaps."
|
| 25 |
)
|
| 26 |
|
| 27 |
+
# Anthropic LLM
|
| 28 |
llm = Anthropic(model="claude-3-opus-20240229")
|
| 29 |
|
| 30 |
+
# Create agent
|
| 31 |
agent = ReActAgent.from_tools(
|
| 32 |
tools=[face_tool, voice_tool, video_tool],
|
| 33 |
llm=llm,
|
|
|
|
| 35 |
)
|
| 36 |
|
| 37 |
|
| 38 |
+
# Chat function
|
| 39 |
def chat_with_agent(user_input, img1=None, img2=None, audio1=None, audio2=None, video=None, ref_img=None):
|
| 40 |
context = "You are an AI assistant. Use the following tools ONLY:\n\n"
|
| 41 |
context += "- 'Compare Faces' to compare two face images (requires img1_path, img2_path).\n"
|