datacipen commited on
Commit
ff2536f
1 Parent(s): d133722

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -7
main.py CHANGED
@@ -5,7 +5,7 @@ import pandas as pd
5
  import numpy as np
6
  from typing import List
7
  from pathlib import Path
8
- from langchain_openai import ChatOpenAI, OpenAI
9
  from langchain.schema.runnable.config import RunnableConfig
10
  from langchain.schema import StrOutputParser
11
  from langchain_core.prompts import ChatPromptTemplate
@@ -49,13 +49,13 @@ def create_agent(filename: str):
49
 
50
  # Create an OpenAI object.
51
  os.environ['OPENAI_API_KEY'] = os.environ['OPENAI_API_KEY']
52
- llm = OpenAI(temperature=0, model="gpt-4o-2024-05-13")
53
 
54
  # Read the CSV file into a Pandas DataFrame.
55
  df = pd.read_csv(filename)
56
 
57
  # Create a Pandas DataFrame agent.
58
- return create_pandas_dataframe_agent(llm, df, verbose=False, allow_dangerous_code=True, handle_parsing_errors=True)
59
 
60
  def query_agent(agent, query):
61
  """
@@ -155,12 +155,12 @@ async def set_starters():
155
  async def on_message(message: cl.Message):
156
  await cl.Message(f"> SURVEYIA").send()
157
  agent = create_agent("./public/ExpeCFA_LP_CAA_7-5-2024.csv")
158
-
159
  # Query the agent.
160
- response = query_agent(agent=agent, query=message.content)
161
  # Decode the response.
162
- decoded_response = decode_response(response)
163
 
164
  # Write the response to the Streamlit app.
165
- result = write_response(decoded_response)
166
  await cl.Message(author="COPILOT",content=GoogleTranslator(source='auto', target='fr').translate(result)).send()
 
5
  import numpy as np
6
  from typing import List
7
  from pathlib import Path
8
+ from langchain_openai import ChatOpenAI
9
  from langchain.schema.runnable.config import RunnableConfig
10
  from langchain.schema import StrOutputParser
11
  from langchain_core.prompts import ChatPromptTemplate
 
49
 
50
  # Create an OpenAI object.
51
  os.environ['OPENAI_API_KEY'] = os.environ['OPENAI_API_KEY']
52
+ llm = ChatOpenAI(temperature=0, model="gpt-4o-2024-05-13")
53
 
54
  # Read the CSV file into a Pandas DataFrame.
55
  df = pd.read_csv(filename)
56
 
57
  # Create a Pandas DataFrame agent.
58
+ return create_pandas_dataframe_agent(llm, df, verbose=False, allow_dangerous_code=True, handle_parsing_errors=True, agent_type=AgentType.OPENAI_FUNCTIONS)
59
 
60
  def query_agent(agent, query):
61
  """
 
155
  async def on_message(message: cl.Message):
156
  await cl.Message(f"> SURVEYIA").send()
157
  agent = create_agent("./public/ExpeCFA_LP_CAA_7-5-2024.csv")
158
+ result = agent.invoke(message.content)
159
  # Query the agent.
160
+ #response = query_agent(agent=agent, query=message.content)
161
  # Decode the response.
162
+ #decoded_response = decode_response(response)
163
 
164
  # Write the response to the Streamlit app.
165
+ #result = write_response(decoded_response)
166
  await cl.Message(author="COPILOT",content=GoogleTranslator(source='auto', target='fr').translate(result)).send()