bstraehle commited on
Commit
478d345
1 Parent(s): 9ec3206

Update rag.py

Browse files
Files changed (1) hide show
  1. rag.py +4 -3
rag.py CHANGED
@@ -1,5 +1,6 @@
1
  import openai, os
2
 
 
3
  from langchain.chains import LLMChain, RetrievalQA
4
  from langchain.chat_models import ChatOpenAI
5
  from langchain.document_loaders import PyPDFLoader, WebBaseLoader
@@ -105,9 +106,6 @@ def llm_chain(config, openai_api_key, prompt):
105
  def rag_chain(config, openai_api_key, rag_option, prompt):
106
  llm = get_llm(config, openai_api_key)
107
 
108
- with get_openai_callback() as cb:
109
- print(cb)
110
-
111
  if (rag_option == RAG_CHROMA):
112
  db = document_retrieval_chroma()
113
  elif (rag_option == RAG_MONGODB):
@@ -120,5 +118,8 @@ def rag_chain(config, openai_api_key, rag_option, prompt):
120
 
121
  completion = rag_chain({"query": prompt})
122
  print("###" + str(completion))
 
 
 
123
 
124
  return completion, rag_chain
 
1
  import openai, os
2
 
3
+ from langchain.callbacks import get_openai_callback
4
  from langchain.chains import LLMChain, RetrievalQA
5
  from langchain.chat_models import ChatOpenAI
6
  from langchain.document_loaders import PyPDFLoader, WebBaseLoader
 
106
  def rag_chain(config, openai_api_key, rag_option, prompt):
107
  llm = get_llm(config, openai_api_key)
108
 
 
 
 
109
  if (rag_option == RAG_CHROMA):
110
  db = document_retrieval_chroma()
111
  elif (rag_option == RAG_MONGODB):
 
118
 
119
  completion = rag_chain({"query": prompt})
120
  print("###" + str(completion))
121
+
122
+ with get_openai_callback() as cb:
123
+ print(cb)
124
 
125
  return completion, rag_chain