View .c
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
#include <stdio.h> | |
void print_string(char *str) { | |
int i = 0; | |
while (str[i]) { | |
printf("%c",str[i]); | |
i++; | |
} | |
} | |
int main() { | |
char location[20] = "The 1st location\n"; |
View .swift
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
GeometryReader { geometry in | |
ScrollView(.vertical, showsIndicators: false) { | |
VStack(alignment: .leading) { | |
let rectangleHeight = geometry.size.height - contentSize.height | |
if contentSize != .zero, rectangleHeight > 0 { | |
Rectangle() | |
.frame(height: rectangleHeight) | |
.foregroundColor(.clear) | |
} | |
if let imageURL = viewModel.getImageURL() { |
View .js
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
const marvel = {}; | |
const ironMan = { key: 'arcReactor' }; | |
const captainAmerica = { key: 'superSoldierSerum' }; | |
marvel[ironMan] = 2008; | |
marvel[captainAmerica] = 2011; | |
console.log(marvel[ironMan]); |
View .py
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
def summarize_pdf(file_path): | |
split_docs = text_splitter.split_documents(chunks(file_path)) | |
return map_reduce_chain.run(split_docs) | |
result_sumary=summarize_pdf(file_path) | |
print(result_summary) |
View .py
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
map_reduce_chain = MapReduceDocumentsChain( | |
llm_chain=map_chain, | |
reduce_documents_chain=reduce_documents_chain, | |
document_variable_name="docs", | |
return_intermediate_steps=False, | |
) |
View .py
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
combine_documents_chain = StuffDocumentsChain( | |
llm_chain=reduce_chain, document_variable_name="doc_summaries" | |
) | |
reduce_documents_chain = ReduceDocumentsChain( | |
combine_documents_chain=combine_documents_chain, | |
collapse_documents_chain=combine_documents_chain, | |
token_max=5000, | |
) |
View .py
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
map_template = """The following is a set of documents | |
{docs} | |
Based on this list of docs, summarised into meaningful | |
Helpful Answer:""" | |
map_prompt = PromptTemplate.from_template(map_template) | |
map_chain = LLMChain(llm=llm, prompt=map_prompt) | |
reduce_template = """The following is set of summaries: | |
{doc_summaries} |
View .py
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
from langchain.chains.mapreduce import MapReduceChain | |
from langchain.text_splitter import CharacterTextSplitter | |
from langchain.chains import ReduceDocumentsChain, MapReduceDocumentsChain | |
from langchain import PromptTemplate | |
from langchain.chains import LLMChain | |
from langchain.chains.combine_documents.stuff import StuffDocumentsChain |
View .py
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
from langchain.document_loaders import PyPDFLoader | |
def chunks(pdf_file_path): | |
loader = PyPDFLoader(pdf_file_path) | |
docs = loader.load_and_split() | |
return docs |
View .py
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
from langchain.text_splitter import CharacterTextSplitter | |
text_splitter = CharacterTextSplitter.from_tiktoken_encoder( | |
chunk_size=1000, chunk_overlap=120 | |
) |
NewerOlder