Skip to content

Commit

Permalink
Merge pull request #78 from kartAI/agent-design
Browse files Browse the repository at this point in the history
Agent design
  • Loading branch information
andreaslhjulstad authored Nov 27, 2024
2 parents f5269bd + d4e66cc commit 05af91f
Show file tree
Hide file tree
Showing 30 changed files with 1,733 additions and 494 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# NTNU KPRO AI Assistant

The scope of the project consists of two primary objectives:

* **Develop a Web Application:** This platform will serve as a centralized hub, integrating the various AI models available through the KartAI project. By bringing these models together, the application will serve as a proof-of-concept (PoC), allowing KartAI to display their assortment of AI tools for different stages of the application process.

* **Create a Summary AI Assistant:** This AI-driven tool analyze documents from submitted applications and generate concise summaries, highlighting key points. The system implements a checklist matching feature. It cross-reference the building application with an official checklist and relevant regulations and inform about the quality of the application. This functionality is designed to support both applicants and case workers, enhancing the overall efficiency and clarity of the application process


## Prerequisites

Before you start, make sure the following tools are installed on your system:
Expand Down
11 changes: 9 additions & 2 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
AZURE_OPENAI_API_KEY = ""
AZURE_OPENAI_API_BASE = ""
AZURE_OPENAI_ENDPOINT = ""
AZURE_OPENAI_API_VERSION = ""
AZURE_OPENAI_DEPLOYMENT_NAME = ""
API_VERSION = ""
OPENAI_API_KEY = ""
TAVILY_API_KEY = ""
LANGCHAIN_API_KEY = ""
LANGCHAIN_TRACING_V2="true"

ARKIVGPT_URL = "http://localhost:80/api"
CADAID_URL = "http://localhost:5001/detect/"
57 changes: 57 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,59 @@ aiohttp==3.10.10
aiosignal==1.3.1
annotated-types==0.7.0
anyio==4.6.0
asgiref==3.8.1
attrs==24.2.0
backoff==2.2.1
bcrypt==4.2.1
beautifulsoup4==4.12.3
build==1.2.2.post1
cachetools==5.5.0
certifi==2024.8.30
charset-normalizer==3.4.0
chroma-hnswlib==0.7.6
chromadb==0.5.20
click==8.1.7
colorama==0.4.6
coloredlogs==15.0.1
dataclasses-json==0.6.7
Deprecated==1.2.15
distro==1.9.0
dnspython==2.6.1
durationpy==0.9
email_validator==2.2.0
exceptiongroup==1.2.2
fastapi==0.115.0
fastapi-cli==0.0.5
filelock==3.16.1
flatbuffers==24.3.25
frozenlist==1.4.1
fsspec==2024.10.0
google-auth==2.36.0
googleapis-common-protos==1.66.0
greenlet==3.1.1
grpcio==1.68.0
h11==0.14.0
httpcore==1.0.5
httptools==0.6.1
httpx==0.27.2
httpx-sse==0.4.0
huggingface-hub==0.26.2
humanfriendly==10.0
idna==3.10
importlib_metadata==8.5.0
importlib_resources==6.4.5
iniconfig==2.0.0
Jinja2==3.1.4
jiter==0.6.1
jsonpatch==1.33
jsonpointer==3.0.0
kubernetes==31.0.0
langchain==0.3.4
langchain-community==0.3.3
langchain-core==0.3.12
langchain-openai==0.2.3
langchain-text-splitters==0.3.0
langchainhub==0.1.21
langgraph==0.2.39
langgraph-checkpoint==2.0.1
langgraph-sdk==0.1.33
Expand All @@ -42,45 +65,79 @@ markdown-it-py==3.0.0
MarkupSafe==2.1.5
marshmallow==3.23.0
mdurl==0.1.2
mmh3==5.0.1
monotonic==1.6
mpmath==1.3.0
msgpack==1.1.0
multidict==6.1.0
mypy-extensions==1.0.0
numpy==1.26.4
oauthlib==3.2.2
onnxruntime==1.20.1
openai==1.52.0
opentelemetry-api==1.28.2
opentelemetry-exporter-otlp-proto-common==1.28.2
opentelemetry-exporter-otlp-proto-grpc==1.28.2
opentelemetry-instrumentation==0.49b2
opentelemetry-instrumentation-asgi==0.49b2
opentelemetry-instrumentation-fastapi==0.49b2
opentelemetry-proto==1.28.2
opentelemetry-sdk==1.28.2
opentelemetry-semantic-conventions==0.49b2
opentelemetry-util-http==0.49b2
orjson==3.10.9
overrides==7.7.0
packaging==24.1
pillow==11.0.0
pluggy==1.5.0
posthog==3.7.3
propcache==0.2.0
protobuf==5.28.3
pyasn1==0.6.1
pyasn1_modules==0.4.1
pydantic==2.9.2
pydantic-settings==2.6.0
pydantic_core==2.23.4
Pygments==2.18.0
PyMuPDF==1.24.12
PyPika==0.48.9
pyproject_hooks==1.2.0
pytesseract==0.3.13
pytest==8.3.3
pytest-asyncio==0.24.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-multipart==0.0.10
PyYAML==6.0.2
regex==2024.9.11
requests==2.32.3
requests-oauthlib==2.0.0
requests-toolbelt==1.0.0
rich==13.8.1
rsa==4.9
shellingham==1.5.4
six==1.16.0
sniffio==1.3.1
soupsieve==2.6
SQLAlchemy==2.0.36
starlette==0.38.6
sympy==1.13.3
tavily-python==0.5.0
tenacity==9.0.0
tiktoken==0.8.0
tokenizers==0.20.3
tomli==2.0.2
tqdm==4.66.5
typer==0.12.5
types-requests==2.32.0.20241016
typing-inspect==0.9.0
typing_extensions==4.12.2
urllib3==2.2.3
uvicorn==0.30.6
uvloop==0.20.0
watchfiles==0.24.0
websocket-client==1.8.0
websockets==13.1
wrapt==1.17.0
yarl==1.15.5
zipp==3.21.0
16 changes: 16 additions & 0 deletions backend/src/configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
from dotenv import load_dotenv

