-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
32 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file removed
BIN
-5.99 MB
tutorial77/db_index/3b0f93d0-8b63-4a9f-ba01-4d90a2c93dd2/data_level0.bin
Binary file not shown.
Binary file removed
BIN
-100 Bytes
tutorial77/db_index/3b0f93d0-8b63-4a9f-ba01-4d90a2c93dd2/header.bin
Binary file not shown.
Binary file removed
BIN
-3.91 KB
tutorial77/db_index/3b0f93d0-8b63-4a9f-ba01-4d90a2c93dd2/length.bin
Binary file not shown.
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
from langchain_openai import OpenAIEmbeddings | ||
from langchain_chroma import Chroma | ||
from langchain_community.document_loaders import TextLoader | ||
from langchain.text_splitter import CharacterTextSplitter | ||
from langchain.text_splitter import RecursiveCharacterTextSplitter | ||
from langchain_community.document_loaders import PyPDFLoader | ||
import os | ||
|
||
os.environ["OPENAI_API_KEY"] = "sk-proj-wbrNr25jaPp9JvUx73zqT3BlbkFJDsyo7Yc4VKmeagQV6gRR" | ||
loader = PyPDFLoader(r"C:\Users\welcome\OneDrive\Documents\GitHub\LLMtutorial\tutorial77\abc.pdf") | ||
|
||
# loader=TextLoader(r"C:\Users\welcome\OneDrive\Documents\GitHub\LLMtutorial\tutorial77\test.txt") | ||
# documents=loader.load() | ||
# text_splitter=CharacterTextSplitter(chunk_size=500,chunk_overlap=0) | ||
# text_splitter=RecursiveCharacterTextSplitter(chunk_size=500,chunk_overlap=0) | ||
# docs=text_splitter.split_documents(documents) | ||
# vs=Chroma.from_documents(documents=docs,embedding=OpenAIEmbeddings(),persist_directory="./db_index") | ||
# print(len(docs)) | ||
|
||
# for i in range(100): | ||
# vs=Chroma.from_documents(documents=docs,embedding=OpenAIEmbeddings(),persist_directory="./db_index_"+str(i)) | ||
|
||
vs=Chroma(persist_directory="./db_index",embedding_function=OpenAIEmbeddings()) | ||
info=vs.similarity_search("family of king john",k=3) | ||
print(info) | ||
# print(info) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from langchain_openai import OpenAI | ||
from langchain.chains import APIChain | ||
|
||
|
||
api_docs=""" | ||
base_url:https://api.coincap.io | ||
end point /v2/assets/{name} uses GET requrest to give information on any crypto token, | ||
here name is url parameter which is actually the name of the crytop token in lower case | ||
""" | ||
llm=OpenAI(temperature=0) | ||
chain=APIChain.from_llm_and_api_docs( | ||
llm, | ||
api_docs, | ||
verbose=True, | ||
limit_to_domains=["https://api.coincap.io"] | ||
) | ||
response=chain.invoke("what is the price of ethereum") | ||
print(response) |
Binary file not shown.
Binary file not shown.