mlara commited on
Commit
6775e53
1 Parent(s): 2a15010
aimakerspace/__pycache__/__init__.cpython-39.pyc DELETED
Binary file (237 Bytes)
 
aimakerspace/__pycache__/text_utils.cpython-39.pyc DELETED
Binary file (2.95 kB)
 
aimakerspace/__pycache__/vectordatabase.cpython-39.pyc DELETED
Binary file (3.64 kB)
 
aimakerspace/openai_utils/__pycache__/__init__.cpython-39.pyc DELETED
Binary file (250 Bytes)
 
aimakerspace/openai_utils/__pycache__/chatmodel.cpython-39.pyc DELETED
Binary file (1.19 kB)
 
aimakerspace/openai_utils/__pycache__/embedding.cpython-39.pyc DELETED
Binary file (2.55 kB)
 
aimakerspace/openai_utils/__pycache__/prompts.cpython-39.pyc DELETED
Binary file (3.73 kB)
 
aimakerspace/openai_utils/chatmodel.py CHANGED
@@ -1,9 +1,6 @@
1
  from openai import OpenAI
2
- from dotenv import load_dotenv
3
  import os
4
 
5
- load_dotenv()
6
-
7
 
8
  class ChatOpenAI:
9
  def __init__(self, model_name: str = "gpt-3.5-turbo"):
@@ -12,11 +9,11 @@ class ChatOpenAI:
12
  if self.openai_api_key is None:
13
  raise ValueError("OPENAI_API_KEY is not set")
14
 
15
- def run(self, messages, text_only: bool = True):
16
  if not isinstance(messages, list):
17
  raise ValueError("messages must be a list")
18
 
19
- client = OpenAI()
20
  response = client.chat.completions.create(
21
  model=self.model_name, messages=messages
22
  )
 
1
  from openai import OpenAI
 
2
  import os
3
 
 
 
4
 
5
  class ChatOpenAI:
6
  def __init__(self, model_name: str = "gpt-3.5-turbo"):
 
9
  if self.openai_api_key is None:
10
  raise ValueError("OPENAI_API_KEY is not set")
11
 
12
+ def run(self, client, messages, text_only: bool = True):
13
  if not isinstance(messages, list):
14
  raise ValueError("messages must be a list")
15
 
16
+ # client = OpenAI()
17
  response = client.chat.completions.create(
18
  model=self.model_name, messages=messages
19
  )
rag.py CHANGED
@@ -41,7 +41,7 @@ class RetrievalAugmentedQAPipeline:
41
  self.llm = llm
42
  self.vector_db_retriever = vector_db_retriever
43
 
44
- def run_pipeline(self, user_query: str) -> str:
45
  context_list = self.vector_db_retriever.search_by_text(user_query, k=4)
46
 
47
  context_prompt = ""
@@ -52,7 +52,7 @@ class RetrievalAugmentedQAPipeline:
52
 
53
  formatted_user_prompt = user_prompt.create_message(user_query=user_query)
54
 
55
- return self.llm.run([formatted_system_prompt, formatted_user_prompt])
56
 
57
  def _split_documents():
58
  split_documents = []
@@ -72,9 +72,9 @@ def _build_vector_db():
72
  vector_db = asyncio.run(vector_db.abuild_from_list(split_documents))
73
  return vector_db
74
 
75
- def retrieval_augmented_qa_pipeline(client):
76
- vector_db = _build_vector_db()
77
- pipeline = RetrievalAugmentedQAPipeline(
78
- llm=client,
79
- vector_db_retriever=vector_db)
80
- return pipeline
 
41
  self.llm = llm
42
  self.vector_db_retriever = vector_db_retriever
43
 
44
+ def run_pipeline(self, client, user_query: str) -> str:
45
  context_list = self.vector_db_retriever.search_by_text(user_query, k=4)
46
 
47
  context_prompt = ""
 
52
 
53
  formatted_user_prompt = user_prompt.create_message(user_query=user_query)
54
 
55
+ return self.llm.run(client, [formatted_system_prompt, formatted_user_prompt])
56
 
57
  def _split_documents():
58
  split_documents = []
 
72
  vector_db = asyncio.run(vector_db.abuild_from_list(split_documents))
73
  return vector_db
74
 
75
+ # def retrieval_augmented_qa_pipeline(client):
76
+ # vector_db = _build_vector_db()
77
+ # pipeline = RetrievalAugmentedQAPipeline(
78
+ # llm=client,
79
+ # vector_db_retriever=vector_db)
80
+ # return pipeline
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ chainlit==0.7.700
2
+ cohere==4.37
3
+ openai==1.3.5
4
+ tiktoken==0.5.1
5
+ python-dotenv==1.0.0
6
+ numpy==1.25.2
7
+ openai
8
+ pandas
9
+ scikit-learn