Skip to content

Commit

Permalink
Update version and fix example in astrologer function
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveParr committed Feb 29, 2024
1 parent d3c0bdd commit 8ef7322
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "starpilot"
version = "0.1.0"
version = "0.1.2"
description = "Discover the hidden power of your GitHub Stars"
authors = ["Dave Parr <8363743+DaveParr@users.noreply.github.com>"]
readme = "README.md"
Expand Down
39 changes: 27 additions & 12 deletions starpilot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from langchain.chains.query_constructor.ir import Comparator
from langchain.chains.query_constructor.schema import AttributeInfo
from langchain.retrievers.self_query.base import SelfQueryRetriever
from langchain.retrievers.self_query.chroma import ChromaTranslator
from langchain_community.embeddings import GPT4AllEmbeddings
from langchain_community.vectorstores import Chroma
from langchain_openai import ChatOpenAI
Expand Down Expand Up @@ -203,7 +204,7 @@ def astrologer(
),
AttributeInfo(
name="topics",
description="the topics a repository is tagged with. Example: ['data-science', 'machine-learning', 'python', 'web-development', 'tidyverse']",
description="the topics a repository is tagged with. Example: ['data-science', 'machine-learning', 'web-development', 'tidyverse']",
type="string",
),
AttributeInfo(
Expand All @@ -227,23 +228,37 @@ def astrologer(
prompt = get_query_constructor_prompt(
document_content_description,
metadata_field_info,
allowed_comparators=[
Comparator.EQ,
Comparator.NE,
Comparator.GT,
Comparator.GTE,
Comparator.LT,
Comparator.LTE,
examples=[
(
"Python machine learning repos",
{
"query": "machine learning",
"filter": 'eq("languages", "python")',
},
),
(
"Rust Dataframe crates",
{"query": "data frame", "filter": 'eq("languages", "rust")'},
),
(
"What R packages do time series analysis",
{"query": "time series", "filter": 'eq("languages", "R")'},
),
],
# allowed_comparators=[
# Comparator.EQ,
# Comparator.NE,
# Comparator.GT,
# Comparator.GTE,
# Comparator.LT,
# Comparator.LTE,
# ],
)

output_parser = StructuredQueryOutputParser.from_components()

query_constructor = prompt | llm | output_parser

ic(query_constructor.invoke({"query": query}))

from langchain.retrievers.self_query.chroma import ChromaTranslator

vectorstore = Chroma(
persist_directory=VECTORSTORE_PATH,
embedding_function=GPT4AllEmbeddings(client=None),
Expand Down

0 comments on commit 8ef7322

Please sign in to comment.