Spaces:
Sleeping
Sleeping
deeplake
Browse filesFiles changed (3)
- .gitignoreAdded+2
- ingest.pyAdded+30
- qa.pyAdded+43
12.envindex123456789101112131415161718192021222324252627282930import osimport getpass
from langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.vectorstores import DeepLakefrom langchain.text_splitter import CharacterTextSplitter
from langchain.document_loaders import TextLoaderfrom dotenv import load_dotenvload_dotenv()embeddings = OpenAIEmbeddings(disallowed_special=())index_name = 'finecast'
root_dirs = ['../../elsewhen/finecast/infra2','../../elsewhen/finecast-infrastructure']docs = []for root_dir in root_dirs: for dirpath, dirnames, filenames in os.walk(root_dir): for file in filenames: try: loader = TextLoader(os.path.join(dirpath, file), encoding='utf-8') docs.extend(loader.load_and_split()) except Exception as e: pass
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)texts = text_splitter.split_documents(docs)
db = DeepLake(dataset_path=f"./index/" + index_name, embedding_function=embeddings) #dataset would be publicly availabledb.add_documents(texts)12345678910111213141516171819202122232425262728293031323334353637383940414243import osfrom langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.vectorstores import DeepLakefrom dotenv import load_dotenvload_dotenv()from langchain.chat_models import ChatOpenAIfrom langchain.chains import ConversationalRetrievalChainembeddings = OpenAIEmbeddings(disallowed_special=())index_name = 'finecast'
db = DeepLake(dataset_path="./index/" + index_name, read_only=True, embedding_function=embeddings)
retriever = db.as_retriever()retriever.search_kwargs['distance_metric'] = 'cos'retriever.search_kwargs['fetch_k'] = 100retriever.search_kwargs['maximal_marginal_relevance'] = Trueretriever.search_kwargs['k'] = 10
model = ChatOpenAI(model='gpt-4') # switch to 'gpt-4'qa = ConversationalRetrievalChain.from_llm(model,retriever=retriever)
questions = [ # "the admin-webapp trigger is not showing up o github in the finecast-develop environment. what change do i need to make to the yaml file so it runs the trigger when someone raises a PR?" # 'in simple terms explain what will adding this - github: ${\_trigger_code_build_github_repo_connection} to the file infra2/environments/finecast-develop/cloudbuild/triggers.yaml do?' "in infra2, what is the default behaviour of secrets?", # "whats the difference between a random secret and a secret?", "in infra2, how many types of secrets are there?", "how many repositories are there about finecast?" # "can you generate a set of FAQ for infra2 that could be useful for a programmer to know?" #"how can i add a new random secret called 'abc' for the 'us' environment?" #"can you explain how the yaml files work in the environments folder?", #"what does the cloudbuild yaml file do?", #"what does the git-setup, clone-modules and the git-actions cloud build yaml files do?", #"explain me how i can create a module in finecast-infrastructure that i can use in infra2?"] chat_history = []
for question in questions: result = qa({"question": question, "chat_history": chat_history}) chat_history.append((question, result['answer'])) print(f"-> **Question**: {question} \n") print(f"**Answer**: {result['answer']} \n").gitignoreAdded+2
ingest.pyAdded+30
qa.pyAdded+43