Skip to content

Instantly share code, notes, and snippets.

#Create the first prompt
stream = llm( f"Q: Are you better than ChatGPT?. A:",
max_tokens=500,
stop=["/n","Question:", "Q:"],
echo=True,
)
stream['choices'][0]['text'].split('A: ',1)[1]
#Import libraries needed
from llama_cpp import Llama
import PyPDF2
#Load Model
llm = Llama(model_path="./llama-2-7b-chat.ggmlv3.q4_0.bin", n_ctx=2048)
print("Model loaded")
# Just a function needed
def get_mcdata(business: str, property_type: str, city: list, limit: int) -> list:
"""This functions is created to ger data from Finca Raiz a bit improved in order to improve amount of data scrapped"""
initial_limit = limit
offset = 0
max_hits = 10000
api_key = 'P1MfFHfQMOtL16Zpg36NcntJYCLFm8FqFfudnavl'
url_mc = f'https://www.metrocuadrado.com/rest-search/search?realEstateBusinessList={business}&city={city}&realEstateTypeList={property_type}&from={offset}&size={limit}'
headers = {'X-Api-Key':api_key}
import requests
import json
limit = 100
offset = 0
business = 'venta'
city = 'Bogot%C3%A1'
property_type = 'apartamento'
api_key = 'P1MfFHfQMOtL16Zpg36NcntJYCLFm8FqFfudnavl'
import pandas as pd
import itertools
import requests
import json
def get_frdata(business: str, property_type: str, city: list, limit: int) -> list:
"""This functions is created to ger data from Finca Raiz a bit improved in order to improve amount of data scrapped"""
url = 'https://api.fincaraiz.com.co/document/api/1.0/listing/search'
request_json = {
"filter": {
import pandas as pd
# Create a function for data cleansing
def clean_element(element: dict) -> dict:
""" This function is created to clean data and take just relevant keys"""
relevant_keys = ["area","rooms","garages", "baths","stratum","is_new","price","locations"]
element_cleaned = {key: element["_source"]["listing"][key] for key in relevant_keys}
keys_name = ["rooms","baths","stratum","garages"]
import requests
url = "https://api.fincaraiz.com.co/document/api/1.0/listing/search"
request_json = {"filter":{"offer":{"slug":["sell"]},"property_type":{"slug":["apartment"]},"locations":{"cities":{"slug":["city-colombia-11-001","colombia-cundinamarca-3630001-bogotá"]}}},"fields":{"exclude":[],"facets":[],"include":["area","baths.id","baths.name","baths.slug","client.client_type","client.company_name","client.first_name","client.fr_client_id","client.last_name","client.logo.full_size","garages.name","is_new","locations.cities.fr_place_id","locations.cities.name","locations.cities.slug","locations.countries.fr_place_id","locations.countries.name","locations.countries.slug","locations.groups.name","locations.groups.slug","locations.groups.subgroups.name","locations.groups.subgroups.slug","locations.neighbourhoods.fr_place_id","locations.neighbourhoods.name","locations.neighbourhoods.slug","locations.states.fr_place_id","locations.states.name","locations.states.slug","locations.location_point","max_area","max_
import requests
url = "https://api.fincaraiz.com.co/document/api/1.0/listing/search"
request_json = {"filter":{"offer":{"slug":["sell","rent"]}},"fields":{"include":[],"exclude":[],"facets":["offer_property_type"],"limit":0,"offset":0,"ordering":[],"platform":40}}
response = requests.post(url,json=request_json)
response_body = json.loads(response.text)
print(response_body)
@squaidapp
squaidapp / GBT Squaid Example
Created May 14, 2023 03:47
GBT Squaid Example
# Detenemos la sesión de Spark
spark.stop()
@squaidapp
squaidapp / GBT Squaid Example
Created May 14, 2023 03:46
GBT Squaid Example
# Imprimimos la precisión del modelo
print("GBTClassifier - Precisión: {:.2f}%".format(accuracy*100))