Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Emerald33 committed Mar 26, 2024
1 parent 705286d commit 3bc3d1d
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 47 deletions.
39 changes: 30 additions & 9 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,41 @@
def welcome_page():
return render_template('home.html')

@app.route('/agents/file_api_key')
def api():
return render_template('file_apikey.html')

@app.route('/agents/langchain')
def langchain_main():
return render_template('langchain.html')

@app.route('/agents/llamaindex')
def llamaindex_main():
return render_template('llamaindex.html')

@app.route('/agents/crewai')
def crewai_main():
return render_template('crewai.html')


@app.route("/agents/file_api_key", methods = ['post'])
def upload_api_page():
data = request.form
files = uploaded_files(data['file_one'], data['file_two'])
openai_api_key = request.form.get('openai_api_key')
serper_api_key = request.form.get('serper_api_key')
browserless_api_key = request.form.get('browserless_api_key')

file_one = request.files.get('file_one')
file_two = request.files.get('file_two')

files = uploaded_files(file_one, file_two)
path_to_directory.extend(files)

keys = api_keys(data['openai_api_key'], data['serper_api_key'],
data['browserless_api_key'])

keys = api_keys(openai_api_key, serper_api_key, browserless_api_key)

for k, v in keys.items():
api_key_dict[k]=v

return render_template('file_apikey.html')
return render_template('api_thankyou.html')


@app.route("/agents/langchain", methods = ['post'])
Expand All @@ -38,7 +59,7 @@ def langchain_page():
path_to_directory[2])
response = model.generate_langchain(data['text_input'])

return render_template('crewai.html',
return render_template('langchain_result.html',
generated = response)


Expand All @@ -49,7 +70,7 @@ def llama_index_page():
path_to_directory[0],
api_key_dict["OPENAI_API_KEY"])