load_dotenv()

ARKIVGPT_URL = os.getenv("ARKIVGPT_URL", "http://localhost:80/api")
CADAID_URL = os.getenv("CADAID_URL", "http://localhost:5001/detect/")

AZURE_API_KEY = os.getenv("AZURE_OPENAI_API_KEY")
AZURE_API_VERSION = os.getenv("AZURE_OPENAI_API_VERSION")
AZURE_DEPLOYMENT_NAME = os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME")
AZURE_OPENAI_ENDPOINT = os.getenv("AZURE_OPENAI_ENDPOINT")
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
TAVILY_API_KEY = os.getenv("TAVILY_API_KEY")
LANGCHAIN_API_KEY = os.getenv("LANGCHAIN_API_KEY")
LANGCHAIN_TRACING = os.getenv("LANGCHAIN_TRACING", "false") == "true"
22 changes: 14 additions & 8 deletions backend/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from src.services.reader import Reader
from src.services.readers.factory import create_reader
from src.services.agent import invoke_agent, invoke_plan_agent
from src.services.external_ai_models import query_cad_aid


app = FastAPI(
Expand Down Expand Up @@ -63,7 +64,8 @@ def summarize(
if not content:
raise HTTPException(status_code=400, detail="File is empty")

response = invoke_agent(contents)
cadaid_detections = query_cad_aid(files) if include_modules else []
response = invoke_agent(contents, cadaid_detections)
return response

except ValueError as e:
Expand All @@ -80,21 +82,25 @@ def extract_text(file: UploadFile) -> str:
@app.post("/plan-prat", response_model=PlanPratResponse)
def plan_prat(question: PlanPratRequest) -> PlanPratResponse:
"""
PlanPrat a query.
PlanPrat a query.
Args:
question (PlanPratRequest): The query to PlanPrat.
Returns:
PlanPratResponse: The PlanPrat response.
backend/src/main.py
Args:
question (PlanPratRequest): The query to PlanPrat.
Returns:
PlanPratResponse: The PlanPrat response.
backend/src/main.py
"""

logger.info(f"Query: {question}")
if not question.query:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, detail="Query is empty"
)
print(f"Query: {question.query}", flush=True)

response = invoke_plan_agent(question.query)
return PlanPratResponse(answer=response)


@app.get("/health")
def health_check():
return {"status": "ok"}
Loading

0 comments on commit 05af91f

Please sign in to comment.