TahaRasouli commited on
Commit
2f36a1e
1 Parent(s): 1358bae

Delete assistant.py

Browse files
Files changed (1) hide show
  1. assistant.py +0 -66
assistant.py DELETED
@@ -1,66 +0,0 @@
1
- from typing import Optional
2
-
3
- from phi.assistant import Assistant
4
- from phi.knowledge import AssistantKnowledge
5
- from phi.llm.groq import Groq
6
- from phi.embedder.openai import OpenAIEmbedder
7
- from phi.embedder.ollama import OllamaEmbedder
8
- from phi.vectordb.pgvector import PgVector2
9
- from phi.storage.assistant.postgres import PgAssistantStorage
10
-
11
-
12
- db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
13
-
14
-
15
- def get_groq_assistant(
16
- llm_model: str = "llama3-70b-8192",
17
- embeddings_model: str = "text-embedding-3-small",
18
- user_id: Optional[str] = None,
19
- run_id: Optional[str] = None,
20
- debug_mode: bool = True,
21
- ) -> Assistant:
22
- """Get a Groq RAG Assistant."""
23
-
24
- # Define the embedder based on the embeddings model
25
- embedder = (
26
- OllamaEmbedder(model=embeddings_model, dimensions=768)
27
- if embeddings_model == "nomic-embed-text"
28
- else OpenAIEmbedder(model=embeddings_model, dimensions=1536)
29
- )
30
- # Define the embeddings table based on the embeddings model
31
- embeddings_table = (
32
- "groq_rag_documents_ollama" if embeddings_model == "nomic-embed-text" else "groq_rag_documents_openai"
33
- )
34
-
35
- return Assistant(
36
- name="groq_rag_assistant",
37
- run_id=run_id,
38
- user_id=user_id,
39
- llm=Groq(model=llm_model),
40
- storage=PgAssistantStorage(table_name="groq_rag_assistant", db_url=db_url),
41
- knowledge_base=AssistantKnowledge(
42
- vector_db=PgVector2(
43
- db_url=db_url,
44
- collection=embeddings_table,
45
- embedder=embedder,
46
- ),
47
- # 2 references are added to the prompt
48
- num_documents=2,
49
- ),
50
- description="You are an AI called 'GroqRAG' and your task is to answer questions using the provided information",
51
- instructions=[
52
- "When a user asks a question, you will be provided with information about the question.",
53
- "Carefully read this information and provide a clear and concise answer to the user.",
54
- "Do not use phrases like 'based on my knowledge' or 'depending on the information'.",
55
- ],
56
- # This setting adds references from the knowledge_base to the user prompt
57
- add_references_to_prompt=True,
58
- # This setting tells the LLM to format messages in markdown
59
- markdown=True,
60
- # This setting adds chat history to the messages
61
- add_chat_history_to_messages=True,
62
- # This setting adds 4 previous messages from chat history to the messages
63
- num_history_messages=4,
64
- add_datetime_to_instructions=True,
65
- debug_mode=debug_mode,
66
- )