Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anthropic MVP #126

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ __pycache__
*.pyc
*.pyo
*.log
.git
.git
venv/
config/
15 changes: 12 additions & 3 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@ ENV PYTHONBUFFERED 1
# Set the working directory in the container
WORKDIR /app

# Install requirements
RUN pip install --no-cache-dir lida
# Install git using apt cache
RUN apt-get update && apt-get install -y git && apt-get clean

# Copy the current directory contents into the container at /app
COPY . /app

# Install dependencies using pip cache
RUN pip install -r requirements.txt

# Install lida from the source in editable mode using pip cache
RUN pip install -e .

# Expose the port that the application will listen on
EXPOSE 8080

# Start the Web UI
CMD ["lida", "ui", "--host", "0.0.0.0", "--port", "8080", "--docs"]
Entrypoint lida ui --host 0.0.0.0 --port 8080 --docs
6 changes: 3 additions & 3 deletions lida/components/scaffold.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_template(self, goal: Goal, library: str):

if library == "matplotlib":
instructions = {
"role": "assistant",
"role": "system",
"content": f" {matplotlib_instructions}. Use BaseMap for charts that require a map. "}
template = \
f"""
Expand All @@ -40,7 +40,7 @@ def plot(data: pd.DataFrame):
chart = plot(data) # data already contains the data to be plotted. Always include this line. No additional code beyond this line."""
elif library == "seaborn":
instructions = {
"role": "assistant",
"role": "system",
"content": f"{matplotlib_instructions}. Use BaseMap for charts that require a map. "}

template = \
Expand All @@ -61,7 +61,7 @@ def plot(data: pd.DataFrame):

elif library == "ggplot":
instructions = {
"role": "assistant",
"role": "system",
"content": f"{general_instructions}. The plot method must return a ggplot object (chart)`. Think step by step.p. \n",
}

Expand Down
2 changes: 1 addition & 1 deletion lida/components/viz/vizeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def generate(
"role": "system", "content": system_prompt}, {
"role": "system", "content": f"The dataset summary is : \n\n {summary} \n\n"}, {
"role": "system", "content": f"The modifications you make MUST BE CORRECT and based on the '{library}' library and also follow these instructions \n\n{library_instructions} \n\n. The resulting code MUST use the following template \n\n {library_template} \n\n "}, {
"role": "user", "content": f"ALL ADDITIONAL LIBRARIES USED MUST BE IMPORTED.\n The code to be modified is: \n\n{code} \n\n. YOU MUST THINK STEP BY STEP, AND CAREFULLY MODIFY ONLY the content of the plot(..) method TO MEET EACH OF THE FOLLOWING INSTRUCTIONS: \n\n {instruction_string} \n\n. The completed modified code THAT FOLLOWS THE TEMPLATE above is. \n"}]
"role": "user", "content": f"ALL ADDITIONAL LIBRARIES USED MUST BE IMPORTED.\n The code to be modified is: \n\n{code} \n\n. YOU MUST THINK STEP BY STEP, AND CAREFULLY MODIFY ONLY the content of the plot(..) method TO MEET EACH OF THE FOLLOWING INSTRUCTIONS: \n\n {instruction_string} \n\n. The completed modified code THAT FOLLOWS THE TEMPLATE above is. \n"}]

completions: TextGenerationResponse = text_gen.generate(
messages=messages, config=textgen_config)
Expand Down
2 changes: 1 addition & 1 deletion lida/web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ async def generate_goal(req: GoalWebRequest) -> dict:
@api.post("/summarize")
async def upload_file(file: UploadFile):
""" Upload a file and return a summary of the data """

# allow csv, excel, json
allowed_types = ["text/csv", "application/vnd.ms-excel", "application/json"]

Expand Down Expand Up @@ -271,7 +272,6 @@ async def upload_file_via_url(req: SummaryUrlRequest) -> dict:
url_response = requests.get(url, allow_redirects=True, timeout=1000)
open(file_location, "wb").write(url_response.content)
try:

summary = lida.summarize(
data=file_location,
file_name=file_name,
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ classifiers = [
]

dependencies = [
"llmx>=0.0.21a",
"llmx@git+https://github.com/MichaelMcCulloch/llmx.git#egg=main",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Revert this to upstream llmx when and if the above is merged into it

"pydantic",
"uvicorn",
"typer",
"fastapi",
"python-multipart",
"scipy",
"scipy",
"numpy",
"pandas",
"matplotlib",
"altair",
"matplotlib",
"seaborn",
"plotly",
"plotnine",
Expand Down