priyamarwaha commited on
Commit
834031f
·
verified ·
1 Parent(s): c145a6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -11,6 +11,7 @@ import zepto
11
  from llama_index.core.tools import FunctionTool
12
  from llama_index.agent.openai import OpenAIAgent
13
  from typing import List, Tuple
 
14
 
15
  load_dotenv()
16
  # Prompt user to enter their OpenAI API key
@@ -43,7 +44,7 @@ Identify the Best Prices: For each product, compare the prices across all websit
43
 
44
  Output Format: Present the results in the following structured format for each product:
45
 
46
- Product Name: The most accurate or common name for the product.
47
 
48
  Store: The name of the store.
49
 
@@ -51,7 +52,7 @@ Product URL: A clickable link to the product page.
51
 
52
  Price: The price of the product at that store.
53
 
54
- Ensure the store-wise product details are ordered by ascending price (cheapest first).
55
 
56
  Handle Ambiguities: If product names or details are unclear, use context to determine if they refer to the same product. If uncertain, list them separately.
57
 
@@ -62,8 +63,11 @@ Product Name: Wireless Noise-Cancelling Headphones
62
  - Store: ElectroShop, Product URL: [ElectroShop Link], Price: ₹130
63
 
64
  '''
 
 
65
  agent = OpenAIAgent.from_tools(
66
  tools=[zepto_tool],
 
67
  api_key=os.environ['OPENAI_API_KEY'],
68
  system_message=system_instructions,
69
  verbose=True,
@@ -109,7 +113,7 @@ if prompt := st.chat_input(f"Hi I'm here to help you find the best price for a p
109
  with st.chat_message("assistant"):
110
 
111
  try:
112
- full_prompt = f"{system_instructions}\n\nUser Query: {prompt}"
113
 
114
  response = agent.chat(full_prompt)
115
  processing_message.empty()
 
11
  from llama_index.core.tools import FunctionTool
12
  from llama_index.agent.openai import OpenAIAgent
13
  from typing import List, Tuple
14
+ from llama_index.llms.openai import OpenAI
15
 
16
  load_dotenv()
17
  # Prompt user to enter their OpenAI API key
 
44
 
45
  Output Format: Present the results in the following structured format for each product:
46
 
47
+ Product Name: The most accurate or common name for the product (this is not the search term but the actual product name returned via search)
48
 
49
  Store: The name of the store.
50
 
 
52
 
53
  Price: The price of the product at that store.
54
 
55
+ Ensure the store-wise product details are ordered by ascending price (cheapest first) and the products themselves are sorted by ascending order of price.
56
 
57
  Handle Ambiguities: If product names or details are unclear, use context to determine if they refer to the same product. If uncertain, list them separately.
58
 
 
63
  - Store: ElectroShop, Product URL: [ElectroShop Link], Price: ₹130
64
 
65
  '''
66
+
67
+ llm = OpenAI(model="gpt-4o-mini")
68
  agent = OpenAIAgent.from_tools(
69
  tools=[zepto_tool],
70
+ llm=llm,
71
  api_key=os.environ['OPENAI_API_KEY'],
72
  system_message=system_instructions,
73
  verbose=True,
 
113
  with st.chat_message("assistant"):
114
 
115
  try:
116
+ full_prompt = prompt #f"{system_instructions}\n\nUser Query: {prompt}"
117
 
118
  response = agent.chat(full_prompt)
119
  processing_message.empty()