-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathmain.py
More file actions
59 lines (51 loc) · 1.93 KB
/
main.py
File metadata and controls
59 lines (51 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from dotenv import load_dotenv
import os
import pandas as pd
from llama_index.experimental.query_engine import PandasQueryEngine
from prompts import new_prompt, instruction_str, coffee_context, context
from note_engine import note_engine
from llama_index.core.tools import QueryEngineTool, ToolMetadata
from llama_index.core.agent import ReActAgent
from llama_index.llms.openai import OpenAI
from pdf import canada_engine
from coffee_scraper import coffee_scraper
load_dotenv()
population_path = os.path.join("data", "population.csv")
population_df = pd.read_csv(population_path)
population_query_engine = PandasQueryEngine(df=population_df, verbose=True, instruction_str=instruction_str)
population_query_engine.update_prompts({"pandas_prompt": new_prompt})
coffee_scraper.scrape_nearby_coffee()
coffee_query_engine = coffee_scraper.get_query_engine()
tools = [
note_engine,
QueryEngineTool(
query_engine=population_query_engine,
metadata=ToolMetadata(
name="population_data",
description="this gives information at the world population and demographics",
),
),
QueryEngineTool(
query_engine=canada_engine,
metadata=ToolMetadata(
name="canada_data",
description="this gives detailed information about canada the country",
),
),
QueryEngineTool(
query_engine=coffee_query_engine,
metadata=ToolMetadata(
name="ottawa_coffee",
description=(
"Coffee shops near National Gallery of Canada. "
"Includes price levels (1-3), ratings (1-5) and distances."
)
)
)
]
# llm = OpenAI(model="gpt-3.5-turbo")
llm = OpenAI(model="gpt-4o-mini-2024-07-18")
agent = ReActAgent.from_tools(tools, llm=llm, verbose=True, context=context + "\n" + coffee_context)
while (prompt := input("Enter a prompt (q to quit): ")) != "q":
result = agent.query(prompt)
print(result)