Utkarsh-Tiwari commited on
Commit
323d23c
·
1 Parent(s): 4ce060b
Files changed (1) hide show
  1. fine-tune.py +0 -56
fine-tune.py DELETED
@@ -1,56 +0,0 @@
1
- import os
2
- from langchain.embeddings.openai import OpenAIEmbeddings
3
- from langchain.vectorstores import DeepLake
4
- from langchain.text_splitter import CharacterTextSplitter
5
- from langchain.document_loaders import SeleniumURLLoader
6
- from langchain import PromptTemplate
7
-
8
- def embedding():
9
- os.environ['OPENAI_API_KEY'] = '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'
10
- os.environ["ACTIVELOOP_TOKEN"] = "eyJhbGciOiJIUzUxMiIsImlhdCI6MTY5NTE5MTAyNiwiZXhwIjoxNzU4MzQ5NDA3fQ.eyJpZCI6InV0a2Fyc2h0aXdhcmkifQ.PK_iz7uybeSmgqFvOYrICw-CQDbDY1aOjYhkMu-0Jle6gU33dCwxah7bmy39O0hPN4jYLu_RfLuU-XejyNvXrw"
11
-
12
- #llm = ChatOpenAI(temperature=1.0, model='gpt-3.5-turbo-0613')
13
-
14
- # URLs of articles to scrape
15
- urls = ["https://modelwise.ai/product/","https://modelwise.ai/category/blog-articles/","https://modelwise.ai/company/"]
16
-
17
- # Load documents using Selenium
18
- loader = SeleniumURLLoader(urls=urls)
19
- docs_not_splitted = loader.load()
20
-
21
- # Split documents into smaller chunks
22
- text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
23
- docs = text_splitter.split_documents(docs_not_splitted)
24
-
25
- # Create OpenAIEmbeddings instance
26
- embeddings = OpenAIEmbeddings(model="text-embedding-ada-002")
27
-
28
- # Specify your ActiveLoop organization ID
29
- my_activeloop_org_id = "utkarshtiwari"
30
- my_activeloop_dataset_name = "chatbot_modelwise"
31
- dataset_path = f"hub://{my_activeloop_org_id}/{my_activeloop_dataset_name}"
32
- db = DeepLake(dataset_path=dataset_path, embedding_function=embeddings)
33
-
34
- # Add documents to the Deep Lake dataset
35
- db.add_documents(docs)
36
-
37
- template = """You are an exceptional customer support chatbot for the company Modelwise that gently answers questions related to the company.
38
-
39
- You know the following context information.
40
-
41
- {chunks_formatted}
42
-
43
- Answer the following question from a customer. Use only information from the context. If you don't know the answer just ask the customer to contact Arnold and provide his contact details. Do not make up any answer.
44
-
45
- Question: {query}
46
-
47
- Answer:"""
48
-
49
- # Create a PromptTemplate instance
50
- prompt = PromptTemplate(
51
- input_variables=["chunks_formatted", "query"],
52
- template=template,
53
- )
54
-
55
- if __name__ == '__main__':
56
- embedding()