Spaces:
Sleeping
Sleeping
Rajan Sharma
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,6 +10,9 @@ import gradio as gr
|
|
| 10 |
import pandas as pd
|
| 11 |
from datetime import datetime
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
# --- BACKEND IMPORTS ---
|
| 14 |
from langchain_cohere import ChatCohere
|
| 15 |
|
|
@@ -34,11 +37,11 @@ def load_markdown_text(filepath: str) -> str:
|
|
| 34 |
|
| 35 |
def _sanitize_text(s: str) -> str:
|
| 36 |
if not isinstance(s, str): return s
|
|
|
|
| 37 |
return re2.sub(r'[\p{C}--[\n\t]]+', '', s)
|
| 38 |
|
| 39 |
def _create_python_script(user_scenario: str, schema_context: str) -> str:
|
| 40 |
"""Uses an LLM to act as an "AI Coder", writing a complete Python script."""
|
| 41 |
-
# --- THE FINAL PROMPT FIX IS HERE ---
|
| 42 |
prompt_for_coder = f"""
|
| 43 |
You are an expert Python data scientist. Your sole job is to write a single, complete, and executable Python script to answer the user's request.
|
| 44 |
You have access to a list of pandas dataframes loaded into a variable named `dfs`.
|
|
|
|
| 10 |
import pandas as pd
|
| 11 |
from datetime import datetime
|
| 12 |
|
| 13 |
+
# --- THE FINAL FIX IS HERE: Re-introducing the missing import ---
|
| 14 |
+
import regex as re2
|
| 15 |
+
|
| 16 |
# --- BACKEND IMPORTS ---
|
| 17 |
from langchain_cohere import ChatCohere
|
| 18 |
|
|
|
|
| 37 |
|
| 38 |
def _sanitize_text(s: str) -> str:
|
| 39 |
if not isinstance(s, str): return s
|
| 40 |
+
# This now works because 're2' is defined from the import above
|
| 41 |
return re2.sub(r'[\p{C}--[\n\t]]+', '', s)
|
| 42 |
|
| 43 |
def _create_python_script(user_scenario: str, schema_context: str) -> str:
|
| 44 |
"""Uses an LLM to act as an "AI Coder", writing a complete Python script."""
|
|
|
|
| 45 |
prompt_for_coder = f"""
|
| 46 |
You are an expert Python data scientist. Your sole job is to write a single, complete, and executable Python script to answer the user's request.
|
| 47 |
You have access to a list of pandas dataframes loaded into a variable named `dfs`.
|