return render_template('llamaindex.html',
return render_template('llamaindex_result.html',
generated = model)


Expand All @@ -64,7 +85,7 @@ def crewai_page():

response = model.run()

return render_template('langchain.html',
return render_template('crewai_result.html',
generated = response)


Expand Down
6 changes: 3 additions & 3 deletions crewai_local/trip_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from langchain_community.chat_models import ChatOllama
from langchain_openai.chat_models import ChatOpenAI

from tools.browser_tools import BrowserTools
from tools.calculator_tools import CalculatorTools
from tools.search_tools import SearchTools
from crewai_local.tools.browser_tools import BrowserTools
from crewai_local.tools.calculator_tools import CalculatorTools
from crewai_local.tools.search_tools import SearchTools

from dotenv import load_dotenv
load_dotenv()
Expand Down
4 changes: 2 additions & 2 deletions crewai_local/trip_crew.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from textwrap import dedent
from langchain_openai.chat_models import ChatOpenAI
from langchain_community.chat_models import ChatOllama
from trip_agents import TripAgents
from trip_task import TripTasks
from crewai_local.trip_agents import TripAgents
from crewai_local.trip_task import TripTasks

from dotenv import load_dotenv
load_dotenv()
Expand Down
31 changes: 31 additions & 0 deletions templates/agents.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>CrewAI Agent</title>
{% include 'bootstrap.html' %}
</head>
<body>
{% include 'nav.html' %}
<div class="container">
<h2 class="text-center mt-2 mb-4">
CrewAI Trip Planner
</h2>
<p class="lead">Make sure to have inputed your OpenAI API Key</p>
<form action="/agents/langchain" method="post">
<div class="mb-3">
<label for="exampleFormControlTextarea1" class="form-label">Chat With Your Data</label>
<textarea class="form-control" name="text_input" id="exampleFormControlTextarea1" rows="3"></textarea>
</div>
<div>
<button type="submit" class="btn btn-primary mb-3">Chat</button>
</div>
</form>
<p class="lead">{{generated}}</p>
</div>
{% include 'footer.html' %}
</div>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>
28 changes: 28 additions & 0 deletions templates/api_thankyou.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Llama-Index Response</title>
{% include 'bootstrap.html' %}
</head>
<body>
{% include 'nav.html' %}
{% include 'img.html' %}
<div class="container">
<h2 class="text-center mt-2 mb-4">
Status
</h2>

<p class="lead">Thank You for entering you API key and or Uploading files</p>

<div class="col-3" style="padding-right: 16px; display: flex; justify-content: center; align-items: center;">
<a href="/" type="button" class="btn btn-outline-primary">Return to Home</a>
</div>

</div> S
{% include 'footer.html' %}
</div>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>
30 changes: 24 additions & 6 deletions templates/crewai.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,39 @@
</head>
<body>
{% include 'nav.html' %}
{% include 'img.html' %}
<div class="container">
<h2 class="text-center mt-2 mb-4">
CrewAI Trip Planner
Langchain Multi-tool Agent
</h2>
<p class="lead">Make sure to have inputed your OpenAI API Key</p>
<form action="/agents/langchain" method="post">
<p class="lead">Make sure to have inputed your OpenAI API Key. Also inpute Serper and Browserless API Keys</p>
<form action="/agents/crewai" method="post">
<div class="mb-3">
<label for="exampleFormControlTextarea1" class="form-label">Chat With Your Data</label>
<textarea class="form-control" name="text_input" id="exampleFormControlTextarea1" rows="3"></textarea>
<label for="exampleFormControlTextarea1" class="form-label">Enter you base location</label>
<textarea class="form-control" required name="location" id="exampleFormControlTextarea1" rows="1"></textarea>
</div>

<div class="mb-3">
<label for="exampleFormControlTextarea1" class="form-label">Enter the cities you want the agent to choose from</label>
<textarea class="form-control" required name="cities" id="exampleFormControlTextarea1" rows="2"></textarea>
</div>

<div class="mb-3">
<label for="exampleFormControlTextarea1" class="form-label">Enter your proposed date range for the trip</label>
<textarea class="form-control" required name="date_range" id="exampleFormControlTextarea1" rows="2"></textarea>
</div>

<div class="mb-3">
<label for="exampleFormControlTextarea1" class="form-label">Enter activities that interest you during trips</label>
<textarea class="form-control" required name="interests" id="exampleFormControlTextarea1" rows="2"></textarea>
</div>
<div>
<button type="submit" class="btn btn-primary mb-3">Chat</button>
<button type="submit" class="btn btn-primary mb-3">Generate</button>
</div>
</form>

<p class="lead">{{generated}}</p>

</div>
{% include 'footer.html' %}
</div>
Expand Down
28 changes: 28 additions & 0 deletions templates/crewai_result.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>CrewAI Response</title>
{% include 'bootstrap.html' %}
</head>
<body>
{% include 'nav.html' %}
{% include 'img.html' %}
<div class="container">
<h2 class="text-center mt-2 mb-4">
Response
</h2>

<p class="lead">{{generated}}</p>

<div class="col-3" style="padding-right: 16px; display: flex; justify-content: center; align-items: center;">
<a href="/agents/crewai" type="button" class="btn btn-outline-primary">Return to page</a>
</div>

</div> S
{% include 'footer.html' %}
</div>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion templates/file_apikey.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h3 class="text-center mt-2 mb-4">
</h3>
<p class="lead">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod</p>

<form action="/agents/file_api_key" method="post">
<form action="/agents/file_api_key" method="post" enctype="multipart/form-data">
<div class="col-6">
<label for="formFileLg" class="form-label">Upload One</label>
<input class="form-control form-control-lg" name="file_one" id="formFileLg" type="file">
Expand Down
30 changes: 6 additions & 24 deletions templates/langchain.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,21 @@
</head>
<body>
{% include 'nav.html' %}
{% include 'img.html' %}
<div class="container">
<h2 class="text-center mt-2 mb-4">
Langchain Multi-tool Agent
CrewAI Trip Planner
</h2>
<p class="lead">Make sure to have inputed your OpenAI API Key. Also inpute Serper and Browserless API Keys</p>
<form action="/agents/crewai" method="post">
<p class="lead">Make sure to have inputed your OpenAI API Key</p>
<form action="/agents/langchain" method="post">
<div class="mb-3">
<label for="exampleFormControlTextarea1" class="form-label">Enter you base location</label>
<textarea class="form-control" required name="location" id="exampleFormControlTextarea1" rows="1"></textarea>
</div>

<div class="mb-3">
<label for="exampleFormControlTextarea1" class="form-label">Enter the cities you want the agent to choose from</label>
<textarea class="form-control" required name="cities" id="exampleFormControlTextarea1" rows="2"></textarea>
</div>

<div class="mb-3">
<label for="exampleFormControlTextarea1" class="form-label">Enter your proposed date range for the trip</label>
<textarea class="form-control" required name="date_range" id="exampleFormControlTextarea1" rows="2"></textarea>
</div>

<div class="mb-3">
<label for="exampleFormControlTextarea1" class="form-label">Enter activities that interest you during trips</label>
<textarea class="form-control" required name="interests" id="exampleFormControlTextarea1" rows="2"></textarea>
<label for="exampleFormControlTextarea1" class="form-label">Chat With Your Data</label>
<textarea class="form-control" name="text_input" id="exampleFormControlTextarea1" rows="3"></textarea>
</div>
<div>
<button type="submit" class="btn btn-primary mb-3">Generate</button>
<button type="submit" class="btn btn-primary mb-3">Chat</button>
</div>
</form>

<p class="lead">{{generated}}</p>

</div>
{% include 'footer.html' %}
</div>
Expand Down
28 changes: 28 additions & 0 deletions templates/langchain_result.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Langchain Response</title>
{% include 'bootstrap.html' %}
</head>
<body>
{% include 'nav.html' %}
{% include 'img.html' %}
<div class="container">
<h2 class="text-center mt-2 mb-4">
Response
</h2>

<p class="lead">{{generated}}</p>

<div class="col-3" style="padding-right: 16px; display: flex; justify-content: center; align-items: center;">
<a href="/agents/langchain" type="button" class="btn btn-outline-primary">Return to page</a>
</div>

</div> S
{% include 'footer.html' %}
</div>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>
28 changes: 28 additions & 0 deletions templates/llamaindex_result.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Llama-Index Response</title>
{% include 'bootstrap.html' %}
</head>
<body>
{% include 'nav.html' %}
{% include 'img.html' %}
<div class="container">
<h2 class="text-center mt-2 mb-4">
Response
</h2>

<p class="lead">{{generated}}</p>

<div class="col-3" style="padding-right: 16px; display: flex; justify-content: center; align-items: center;">
<a href="/agents/llamaindex" type="button" class="btn btn-outline-primary">Return to page</a>
</div>

</div> S
{% include 'footer.html' %}
</div>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>
2 changes: 0 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import tempfile


def api_keys(openai_api_key: str = None, serper_api_key: str | None= None,
browserless_api_key: str | None = None ) -> dict:
api_keys = {
Expand All @@ -11,7 +10,6 @@ def api_keys(openai_api_key: str = None, serper_api_key: str | None= None,
}
return api_keys


def uploaded_files(upload_one=None, upload_two=None) -> list:
temp_dir = tempfile.mkdtemp()
result_list = [temp_dir]
Expand Down

0 comments on commit 3bc3d1d

Please sign in to comment.