From 995e8a1296ad5a6134dd124f82612715c41aadee Mon Sep 17 00:00:00 2001 From: Casper van Langen Date: Mon, 10 Jun 2024 19:41:34 +0200 Subject: [PATCH] feat: updated demo to remove sql tool and link to new repo --- backend/app/app/api/v1/api.py | 11 ++--- backend/app/app/config/agent.yml | 44 +++++++++---------- backend/app/app/config/tools.yml | 24 +++++----- backend/app/app/schemas/tool_schema.py | 1 + .../app/services/chat_agent/helpers/llm.py | 8 ++++ caddy/Caddyfile | 1 + docker-compose.yml | 44 +++++++++---------- docs/docusaurus/docs/introduction.md | 4 +- docs/docusaurus/sidebars.js | 5 +++ .../components/ConversationView/EmptyView.tsx | 16 ++++--- frontend/src/pages/auth/signin.tsx | 3 +- frontend/src/styles/globals.css | 4 ++ 12 files changed, 92 insertions(+), 73 deletions(-) diff --git a/backend/app/app/api/v1/api.py b/backend/app/app/api/v1/api.py index c6aef092..5612c557 100644 --- a/backend/app/app/api/v1/api.py +++ b/backend/app/app/api/v1/api.py @@ -4,11 +4,12 @@ from app.api.v1.endpoints import chat, sql, statistics api_router = APIRouter() -api_router.include_router( - sql.router, - prefix="/sql", - tags=["sql"], -) +# Uncomment SQL router to enable SQL tool +# api_router.include_router( +# sql.router, +# prefix="/sql", +# tags=["sql"], +# ) api_router.include_router( chat.router, prefix="/chat", diff --git a/backend/app/app/config/agent.yml b/backend/app/app/config/agent.yml index d79c35c3..4b93f3fd 100644 --- a/backend/app/app/config/agent.yml +++ b/backend/app/app/config/agent.yml @@ -1,10 +1,10 @@ --- tools_library: !include tools.yml common: # settings shared by agent and all tools (can be overwritten by passing explicitly to constructors) - llm: 'gpt-4' - fast_llm: 'gpt-3.5-turbo' - fast_llm_token_limit: 2500 - max_token_length: 4000 + llm: 'gpt-4o' + fast_llm: 'gpt-4o' + fast_llm_token_limit: 5000 + max_token_length: 6000 tools: - expert_tool - clarify_tool @@ -37,24 +37,24 @@ action_plans: actions: - - memory - clarify_tool - '2': - name: '' - description: |- - Use this plan to fetch Github-related information from the repository of AgentKit, such as commits, issues, pull requests. - Always use this action plan when asked about issues, pull requests, or commits - unless there is a specific request to make a visualization. - actions: - - - memory - - sql_tool - - - sql_expert_tool - '3': - name: '' - description: |- - Make a visualization regarding GitHub information of AgentKit, such as PRs, issues, or commits. - **ONLY use this action plan if there is a specific request to make a visualization** - actions: - - - memory - - sql_tool - - - visualizer_tool + # '2': + # name: '' + # description: |- + # Use this plan to fetch Github-related information from the repository of AgentKit, such as commits, issues, pull requests. + # Always use this action plan when asked about issues, pull requests, or commits - unless there is a specific request to make a visualization. + # actions: + # - - memory + # - sql_tool + # - - sql_expert_tool + # '3': + # name: '' + # description: |- + # Make a visualization regarding GitHub information of AgentKit, such as PRs, issues, or commits. + # **ONLY use this action plan if there is a specific request to make a visualization** + # actions: + # - - memory + # - sql_tool + # - - visualizer_tool '4': name: '' description: |- diff --git a/backend/app/app/config/tools.yml b/backend/app/app/config/tools.yml index 11031f8f..23942c31 100644 --- a/backend/app/app/config/tools.yml +++ b/backend/app/app/config/tools.yml @@ -30,8 +30,8 @@ library: content: |- The prompt for generating an image of the item is ... clarify_tool: - default_llm: "gpt-4" - default_fast_llm: "gpt-3.5-turbo-1106" + default_llm: "gpt-4o" + default_fast_llm: "gpt-3.5-turbo" description: >- Tool to engage the user for additional input when the initial question lacks enough detail to determine the appropriate action plan. Utilize this tool to solicit clarifications from the user, enabling a more informed action plan selection within the AgentKit codebase environment. @@ -189,8 +189,8 @@ library: max_rows_in_output: 30 expert_tool: - default_llm: "gpt-4" - default_fast_llm: "gpt-3.5-turbo-1106" + default_llm: "gpt-4o" + default_fast_llm: "gpt-3.5-turbo" description: >- Tool to answer the user question based on the documents retrieved by the pdf_tool. It analyzes the documents to provide reliable, helpful answers to specific technical queries related to the codebase, such as setup procedures or tool additions. {examples} @@ -230,7 +230,7 @@ library: max_token_length: 8000 sql_expert_tool: - default_llm: "gpt-4" + default_llm: "gpt-4o" default_fast_llm: "gpt-3.5-turbo" description: >- Tool to answer the user question based on the structured data retrieved by the sql_tool. This data has been retrieved @@ -433,8 +433,8 @@ library: prompt_message: "" code_expert_tool: - default_llm: "gpt-4" - default_fast_llm: "gpt-3.5-turbo-1106" + default_llm: "gpt-4o" + default_fast_llm: "gpt-3.5-turbo" description: >- Tool to answer the user question based on the python source code and codebase documentation. It analyzes the context to provide reliable, helpful answers to specific technical queries related to the codebase, such as setup procedures or tool additions. @@ -576,7 +576,7 @@ library: fast_llm_token_threshold: 7800 generate_config_tool: - default_llm: "gpt-4" + default_llm: "gpt-4o" default_fast_llm: "gpt-3.5-turbo" description: >- Generation of a new parameter configuration as input into a optimization problem. @@ -632,7 +632,7 @@ library: - Software_Engineer: Number of resources available for Software_Engineer speciality generate_optim_input_tool: - default_llm: "gpt-4" + default_llm: "gpt-4o" default_fast_llm: "gpt-3.5-turbo" description: >- Generation of a new configuration as input into a optimization problem. @@ -724,7 +724,7 @@ library: - resource_req is the number of resources required for the feature (standard 1) run_optimizer_tool: - default_llm: "gpt-4" + default_llm: "gpt-4o" default_fast_llm: "gpt-3.5-turbo" description: >- Execution of the product development backlog optimization algorithm. @@ -737,7 +737,7 @@ library: placeholder summarize_config_changes_tool: - default_llm: "gpt-4" + default_llm: "gpt-4o" default_fast_llm: "gpt-3.5-turbo" description: >- Summarizes the changes between two parameter configuration. @@ -825,7 +825,7 @@ library: - New feature 'Introduce_New_Tool' was added with the following parameters: 'Data_Scientist' and 'Software_Engineer' summarize_kpi_tool: - default_llm: "gpt-4" + default_llm: "gpt-4o" default_fast_llm: "gpt-3.5-turbo" description: >- Optimizer output summarization. diff --git a/backend/app/app/schemas/tool_schema.py b/backend/app/app/schemas/tool_schema.py index b5b03b69..60c3f991 100644 --- a/backend/app/app/schemas/tool_schema.py +++ b/backend/app/app/schemas/tool_schema.py @@ -7,6 +7,7 @@ LLMType = Literal[ "gpt-4", + "gpt-4o", "gpt-3.5-turbo", "azure-4-32k", "azure-3.5", diff --git a/backend/app/app/services/chat_agent/helpers/llm.py b/backend/app/app/services/chat_agent/helpers/llm.py index 7ed9f155..7f387323 100644 --- a/backend/app/app/services/chat_agent/helpers/llm.py +++ b/backend/app/app/services/chat_agent/helpers/llm.py @@ -66,6 +66,14 @@ def get_llm( openai_api_key=api_key if api_key is not None else settings.OPENAI_API_KEY, streaming=True, ) + case "gpt-4o": + return ChatOpenAI( + temperature=0, + model_name="gpt-4o", + openai_organization=settings.OPENAI_ORGANIZATION, + openai_api_key=api_key if api_key is not None else settings.OPENAI_API_KEY, + streaming=True, + ) # If an exact match is not confirmed, this last case will be used if provided case _: logger.warning(f"LLM {llm} not found, using default LLM") diff --git a/caddy/Caddyfile b/caddy/Caddyfile index 1288c6aa..23497498 100644 --- a/caddy/Caddyfile +++ b/caddy/Caddyfile @@ -17,6 +17,7 @@ reverse_proxy nextjs_server:3000 reverse_proxy /api/v1/* fastapi_server:9090 reverse_proxy /docs/* docusaurus:3001 + reverse_proxy /docs docusaurus:3001 } fastapi.{$EXT_ENDPOINT1}:80, fastapi.{$LOCAL_1}:80, fastapi.{$LOCAL_2}:80 { diff --git a/docker-compose.yml b/docker-compose.yml index 71e1cb91..5695e912 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: container_name: fastapi_server build: ./backend restart: always - command: "sh -c 'alembic upgrade head && python app/document_ingestion.py && uvicorn app.main:app --reload --workers 1 --host 0.0.0.0 --port 9090'" + command: "sh -c 'alembic upgrade head && python app/document_ingestion.py && uvicorn app.main:app --reload --workers 5 --host 0.0.0.0 --port 9090'" volumes: - ./backend/app:/code expose: @@ -48,27 +48,27 @@ services: - POSTGRES_DATABASE=${DATABASE_NAME} - POSTGRES_HOST_AUTH_METHOD= "trust" - db_sql_tool: # Remove if not using sql tool - image: postgres:11 - restart: always - container_name: db_sql_tool - volumes: - - ./db_docker:/var/lib/postgresql - - ./scripts/db_sql_tool/github_data_psql_load.sql:/docker-entrypoint-initdb.d/github_data_psql_load.sql - - ./backend/app/app/tool_constants/public_demo_data/pull_requests.csv:/docker-entrypoint-initdb.d/pull_requests.csv - - ./backend/app/app/tool_constants/public_demo_data/commit_history.csv:/docker-entrypoint-initdb.d/commit_history.csv - - ./backend/app/app/tool_constants/public_demo_data/issues.csv:/docker-entrypoint-initdb.d/issues.csv - environment: - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - - POSTGRES_DB=sqltool - ports: - - "5632:5432" - healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres"] - interval: 10s - timeout: 15s - retries: 5 + # db_sql_tool: # Remove if not using sql tool + # image: postgres:11 + # restart: always + # container_name: db_sql_tool + # volumes: + # - ./db_docker:/var/lib/postgresql + # - ./scripts/db_sql_tool/github_data_psql_load.sql:/docker-entrypoint-initdb.d/github_data_psql_load.sql + # - ./backend/app/app/tool_constants/public_demo_data/pull_requests.csv:/docker-entrypoint-initdb.d/pull_requests.csv + # - ./backend/app/app/tool_constants/public_demo_data/commit_history.csv:/docker-entrypoint-initdb.d/commit_history.csv + # - ./backend/app/app/tool_constants/public_demo_data/issues.csv:/docker-entrypoint-initdb.d/issues.csv + # environment: + # - POSTGRES_USER=postgres + # - POSTGRES_PASSWORD=postgres + # - POSTGRES_DB=sqltool + # ports: + # - "5632:5432" + # healthcheck: + # test: ["CMD-SHELL", "pg_isready -U postgres"] + # interval: 10s + # timeout: 15s + # retries: 5 redis_server: image: redis:alpine diff --git a/docs/docusaurus/docs/introduction.md b/docs/docusaurus/docs/introduction.md index 528b686f..21cb2a21 100644 --- a/docs/docusaurus/docs/introduction.md +++ b/docs/docusaurus/docs/introduction.md @@ -10,9 +10,7 @@ Key advantages of AgentKit include: - 💻 **Flexible, reactive UI/UX designed for Agents**: React/Nextjs chat-based UI that is easy to configure, with features such as streaming, rendering of tables/visualizations/code, status of Agent actions and more - 🛡️ **Focus on reliability**: Easy to configure routing architecture gives control of possible paths Agent can take, increasing reliability and making it suited for real-life use cases -As an example, try the AgentKit codebase helper [demo](https://agentkit.infra.x.bcg.com/) - - +As an example, try the AgentKit codebase helper [demo](https://agentkit.infra.x.bcg.com/) build following the [tutorial](docs/tutorial/tutorial.md) ## Chinook music database demo For a quick start to test some of the functionality, you can use the dummy Chinook example: diff --git a/docs/docusaurus/sidebars.js b/docs/docusaurus/sidebars.js index 12cb55a4..63f8c4bd 100644 --- a/docs/docusaurus/sidebars.js +++ b/docs/docusaurus/sidebars.js @@ -33,6 +33,11 @@ const sidebars = { label: 'Configuration', items: ['configuration/configure_agent_and_tools', 'configuration/configure_ui'], }, + { + type: 'category', + label: 'Tutorial', + items: ['tutorial/tutorial'], + }, { type: 'category', label: 'How it works', diff --git a/frontend/src/components/ConversationView/EmptyView.tsx b/frontend/src/components/ConversationView/EmptyView.tsx index 622b0ad2..508fba8f 100644 --- a/frontend/src/components/ConversationView/EmptyView.tsx +++ b/frontend/src/components/ConversationView/EmptyView.tsx @@ -8,7 +8,6 @@ import { CONVERSATION_VIEW_SELECTORS } from "./ConversationView.selectors" const rag_examples = [ 'Get started with AgentKit: "What is the quickest way to get started and run the code?"', 'Ask questions about the code: "How do I create a new tool?"', - 'Explore the Github repo: "Visualize the number of commits per month this year"', ] const opt_examples = [ @@ -41,9 +40,10 @@ const EmptyView = (props: Props) => {
-

