From 1a2eca92373a366c10831962be21ba4b3a0f77ae Mon Sep 17 00:00:00 2001 From: Konrad Date: Tue, 12 Nov 2024 18:20:49 +0100 Subject: [PATCH 1/6] Added fancy name thing --- core/static/index.css | 14 +++++++++++++- core/static/index.html | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/core/static/index.css b/core/static/index.css index 94ab354..7f9e7f5 100644 --- a/core/static/index.css +++ b/core/static/index.css @@ -339,4 +339,16 @@ a{ .processElement>img{ width: 20px; margin-left: 6px; - } \ No newline at end of file + } + + +#jarvis { color: #d9d9d9; } + span { + color: #050505; + transition: color 1s, font-size 1s; + font-size: 0px; +} +#jarvis:hover span { + color: #d9d9d9; + font-size: 1em; +} \ No newline at end of file diff --git a/core/static/index.html b/core/static/index.html index 5f650cc..b2e43a0 100644 --- a/core/static/index.html +++ b/core/static/index.html @@ -24,7 +24,7 @@

Settings

-

Jarvis

+

Just a rather very intelligent system

From 0d66ef2b24cf07c23e7e54b18277b51ef4dc07ab Mon Sep 17 00:00:00 2001 From: EldarAlvik Date: Tue, 12 Nov 2024 18:21:24 +0100 Subject: [PATCH 2/6] Feat: added to env example --- .env.example | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index d95d9e6..047e2d7 100644 --- a/.env.example +++ b/.env.example @@ -3,4 +3,8 @@ LANGSMITH_API_KEY=your_langsmith_api_key #Find it here: https://smith.langchain. #FLASK_ENV=development #Optional if you want docker to reload flask when you save your code. #LANGSMITH_API_KEY=your_api_key #optional. Let's you debug using langsmith #LANGCHAIN_PROJECT=your_project_name #pops up in langsmith dashboard -#TAVILY_API_KEY=your_api_key #Needed for the AI to search the web. The tool will be disabled if there's no api key \ No newline at end of file +#TAVILY_API_KEY=your_api_key #Needed for the AI to search the web. The tool will be disabled if there's no api key +#NARAKEET_API_KEY=your_api_key #Needed for the AI to generate videos. The tool will be disabled if there's no api key +#PERPLEXITY_API_KEY=your_api_key #Needed for the AI to generate videos. The tool will be disabled if there's no api key +#GOOGLE_AUTH_KEY=your_google_auth_key #Needed for the AI to access your google calendar. The tool will be disabled if there's no api key +#GOOGLE_CALENDAR_ID=your_google_calendar_id #Needed for the AI to access your google calendar. The tool will be disabled if there's no api key \ No newline at end of file From f91dac1f70505a9a4fb353f738f64766e7485e6c Mon Sep 17 00:00:00 2001 From: EldarAlvik Date: Tue, 12 Nov 2024 18:22:30 +0100 Subject: [PATCH 3/6] Feat: added gpt 4o to jarvis and added temperature to response generator --- core/Agents/simpleagent.py | 17 ++++++++++++++++- core/graphAgent.py | 4 +++- core/main.py | 6 +++--- core/noder.py | 8 ++++---- docker-compose.yml | 1 + 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/core/Agents/simpleagent.py b/core/Agents/simpleagent.py index 60b2167..3c501b7 100644 --- a/core/Agents/simpleagent.py +++ b/core/Agents/simpleagent.py @@ -11,6 +11,21 @@ class SimpleAgent: temperature=0, max_tokens=1024, ) - + +class SlighltlySmarterAgent: + llm = ChatOpenAI( + model = Model.gpt_4oo, + temperature=0, + max_tokens=1024, + ) +class JapperAgent: + llm = ChatOpenAI( + model = Model.gpt_4o, + temperature=0.7, + max_tokens=1024, + ) class ToolsAgent: agent = SimpleAgent.llm.bind_tools(get_tools()) + +class ToolsAgent2: + agent = SlighltlySmarterAgent.llm.bind_tools(get_tools()) \ No newline at end of file diff --git a/core/graphAgent.py b/core/graphAgent.py index 1accf4c..5e46606 100644 --- a/core/graphAgent.py +++ b/core/graphAgent.py @@ -19,10 +19,11 @@ class Graph: def __init__(self): + LANGCHAIN_TRACING_V2: str = "true" print(""" ------------------------------ Instantiated Graph Agent.... ------------------------------- +------------------------------ """) self.workflow = StateGraph(GraphState) @@ -44,6 +45,7 @@ def __init__(self): self.workflow.add_edge("calendar_tool", "calendar_decider") self.workflow.add_edge("other_agent", "tools") self.workflow.add_edge("tools", "jarvis_agent") + self.workflow.add_edge("jarvis_agent", "generate") self.workflow.add_edge("generate", END) # Defining conditional edges diff --git a/core/main.py b/core/main.py index e9ba35f..f2a6f2a 100644 --- a/core/main.py +++ b/core/main.py @@ -33,10 +33,10 @@ # Agent instantiation # Graph() contains all complex tools # NeoAgent() is a simple ReAct agent that only has websearch and the add tool. For testing purposes. -#jarvis = Graph() # API key is configured in agent.py -jarvis = NeoAgent() +jarvis = Graph() # API key is configured in agent.py +#jarvis = NeoAgent() -# Initialize active_chats with the correct format +# Initialize active_chatss with the correct format active_chats = defaultdict(lambda: {"chat_history": []}) # diff --git a/core/noder.py b/core/noder.py index bbaf790..e99f861 100644 --- a/core/noder.py +++ b/core/noder.py @@ -1,5 +1,5 @@ from graphstate import GraphState -from Agents.simpleagent import SimpleAgent, ToolsAgent +from Agents.simpleagent import SimpleAgent, ToolsAgent, ToolsAgent2, JapperAgent from langchain_core.prompts import PromptTemplate from langchain_core.output_parsers import StrOutputParser from typing import Literal @@ -34,11 +34,11 @@ def jarvis_agent(state: GraphState): if you answer with an ampty string you will not do anything and stop working. """, ) - chain = prompt | ToolsAgent.agent | StrOutputParser() + chain = prompt | ToolsAgent2.agent | StrOutputParser() response = chain.invoke({ "messages": state["messages"], "data": state.get("data", {})}) response.replace("'", "") - response.replace('"', '') + response.replace('"', '') return {"tool_decision": response} def tool_agent_decider(state: GraphState): @@ -107,7 +107,7 @@ def response_generator(state: GraphState): Formulate a response that answer the users question and is formatted correctly """, ) - chain = prompt | SimpleAgent.llm + chain = prompt | JapperAgent.llm response = chain.invoke({"messages": state["messages"], "data": state.get("data", {})}) return {"messages": [response]} diff --git a/docker-compose.yml b/docker-compose.yml index ebc0cfb..f705a3f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,7 @@ services: GOOGLE_CALENDAR_ID: ${GOOGLE_CALENDAR_ID} PORT: ${PORT} TAVILY_API_KEY: ${TAVILY_API_KEY} + Port_STT: ${PORT_STT} volumes: - ./core:/app # Mount the application code to detect live changes networks: From aa10fdd4469d5189bdf27898ce83da52e286d032 Mon Sep 17 00:00:00 2001 From: EldarAlvik Date: Tue, 12 Nov 2024 19:04:48 +0100 Subject: [PATCH 4/6] Prompt engingeerd: fixed looping hopefully --- core/noder.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/noder.py b/core/noder.py index e99f861..285f9e4 100644 --- a/core/noder.py +++ b/core/noder.py @@ -16,6 +16,8 @@ def jarvis_agent(state: GraphState): som times you have to use multiple tools from multiple diffrent tools that has been called to complte the users requests. if you calender is sent to you for a second or third time you should generate instead of using tools. if you get a complex task you should call a tool to help you solve the task. + If you have called for weather data you should generate instead of calling for weather data again. + If you have already done calculations you should generate instead of doing calculations again. Here are previous messages: Message: {messages} From 9a12fb6dfc920a2379101c1d1387bde00bea0c12 Mon Sep 17 00:00:00 2001 From: EldarAlvik Date: Tue, 12 Nov 2024 21:43:20 +0100 Subject: [PATCH 5/6] Refactor: # out hard edge --- core/graphAgent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/graphAgent.py b/core/graphAgent.py index 5e46606..26e0692 100644 --- a/core/graphAgent.py +++ b/core/graphAgent.py @@ -45,7 +45,7 @@ def __init__(self): self.workflow.add_edge("calendar_tool", "calendar_decider") self.workflow.add_edge("other_agent", "tools") self.workflow.add_edge("tools", "jarvis_agent") - self.workflow.add_edge("jarvis_agent", "generate") + #self.workflow.add_edge("jarvis_agent", "generate") self.workflow.add_edge("generate", END) # Defining conditional edges From bfb0bdd152aefba483d7011a86730c7f853ab85a Mon Sep 17 00:00:00 2001 From: EldarAlvik Date: Tue, 12 Nov 2024 21:53:53 +0100 Subject: [PATCH 6/6] Prompt enigeerd: added to use weather tool when asked for weather tool --- core/noder.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/noder.py b/core/noder.py index 285f9e4..77da49e 100644 --- a/core/noder.py +++ b/core/noder.py @@ -121,6 +121,8 @@ def perplexity_agent(state: GraphState): Your job is to create tool_calls to tools using the perplexity API or to tools that do a RAG-search on the chat history. The tool or tools you decide to call should help answer the users question. + if you get asked about weather you should us the weather tool. + Here are previous messages: