Skip to content

Commit

Permalink
Add min width to ChatStep (#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 authored Aug 5, 2024
1 parent 0f0583e commit 12018eb
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 35 deletions.
3 changes: 1 addition & 2 deletions lumen/ai/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from ..transforms.sql import SQLOverride, SQLTransform, Transform
from ..views import VegaLiteView, View, hvPlotUIView
from .analysis import Analysis
from .config import FUZZY_TABLE_LENGTH
from .embeddings import Embeddings
from .llm import Llm
from .memory import memory
Expand All @@ -39,8 +40,6 @@
)
from .views import AnalysisOutput, LumenOutput, SQLOutput

FUZZY_TABLE_LENGTH = 10


class Agent(Viewer):
"""
Expand Down
17 changes: 1 addition & 16 deletions lumen/ai/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,14 @@
from .agents import (
Agent, AnalysisAgent, ChatAgent, SQLAgent,
)
from .config import DEMO_MESSAGES, GETTING_STARTED_SUGGESTIONS
from .export import export_notebook
from .llm import Llama, Llm
from .logs import ChatLogs
from .memory import memory
from .models import Validity
from .utils import get_schema, render_template, retry_llm_output

GETTING_STARTED_SUGGESTIONS = [
"What datasets do you have?",
"Tell me about the dataset.",
"Create a plot of the dataset.",
"Find the min and max of the values.",
]

DEMO_MESSAGES = [
"What data is available?",
"Can I see the first one?",
"Tell me about the dataset.",
"What could be interesting to analyze?",
"Perform a SQL query on one of these.",
"Show it to me as a scatter plot."
]


class Assistant(Viewer):
"""
Expand Down
40 changes: 40 additions & 0 deletions lumen/ai/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from pathlib import Path

import panel as pn


class LlmSetupError(Exception):
"""
Raised when an error occurs during the setup of the LLM.
"""


THIS_DIR = Path(__file__).parent

FUZZY_TABLE_LENGTH = 10

GETTING_STARTED_SUGGESTIONS = [
"What datasets do you have?",
"Tell me about the dataset.",
"Create a plot of the dataset.",
"Find the min and max of the values.",
]

DEMO_MESSAGES = [
"What data is available?",
"Can I see the first one?",
"Tell me about the dataset.",
"What could be interesting to analyze?",
"Perform a SQL query on one of these.",
"Show it to me as a scatter plot.",
]

DEFAULT_EMBEDDINGS_PATH = Path("embeddings")

UNRECOVERABLE_ERRORS = (
ImportError,
LlmSetupError,
RecursionError,
)

pn.chat.ChatStep.min_width = 350
4 changes: 2 additions & 2 deletions lumen/ai/embeddings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path

DEFAULT_PATH = Path("embeddings")
from .config import DEFAULT_EMBEDDINGS_PATH


class Embeddings:
Expand All @@ -14,7 +14,7 @@ def query(self, query_texts: str) -> list:

class ChromaDb(Embeddings):

def __init__(self, collection: str, persist_dir: str = DEFAULT_PATH):
def __init__(self, collection: str, persist_dir: str = DEFAULT_EMBEDDINGS_PATH):
import chromadb
self.client = chromadb.PersistentClient(path=str(persist_dir / collection))
self.collection = self.client.get_or_create_collection(collection)
Expand Down
16 changes: 1 addition & 15 deletions lumen/ai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,7 @@
from lumen.pipeline import Pipeline
from lumen.sources.base import Source

THIS_DIR = Path(__file__).parent


class LlmSetupError(Exception):
"""
Raised when an error occurs during the setup of the LLM.
"""



UNRECOVERABLE_ERRORS = (
ImportError,
LlmSetupError,
RecursionError,
)
from .config import THIS_DIR, UNRECOVERABLE_ERRORS


def render_template(template, **context):
Expand Down

0 comments on commit 12018eb

Please sign in to comment.