{" "} - I'm an AgentKit codebase helper. I can answer questions about the documentation, codebase, Github - repository, and more.

+

+ {" "} + I'm an AgentKit codebase helper. I can answer questions about the documentation, codebase, and more. +

Here are some examples:

@@ -54,9 +54,11 @@ const EmptyView = (props: Props) => {
-

{" "} - I can also help you schedule your team's AgentKit project. Define your backlog, and I will create a - schedule for you.

+

+ {" "} + I can also help you schedule your team's AgentKit project. Define your backlog, and I will create a + schedule for you. +

Here is an example:

diff --git a/frontend/src/pages/auth/signin.tsx b/frontend/src/pages/auth/signin.tsx index 24e0060e..0379db1b 100644 --- a/frontend/src/pages/auth/signin.tsx +++ b/frontend/src/pages/auth/signin.tsx @@ -1,13 +1,12 @@ import Image from "next/image" import { getServerSession } from "next-auth/next" import { getCsrfToken, getProviders, signIn, useSession } from "next-auth/react" +import { useTheme } from "next-themes" import { useEffect, useState } from "react" import Icon from "~/components/CustomIcons/Icon" import { authOptions } from "~/server/auth" -import { Theme } from "~/styles/themes" -import { useTheme } from "next-themes" import { APPLICATION_TITLE, getMainLogoSrc } from "~/utils" import { AUTH_SELECTORS } from "~/utils/signin.selectors" import type { GetServerSidePropsContext, InferGetServerSidePropsType } from "next" diff --git a/frontend/src/styles/globals.css b/frontend/src/styles/globals.css index 57c15eae..5db0f80c 100644 --- a/frontend/src/styles/globals.css +++ b/frontend/src/styles/globals.css @@ -82,6 +82,10 @@ body, @apply text-neutral; } +[data-theme="dark"] code { + @apply !text-neutral; +} + @font-face { font-family: "BCG Sans"; src: url("/fonts/sans/BCGHenSansRegular.ttf") format("ttf");