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

fastembedder-fix #1745

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 2 deletions cookbook/assistants/llms/groq/video_summary/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def main() -> None:
if num_chunks > 1:
chunk_summaries = []
for i in range(num_chunks):
with st.status(f"Summarizing chunk: {i+1}", expanded=False) as status:
with st.status(f"Summarizing chunk: {i + 1}", expanded=False) as status:
chunk_summary = ""
chunk_container = st.empty()
chunk_summarizer = get_chunk_summarizer(model=llm_model)
Expand All @@ -99,7 +99,7 @@ def main() -> None:
chunk_summary += delta # type: ignore
chunk_container.markdown(chunk_summary)
chunk_summaries.append(chunk_summary)
status.update(label=f"Chunk {i+1} summarized", state="complete", expanded=False)
status.update(label=f"Chunk {i + 1} summarized", state="complete", expanded=False)

with st.spinner("Generating Summary"):
summary = ""
Expand Down
4 changes: 2 additions & 2 deletions cookbook/assistants/llms/ollama/video_summary/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def main() -> None:
if num_chunks > 1:
chunk_summaries = []
for i in range(num_chunks):
with st.status(f"Summarizing chunk: {i+1}", expanded=False) as status:
with st.status(f"Summarizing chunk: {i + 1}", expanded=False) as status:
chunk_summary = ""
chunk_container = st.empty()
chunk_summarizer = get_chunk_summarizer(model=llm_model)
Expand All @@ -100,7 +100,7 @@ def main() -> None:
chunk_summary += delta # type: ignore
chunk_container.markdown(chunk_summary)
chunk_summaries.append(chunk_summary)
status.update(label=f"Chunk {i+1} summarized", state="complete", expanded=False)
status.update(label=f"Chunk {i + 1} summarized", state="complete", expanded=False)

with st.spinner("Generating Summary"):
summary = ""
Expand Down
4 changes: 1 addition & 3 deletions cookbook/assistants/tools/hackernews.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@
# debug_mode=True,
)
hn_assistant.print_response(
"Write an engaging summary of the "
"users with the top 2 stories on hackernews. "
"Please mention the stories as well.",
"Write an engaging summary of the users with the top 2 stories on hackernews. Please mention the stories as well.",
)
3 changes: 1 addition & 2 deletions cookbook/teams/02_news_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
role="Searches the top URLs for a topic",
instructions=[
"Given a topic, first generate a list of 3 search terms related to that topic.",
"For each search term, search the web and analyze the results."
"Return the 10 most relevant URLs to the topic.",
"For each search term, search the web and analyze the results.Return the 10 most relevant URLs to the topic.",
"You are writing for the New York Times, so the quality of the sources is important.",
],
tools=[DuckDuckGo()],
Expand Down
4 changes: 1 addition & 3 deletions cookbook/tools/hackernews.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@
markdown=True,
)
agent.print_response(
"Write an engaging summary of the "
"users with the top 2 stories on hackernews. "
"Please mention the stories as well.",
"Write an engaging summary of the users with the top 2 stories on hackernews. Please mention the stories as well.",
)
2 changes: 1 addition & 1 deletion cookbook/workflows/content_creator_workflow/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"and business leaders while maintaining technical accuracy.\n\n"
),
"expected_output": (
"A LinkedIn post plan containing:\n" "- content\n" "- a main blog URL that is associated with the post\n\n"
"A LinkedIn post plan containing:\n- content\n- a main blog URL that is associated with the post\n\n"
),
},
}
3 changes: 1 addition & 2 deletions phi/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,7 @@ def update_model(self) -> None:
except ModuleNotFoundError as e:
logger.exception(e)
logger.error(
"phidata uses `openai` as the default model provider. "
"Please provide a `model` or install `openai`."
"phidata uses `openai` as the default model provider. Please provide a `model` or install `openai`."
)
exit(1)
self.model = OpenAIChat() # We default to OpenAIChat as a base model
Expand Down
6 changes: 2 additions & 4 deletions phi/assistant/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,7 @@ def update_llm(self) -> None:
from phi.llm.openai import OpenAIChat
except ModuleNotFoundError as e:
logger.exception(e)
logger.error(
"phidata uses `openai` as the default LLM. " "Please provide an `llm` or install `openai`."
)
logger.error("phidata uses `openai` as the default LLM. Please provide an `llm` or install `openai`.")
exit(1)

self.llm = OpenAIChat()
Expand Down Expand Up @@ -662,7 +660,7 @@ def get_system_prompt(self) -> Optional[str]:
)
)
for i, instruction in enumerate(instructions):
system_prompt_lines.append(f"{i+1}. {instruction}")
system_prompt_lines.append(f"{i + 1}. {instruction}")
system_prompt_lines.append("</instructions>")

# The add the expected output to the system prompt
Expand Down
2 changes: 1 addition & 1 deletion phi/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def print_to_cli(self, show_all: bool = False):
else:
print_info("No active workspace found.")
print_info(
"Please create a workspace using `phi ws create` " "or setup existing workspace using `phi ws setup`"
"Please create a workspace using `phi ws create` or setup existing workspace using `phi ws setup`"
)

