Chain-Internals

Fri 14 November 2025

8
How to: add message history (memory) to a chain
https://python.langchain.com/docs/how_to/message_history/

!python --version
Python 3.12.4
from constants import OPENAI_API_KEY
!pip show langchain-openai | grep "Version:"
Version: 0.2.9
import os
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
from langchain_openai import ChatOpenAI

model = ChatOpenAI(model …

Category: langchain

Read More

Chainmap

Fri 14 November 2025

title: "Chainmap" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


city = {'name': 'Toronto', 'short_name': 'TO'}
number = {'a': 2, 'b': 3, 'c' : 4}
city
{'name': 'Toronto', 'short_name': 'TO'}
number
{'a': 2, 'b': 3, 'c': 4}
from collections import ChainMap
ab = ChainMap(city, number)
ab
ChainMap({'name': 'Toronto', 'short_name …

Category: basics

Read More

Chains

Fri 14 November 2025
from constants import OPENAI_API_KEY
!pip show langchain-openai | grep "Version:"
Version: 0.2.9
import os
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
from langchain_openai import ChatOpenAI

model = ChatOpenAI(model="gpt-4o-mini")
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate

prompt = ChatPromptTemplate.from_template("tell me a joke about {topic}")
parser = StrOutputParser()
chain …

Category: langchain

Read More

Change-Columns-Based-On-Other-Column

Fri 14 November 2025

title: "Change Column Based on Other Column" author: "Rj" date: 2019-04-24 description: "-" type: technical_note draft: false


import numpy as np
import pandas as pd
df = pd.read_csv('marks.csv')
df
student language …

Category: data-wrangling

Read More

Check Datatypes

Fri 14 November 2025

title: "Check Data Types" author: "Rj" date: 2019-04-24 description: "-" type: technical_note draft: false


import numpy as np
import pandas as pd
df = pd.read_csv("/Users/rajacsp/datasets/sales_data_types.csv")
df
Customer Number …

Category: data-wrangling

Read More

Checkin-Array

Fri 14 November 2025

def checkInArray(list, cc):
    #print(len(list))
    for x in list:
        print(x)

        if(x in cc):
            print('x['+x+'] ==> '+cc)
            return True

    return False


domain = "springframework.guru"

if(checkInArray(["baeldung", "abcde.com", "docs.spring.io", "springframework.guru",
                     "logback.qos.ch", "javabeat.net"], domain) ):
    print("java")
baeldung
abcde.com
docs …

Category: array

Read More

Chloropleth Maps

Fri 14 November 2025

title: "Chloropleth Maps" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import geopandas
world = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres"))
world.head()
pop_est continent name iso_a3 gdp_md_est geometry
0 …

Category: geopandas

Read More

Chua-Circuit

Fri 14 November 2025

from bokeh.plotting import figure, output_file, show
from bokeh.io import output_notebook
from bokeh.models import ColumnDataSource
# Set Bokeh output to notebook
output_notebook()

Category: bokeh

Read More

Cistem-Stemmer

Fri 14 November 2025

title: "Cistem Stemmer" author: "Rj" date: 2019-04-21 description: "-" type: technical_note draft: false


from nltk.stem.cistem import Cistem
c_stemmer = Cistem()
print(c_stemmer.stem("filtering"))
filtering
print(c_stemmer.segment("filtering"))
('filtering', '')
print(c_stemmer.segment("Ausgefeiltere"))
('ausgefeilt', 'ere')
  • segment method will return both the stem and the rest that was removed at …

Category: textprocessing

Read More

City Location

Fri 14 November 2025

title: "City Location" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


from geopy.geocoders import Nominatim
geoloc = Nominatim(user_agent="rajarcsp", format_string="%s, Toronto ON")
address, (lat, long) = geoloc.geocode("26, Spadina Road")
address
'Spadina Road, The Annex, University—Rosedale, Old Toronto, Toronto, Ontario, M5R 2X3, Canada'


Score …

Category: geopandas

Read More
Page 92 of 146

« Prev Next »