David Hrachovy commited on
Commit
005a4c0
·
1 Parent(s): 190ecd4
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -11,7 +11,7 @@ from dotenv import load_dotenv
11
  # SmolaGents imports
12
  from smolagents import CodeAgent, LiteLLMModel, tool
13
  from smolagents.agent_types import AgentText
14
-
15
  # Local imports
16
  from init_db import Project
17
 
@@ -102,11 +102,11 @@ def chat_with_sql(message, history):
102
  try:
103
  input_message = "You are a helpful assistant that presents information about real estate projects in database for investors. Use 'IS NOT NULL' when necessary. Translate any city names from input into Czech language. Present useful fields such as url. Do not make up information or hallucinate. If final result rows are empty respond that you could not find records matching criteria. Use only Czech city names. Note that there is limit 10 records for database result. Reformat final answer in markdown. User Input:\n\n {message}"
104
  prompt = input_message.format(message=message)
105
- result = codeagent.run(prompt)
106
  yield gr.ChatMessage(role="assistant", content=result)
107
 
108
  except Exception as e:
109
- yield f"Error: {str(e)}"
110
 
111
  # Create the Gradio interface
112
  count_projects = Project.select().where(Project.structure.is_null(False)).count()
 
11
  # SmolaGents imports
12
  from smolagents import CodeAgent, LiteLLMModel, tool
13
  from smolagents.agent_types import AgentText
14
+ from smolagents.memory import ActionStep, TaskStep
15
  # Local imports
16
  from init_db import Project
17
 
 
102
  try:
103
  input_message = "You are a helpful assistant that presents information about real estate projects in database for investors. Use 'IS NOT NULL' when necessary. Translate any city names from input into Czech language. Present useful fields such as url. Do not make up information or hallucinate. If final result rows are empty respond that you could not find records matching criteria. Use only Czech city names. Note that there is limit 10 records for database result. Reformat final answer in markdown. User Input:\n\n {message}"
104
  prompt = input_message.format(message=message)
105
+ result = codeagent.run(prompt, reset=False)
106
  yield gr.ChatMessage(role="assistant", content=result)
107
 
108
  except Exception as e:
109
+ yield gr.ChatMessage(role="assistant", content=f"Error: {str(e)}")
110
 
111
  # Create the Gradio interface
112
  count_projects = Project.select().where(Project.structure.is_null(False)).count()