From eb7c9b55d3c6a905385e43e47c4bf3da61dec372 Mon Sep 17 00:00:00 2001 From: Ashpreet Bedi Date: Mon, 12 Feb 2024 21:04:45 +0000 Subject: [PATCH] Formatting --- CONTRIBUTING.md | 27 +++++++++++++-------------- cookbook/knowledge/text.py | 18 ++++++++---------- phi/llm/anyscale/anyscale.py | 2 +- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e6350d2af..e884a3744 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,20 +29,19 @@ Please run this script before submitting a pull request. ## Adding a new Vector Database -1. Setup your local environment by following the Development setup. - -2. Create a new directory under phi/vectordb for the new vector database. - -3. Create a Class for your VectorDb that implements the VectorDb interface: - -4. Your Class will be in the phi/vectordb//.py file. -5. The VectorDb interface is defined in phi/vectordb/base. -6. Import your VectorDb Class in phi/vectordb//__init__.py. -7. Check out the phi/vectordb/pgvector/pgvector2 file for an example. -8. Add a recipe for using your VectorDb under cookbook/: - -9. Check out phidata/cookbook/pgvector for an example (you do not need to add the resources.py file). -Important: Format and validate your code by running ./scripts/format.sh. +1. Setup your local environment by following the [Development setup](#development-setup). +2. Create a new directory under `phi/llm` for the new LLM provider. +3. If the LLM provider supports the OpenAI API spec: + - Create a Class for your LLM provider that inherits the `OpenAILike` Class from `phi/llm/openai/like.py`. + - Your Class will be in the `phi/llm//.py` file. + - Import your Class in the `phi/llm//__init__.py` file. + - Checkout the [`phi/llm/together/together.py`](https://github.com/phidatahq/phidata/blob/main/phi/llm/together/together.py) file for an example. +4. If the LLM provider does not support the OpenAI API spec: + - Reach out to us on [Discord](https://discord.gg/4MtYHHrgA8) or open an issue to discuss the best way to integrate your LLM provider. +5. Add a recipe for using your LLM provider under `cookbook/`. + - Checkout [`phidata/cookbook/together`](https://github.com/phidatahq/phidata/tree/main/cookbook/together) for an example. +6. Important: Format and validate your code by running `./scripts/format.sh`. +7. Submit a pull request. Submit a pull request diff --git a/cookbook/knowledge/text.py b/cookbook/knowledge/text.py index 0cfc996d0..765d449cb 100644 --- a/cookbook/knowledge/text.py +++ b/cookbook/knowledge/text.py @@ -1,9 +1,10 @@ +from pathlib import Path + +from phi.assistant import Assistant from phi.knowledge.text import TextKnowledgeBase from phi.vectordb.pgvector import PgVector2 -from phi.assistant import Assistant -from resources import vector_db -from knowledge_base import knowledge_base -from pathlib import Path + +from resources import vector_db # type: ignore # Initialize the TextKnowledgeBase @@ -13,10 +14,10 @@ collection="text_documents", db_url=vector_db.get_db_connection_local(), ), - formats=[".txt"], # Formats accepted by this knowledge base num_documents=5, # Number of documents to return on search - optimize_on=10, # Number of documents to optimize the vector db on ) +# Load the knowledge base +knowledge_base.load(recreate=False) # Initialize the Assistant with the knowledge_base assistant = Assistant( @@ -24,8 +25,5 @@ add_references_to_prompt=True, ) -# Load the knowledge base -assistant.knowledge_base.load(recreate=False) - # Use the assistant -assistant.print_response("Ask me about something from the knowledge base",markdown=True) +assistant.print_response("Ask me about something from the knowledge base", markdown=True) diff --git a/phi/llm/anyscale/anyscale.py b/phi/llm/anyscale/anyscale.py index 04762629d..515c4c227 100644 --- a/phi/llm/anyscale/anyscale.py +++ b/phi/llm/anyscale/anyscale.py @@ -2,7 +2,7 @@ from typing import Optional from phi.llm.openai.like import OpenAILike - + class Anyscale(OpenAILike): name: str = "Anyscale"