if show_all and len(self.ws_config_map) > 0:
Expand Down
2 changes: 1 addition & 1 deletion phi/document/chunking/agentic.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def chunk(self, document: Document) -> List[Document]:
Consider semantic completeness, paragraph boundaries, and topic transitions.
Return only the character position number of where to break the text:
{remaining_text[:self.max_chunk_size]}"""
{remaining_text[: self.max_chunk_size]}"""

try:
response = self.model.response([Message(role="user", content=prompt)])
Expand Down
6 changes: 5 additions & 1 deletion phi/embedder/fastembed.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ def get_embedding(self, text: str) -> List[float]:
return []

def get_embedding_and_usage(self, text: str) -> Tuple[List[float], Optional[Dict]]:
return super().get_embedding_and_usage(text)
embedding = self.get_embedding(text=text)
# Currently, FastEmbed does not provide usage information
usage = None

return embedding, usage
3 changes: 1 addition & 2 deletions phi/memory/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ def update_model(self) -> None:
except ModuleNotFoundError as e:
logger.exception(e)
logger.error(
"phidata uses `openai` as the default model provider. "
"Please provide a `model` or install `openai`."
"phidata uses `openai` as the default model provider. Please provide a `model` or install `openai`."
)
exit(1)
self.model = OpenAIChat()
Expand Down
3 changes: 1 addition & 2 deletions phi/memory/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ def update_model(self) -> None:
except ModuleNotFoundError as e:
logger.exception(e)
logger.error(
"phidata uses `openai` as the default model provider. "
"Please provide a `model` or install `openai`."
"phidata uses `openai` as the default model provider. Please provide a `model` or install `openai`."
)
exit(1)
self.model = OpenAIChat()
Expand Down
3 changes: 1 addition & 2 deletions phi/memory/summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def update_model(self) -> None:
except ModuleNotFoundError as e:
logger.exception(e)
logger.error(
"phidata uses `openai` as the default model provider. "
"Please provide a `model` or install `openai`."
"phidata uses `openai` as the default model provider. Please provide a `model` or install `openai`."
)
exit(1)
self.model = OpenAIChat()
Expand Down
2 changes: 1 addition & 1 deletion phi/tools/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def another_function():
invalid_kwargs = set(kwargs.keys()) - VALID_KWARGS
if invalid_kwargs:
raise ValueError(
f"Invalid tool configuration arguments: {invalid_kwargs}. " f"Valid arguments are: {sorted(VALID_KWARGS)}"
f"Invalid tool configuration arguments: {invalid_kwargs}. Valid arguments are: {sorted(VALID_KWARGS)}"
)

def decorator(func: F) -> Function:
Expand Down
6 changes: 3 additions & 3 deletions phi/tools/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(
get_pull_request_changes: bool = True,
create_issue: bool = True,
create_repository: bool = True,
get_repository_languages: bool = True
get_repository_languages: bool = True,
):
super().__init__(name="github")

Expand Down Expand Up @@ -136,7 +136,7 @@ def create_repository(
logger.debug(f"Creating repository: {name}")
try:
description = description if description is not None else ""

if organization:
logger.debug(f"Creating in organization: {organization}")
org = self.g.get_organization(organization)
Expand All @@ -153,7 +153,7 @@ def create_repository(
description=description,
auto_init=auto_init,
)

repo_info = {
"name": repo.full_name,
"url": repo.html_url,
Expand Down
2 changes: 1 addition & 1 deletion phi/tools/wikipedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def search_wikipedia(self, query: str) -> str:
import wikipedia # noqa: F401
except ImportError:
raise ImportError(
"The `wikipedia` package is not installed. " "Please install it via `pip install wikipedia`."
"The `wikipedia` package is not installed. Please install it via `pip install wikipedia`."
)

logger.info(f"Searching wikipedia for: {query}")
Expand Down
2 changes: 1 addition & 1 deletion phi/vectordb/chroma/chromadb.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from chromadb.api.types import QueryResult, GetResult

except ImportError:
raise ImportError("The `chromadb` package is not installed. " "Please install it via `pip install chromadb`.")
raise ImportError("The `chromadb` package is not installed. Please install it via `pip install chromadb`.")

from phi.document import Document
from phi.embedder import Embedder
Expand Down
2 changes: 1 addition & 1 deletion phi/vectordb/milvus/milvus.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
try:
from pymilvus import MilvusClient # type: ignore
except ImportError:
raise ImportError("The `pymilvus` package is not installed. " "Please install it via `pip install pymilvus`.")
raise ImportError("The `pymilvus` package is not installed. Please install it via `pip install pymilvus`.")

from phi.document import Document
from phi.embedder import Embedder
Expand Down
2 changes: 1 addition & 1 deletion phi/vectordb/qdrant/qdrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from qdrant_client.http import models
except ImportError:
raise ImportError(
"The `qdrant-client` package is not installed. " "Please install it via `pip install qdrant-client`."
"The `qdrant-client` package is not installed. Please install it via `pip install qdrant-client`."
)

from phi.document import Document
Expand Down
Loading